From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BDB9315D5E for ; Wed, 10 Dec 2025 10:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765361928; cv=none; b=NzwXDZOO10XywFbxaLZFobaRpHTyx7clkZs/xykJZQhlfPYBMvp+g+zpU6ZibMnJMfXDbA65olnq3MKW0sjiSJx6VunZcRmZL0hZzlJKlEHhbFN+CwKXpO7at5qda/z0u9Pw2EX4VDhoJzh5fmZTKrbBazlLfOUKsrqe5SEIAGg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765361928; c=relaxed/simple; bh=I/JMNNp1r55UL6QKtwkNR+AyEKT986MddtqR5zGlc94=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iR1lFdgnsN3jQcydjaLuOjQJMcylDwN2rbEcw8yFU8dnZJ7HqzA2539iSngHWcAWc3JEun4T64Un0Pw/6yNzxX/Mj+niNYzzKt8qq9flD12TAyLL2XA+bGQ7o4j2e8JI8Lp3Fylic4Gdw1a8znDouuCScH3zO3/v2meE4kpye24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JhDcGuxJ; arc=none smtp.client-ip=209.85.221.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JhDcGuxJ" Received: by mail-wr1-f65.google.com with SMTP id ffacd0b85a97d-42e2e52cc04so2392158f8f.0 for ; Wed, 10 Dec 2025 02:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765361925; x=1765966725; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ivJBwP5GNe4rsrKX30pWrsmTA+5ClhNGxoBEPh+DS3E=; b=JhDcGuxJoSfUxR7CjDBVcePFgl7mIlIgVNM+ZlYC0d/guoykVKnfcRUyM/pynYzusZ TxL5tihTds4nAFseG7GA/fpk+4wyFQGb5LVl9VhE8zmpRkPXyPb1enDa6+VpVs8y47UO qRmbv4xnMfyBkJseULJm3hWsqbAaSfNuA7SIup3Ii//TW/fZAISQuCZoBduMHO1u7E1x 3Q/IHLu3w02yJL/ny11hvpkI+IylQIqCs3cF7ixmWQNYfoPXrAG+aVoRX0ghjIrrO2Gg Ieo5xVrRZYhfBl1RNIo/qiLaJCt6XV5pAdLXH7eNl/ZHLa5OCHTmBYRjLJxxUFKzgfSk KotQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765361925; x=1765966725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ivJBwP5GNe4rsrKX30pWrsmTA+5ClhNGxoBEPh+DS3E=; b=aucN1iDD66oiaMrmPcvfBl7zwITGGn4NBPNV8gT9KFhGUU6DbkViUIz6BxP3E6cbd7 Mjqepb4g0gZ0VjYDFc/dQ34PnGCnohgkk5wFcYW4ddliROkfq0aaXBPPXfMv0C+BTlrt SGM4ZpKhgIeM9KIOgGa61xoO9qZylvlmo5As23nDTyG8ALU6Owc1G0ZJMdoEDF3jvZ8/ +cVJpXstotSpAPJ6BWe4Mw8TVizvTTXwF2mbDRqcD9g45twLY0HTJiGMSxbtsu+WmVOW Re7j37mb4K+OkoG2e49AgXtLheS7CmUzuLuiYpQ8+6fGrIKiJAKjyt15ueSZ+WAZFcre DmbQ== X-Forwarded-Encrypted: i=1; AJvYcCUcSfIHvKV6B/P3cmHBxXqKY+F+8QBIl+EquyM3fIF+tJxx8GByT3+lZX7OQaxJETWOfm1HyNnA0P0sBMA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3j6U76kg24BJkmABu3UFMbKfi+A1ZjVaG0ldRf2QlyDHWWl/2 V+IrasKkaBT40dGb8UBFF1c+1LA5f1PgJDuWaDP5nMpKZVJUTpwty27z X-Gm-Gg: AY/fxX4sVVtuqPkqYNCsdyoaa1nkEmeskZzw4lxXfPwUi0jmpiPjh4cfgTZT35+adyL 2/zIHt6ycz5tAHAR0NU9PJG1eZgxzNt4fL2xJcYYmYh94gz0dwspQrvBKFG20g6SDskVyKAIO3p e4VzFrm1LSNcsWEVPqVesvAMq/rUDVaE5NTXMiYWLiAwwRK9bLMQAtOY24nyofYpny2hoUtthod UvZK2dBCFTjCnmOxJuf5U/0BuKchp3Pl36Met4HDlyCtejVUyrVdUtOS8KSfU0WcRTefCD4QKHW wQom2R3vDcdAVgrdncvDKr2gTng/yFc//LJQrbmYg+JCzdRAy3VMSjcxXRmsMxpiLPdTICSJ9X6 FhAxebc6ijf7h31K32Q7vdOLBKSVig2/CNLd9ANrtqYMzY8k0hJu+gLrrVxJP58dHebkrPCMvQ9 +5b7fgP9CT8i0CDR53BymoLZMGNWZAudWXax8gc2eh7Za4N+vRgQI4 X-Google-Smtp-Source: AGHT+IHnnDz/LzTTRTNEb7lg6Qv9pz02shzN5UFCICKksM96FcH+4Cq+vdcgE23tcA9uj4y82edHXw== X-Received: by 2002:a05:6000:40c8:b0:42b:3bc4:16dc with SMTP id ffacd0b85a97d-42fa39d2c8emr1581708f8f.21.1765361924693; Wed, 10 Dec 2025 02:18:44 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7cbfeadesm36502473f8f.10.2025.12.10.02.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Dec 2025 02:18:44 -0800 (PST) Date: Wed, 10 Dec 2025 10:18:42 +0000 From: David Laight To: Mika Westerberg Cc: Yury Norov , Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Geert Uytterhoeven , Alexandre Belloni , Jonathan Cameron , Crt Mori , Richard Genoud , Andy Shevchenko , Luo Jie , Peter Zijlstra , Jakub Kicinski , netdev@vger.kernel.org, "David S . Miller" , Simon Horman , Andreas Noever , Yehezkel Bernat , Nicolas Frattaroli Subject: Re: [PATCH 2/9] thunderblot: Don't pass a bitfield to FIELD_GET Message-ID: <20251210101842.022d1a99@pumpkin> In-Reply-To: <20251210094102.GF2275908@black.igk.intel.com> References: <20251209100313.2867-1-david.laight.linux@gmail.com> <20251209100313.2867-3-david.laight.linux@gmail.com> <20251210055617.GD2275908@black.igk.intel.com> <20251210093403.5b0f440e@pumpkin> <20251210094102.GF2275908@black.igk.intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 10 Dec 2025 10:41:02 +0100 Mika Westerberg wrote: > On Wed, Dec 10, 2025 at 09:34:03AM +0000, David Laight wrote: > > On Wed, 10 Dec 2025 06:56:17 +0100 > > Mika Westerberg wrote: > > > > > $subject has typo: thunderblot -> thunderbolt ;-) > > > > > > On Tue, Dec 09, 2025 at 10:03:06AM +0000, david.laight.linux@gmail.com wrote: > > > > From: David Laight > > > > > > > > FIELD_GET needs to use __auto_type to get the value of the 'reg' > > > > parameter, this can't be used with bifields. > > > > > > > > FIELD_GET also want to verify the size of 'reg' so can't add zero > > > > to force the type to int. > > > > > > > > So add a zero here. > > > > > > > > Signed-off-by: David Laight > > > > --- > > > > drivers/thunderbolt/tb.h | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h > > > > index e96474f17067..7ca2b5a0f01e 100644 > > > > --- a/drivers/thunderbolt/tb.h > > > > +++ b/drivers/thunderbolt/tb.h > > > > @@ -1307,7 +1307,7 @@ static inline struct tb_retimer *tb_to_retimer(struct device *dev) > > > > */ > > > > static inline unsigned int usb4_switch_version(const struct tb_switch *sw) > > > > { > > > > - return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); > > > > + return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version + 0); > > > > > > Can't this use a cast instead? If not then can you also add a comment here > > > because next someone will send a patch "fixing" the unnecessary addition. > > > > A cast can do other (possibly incorrect) conversions, adding zero is never going > > to so any 'damage' - even if it looks a bit odd. > > > > Actually, I suspect the best thing here is to delete USB4_VERSION_MAJOR_MASK and > > just do: > > /* The major version is in the top 3 bits */ > > return sw->config.thunderbolt_version > 5; > > You mean > > return sw->config.thunderbolt_version >> 5; > > ? > > Yes that works but I prefer then: > > return sw->config.thunderbolt_version >> USB4_VERSION_MAJOR_SHIFT; I've put that in for the next version (without the comment line). David > > > > > The only other uses of thunderbolt_version are debug prints (in decimal). > > > > David > > > > > > > > > } > > > > > > > > /** > > > > -- > > > > 2.39.5 >