From patchwork Thu Feb 29 13:17:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 208359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp386737dyb; Thu, 29 Feb 2024 05:19:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUYpeCeB6UELqvrSqe3kNH7/SfVxxrlywzbd1dM51dliOV314kAraNV7GjjBtodkl2Yn7VdoGUHb2lfEyskANyQN5MrAg== X-Google-Smtp-Source: AGHT+IG+P5ZUO7JA4kIhKRsRRkm03admYfpGhMOtz3vpHy7AYDtSlAOddVTtXoL5Tx/nLriY4gh1 X-Received: by 2002:a92:dd09:0:b0:365:1035:55ab with SMTP id n9-20020a92dd09000000b00365103555abmr2477630ilm.7.1709212769661; Thu, 29 Feb 2024 05:19:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709212769; cv=pass; d=google.com; s=arc-20160816; b=L1HP1tfMJMioKocxBsPs9m8xnZooj2V6pMiX6BQ90peH++JkvS+6TxWNWC6ufgEntA NXFUqVNwBcOjdKcFbtaMTasEMFIw14/ijkVueHmHFrVflJnbJkICJtslpVSePmYOZyrl xWCWhrqGB09XCksD7vxH1sGjyanDDLukzkKgZuDVzTF8tOiObZ2fXBWsiyH7ADRzqfDV fljC+lJoQ4CwaYtfNDg3Ti5y1znNtGHvSTOh3AcOyhbslCN+jndUCZegScomK0G+hVl/ gYmQmTN2F+2uPzVABMmT3gadzm+CRGwG/yOn+rkA4LbqDSY48GaYGfCQaQdHN6Svf6Cy zyaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=yG40N0lNsl+2yNQD0AbqRVz2p0LrcwZf0KyDHikEEKQ=; fh=v6JR+PIa3GxXJxWhnTX8Om1ejtg8GC4J7wMV1OBCm7k=; b=uQQXpueAyh975g4EuXM1nzadpqNUar5AQ2KU32bJsV7kGbEKDsCqI+TRZZBgn7a5eU QeMB739BmKPvT7UO19PqhF2D9pTT0Mr4BonYnPZ5ykmrH6TpC3DDa5v1d3uq05xNVNL8 0rX7YO/f2xgjNb/ax2v5SaAsC5qfeIirxw7Zu5XsKcvVR1cTgF5wwixgYeFWWY0CoTud 2M5AsX6VgJbDHtxGBOzzsLdbAvJmC45ttxMpjHhTrVNLH61XiMuLEzuTgDhb+YCE/s3i nGnlh5vTnOjRCrNfVUOGLh3fYWg3LtSJQoPJGabeKexxesdcbHBUw0OYfjmWJKQTHzj4 2JBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=DA307nsL; dkim=pass header.i=@suse.com header.s=susede1 header.b=DA307nsL; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-86741-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86741-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u15-20020a62d44f000000b006e55c331b48si1269548pfl.327.2024.02.29.05.19.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 05:19:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86741-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=DA307nsL; dkim=pass header.i=@suse.com header.s=susede1 header.b=DA307nsL; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-86741-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86741-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6F715284970 for ; Thu, 29 Feb 2024 13:19:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A62882860; Thu, 29 Feb 2024 13:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="DA307nsL"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="DA307nsL" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 BCF631DFE3; Thu, 29 Feb 2024 13:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709212745; cv=none; b=tkBsGH9vW59zesz5KPZGqMxdLKlJK+yDl5hjeoudD3y+uvsXzFtm/sTbtD5stVrI/lBN655C4WPjjjPOBjzEYYRIFH+xya/TwhX3dnKLht2OBU0fixjcAk1PoIgkqy8W+26qghzRacKxqNeBYbVz2knemWN+5TXLKG65ss84Srs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709212745; c=relaxed/simple; bh=ftMktD3pCFTnpyLcc5TiO5qk07HSjVHQ7MHGcD+s7Wo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J7p6kIDKBhaO7pK9zWPZW1Jo+96Ke7Ahg7SkQ6gQeg3NxPx67VBJ1al+HQ/JWC6Qh1BGvseNGA1L7v5p2LwIjhC2ORTiDoM43/X580zzB3KG7O+U72aLf10AnH7z5G1ANJOQiJVu6zs1YWqgwNzAzdt+rA8xHiKaYAYvmJBD2v0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=DA307nsL; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=DA307nsL; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9D97022807; Thu, 29 Feb 2024 13:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1709212735; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yG40N0lNsl+2yNQD0AbqRVz2p0LrcwZf0KyDHikEEKQ=; b=DA307nsLaKcv8JPrfNrzJwUEZow2NGMu77YnPa52gGGqrdufFPl4UzAGvU/0CmtVMa3obp rUn3r/louQB4MW/no92Nny7/onMziABPQ1Jdff550ycpTLqlGu+YN4zgEM+9GLRZ9g4qBV VUvpLwzvmfJ1rKch8MnE/sDX8A8wE70= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1709212735; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yG40N0lNsl+2yNQD0AbqRVz2p0LrcwZf0KyDHikEEKQ=; b=DA307nsLaKcv8JPrfNrzJwUEZow2NGMu77YnPa52gGGqrdufFPl4UzAGvU/0CmtVMa3obp rUn3r/louQB4MW/no92Nny7/onMziABPQ1Jdff550ycpTLqlGu+YN4zgEM+9GLRZ9g4qBV VUvpLwzvmfJ1rKch8MnE/sDX8A8wE70= Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 5067013A42; Thu, 29 Feb 2024 13:18:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id ULAvET+E4GWPKQAAn2gu4w (envelope-from ); Thu, 29 Feb 2024 13:18:55 +0000 From: Oliver Neukum To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH] usb: typec: pd: no opencoding of FIELD_GET Date: Thu, 29 Feb 2024 14:17:33 +0100 Message-ID: <20240229131851.16148-2-oneukum@suse.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240229131851.16148-1-oneukum@suse.com> References: <20240229131851.16148-1-oneukum@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=DA307nsL X-Spamd-Result: default: False [2.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DWL_DNSWL_MED(-2.00)[suse.com:dkim]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 2.69 X-Rspamd-Queue-Id: 9D97022807 X-Spam-Level: ** X-Spam-Flag: NO X-Spamd-Bar: ++ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792239489253163097 X-GMAIL-MSGID: 1792239489253163097 If we have a neat macro, at least new code should use it. Signed-off-by: Oliver Neukum --- include/linux/usb/pd_vdo.h | 5 +++-- include/linux/usb/typec_dp.h | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h index c09c5a12e273..5c48e8a81403 100644 --- a/include/linux/usb/pd_vdo.h +++ b/include/linux/usb/pd_vdo.h @@ -7,6 +7,7 @@ #define __LINUX_USB_PD_VDO_H #include "pd.h" +#include /* * VDO : Vendor Defined Message Object @@ -188,7 +189,7 @@ * <5:3> :: Alternate modes * <2:0> :: USB highest speed */ -#define PD_VDO_UFP_DEVCAP(vdo) (((vdo) & GENMASK(27, 24)) >> 24) +#define PD_VDO_UFP_DEVCAP(vdo) FIELD_GET(GENMASK(27, 24), vdo) /* UFP VDO Version */ #define UFP_VDO_VER1_2 2 @@ -247,7 +248,7 @@ * <21:5> :: Reserved * <4:0> :: Port number */ -#define PD_VDO_DFP_HOSTCAP(vdo) (((vdo) & GENMASK(26, 24)) >> 24) +#define PD_VDO_DFP_HOSTCAP(vdo) FIELD_GET(GENMASK(26, 24), vdo) #define DFP_VDO_VER1_1 1 #define HOST_USB2_CAPABLE BIT(0) diff --git a/include/linux/usb/typec_dp.h b/include/linux/usb/typec_dp.h index 1f358098522d..f2da264d9c14 100644 --- a/include/linux/usb/typec_dp.h +++ b/include/linux/usb/typec_dp.h @@ -3,6 +3,7 @@ #define __USB_TYPEC_DP_H #include +#include #define USB_TYPEC_DP_SID 0xff01 /* USB IF has not assigned a Standard ID (SID) for VirtualLink, @@ -67,21 +68,21 @@ enum { #define DP_CAP_UFP_D 1 #define DP_CAP_DFP_D 2 #define DP_CAP_DFP_D_AND_UFP_D 3 -#define DP_CAP_DP_SIGNALLING(_cap_) (((_cap_) & GENMASK(5, 2)) >> 2) +#define DP_CAP_DP_SIGNALLING(_cap_) FIELD_GET(GENMASK(5, 2), _cap_) #define DP_CAP_SIGNALLING_HBR3 1 #define DP_CAP_SIGNALLING_UHBR10 2 #define DP_CAP_SIGNALLING_UHBR20 3 #define DP_CAP_RECEPTACLE BIT(6) #define DP_CAP_USB BIT(7) -#define DP_CAP_DFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(15, 8)) >> 8) -#define DP_CAP_UFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(23, 16)) >> 16) +#define DP_CAP_DFP_D_PIN_ASSIGN(_cap_) FIELD_GET(GENMASK(15, 8), _cap_) +#define DP_CAP_UFP_D_PIN_ASSIGN(_cap_) FIELD_GET(GENMASK(23, 16), _cap_) /* Get pin assignment taking plug & receptacle into consideration */ #define DP_CAP_PIN_ASSIGN_UFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_)) #define DP_CAP_PIN_ASSIGN_DFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_)) #define DP_CAP_UHBR_13_5_SUPPORT BIT(26) -#define DP_CAP_CABLE_TYPE(_cap_) (((_cap_) & GENMASK(29, 28)) >> 28) +#define DP_CAP_CABLE_TYPE(_cap_) FIELD_GET(GENMASK(29, 28), _cap_) #define DP_CAP_CABLE_TYPE_PASSIVE 0 #define DP_CAP_CABLE_TYPE_RE_TIMER 1 #define DP_CAP_CABLE_TYPE_RE_DRIVER 2 @@ -116,7 +117,7 @@ enum { /* Helper for setting/getting the pin assignment value to the configuration */ #define DP_CONF_SET_PIN_ASSIGN(_a_) ((_a_) << 8) -#define DP_CONF_GET_PIN_ASSIGN(_conf_) (((_conf_) & GENMASK(15, 8)) >> 8) +#define DP_CONF_GET_PIN_ASSIGN(_conf_) FIELD_GET(GENMASK(15, 8), _conf_) #define DP_CONF_UHBR13_5_SUPPORT BIT(26) #define DP_CONF_CABLE_TYPE_MASK GENMASK(29, 28) #define DP_CONF_CABLE_TYPE_SHIFT 28