public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benson Leung <bleung@google.com>
To: Prashant Malani <pmalani@chromium.org>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	bleung@chromium.org, stable@vger.kernel.org,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Guillaume Ranquet <granquet@baylibre.com>,
	Macpaul Lin <macpaul.lin@mediatek.com>,
	Pablo Sun <pablo.sun@mediatek.com>
Subject: Re: [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper
Date: Tue, 10 Jan 2023 18:11:51 -0800	[thread overview]
Message-ID: <Y74a53YFeYECjvH4@google.com> (raw)
In-Reply-To: <20230111020546.3384569-1-pmalani@chromium.org>

[-- Attachment #1: Type: text/plain, Size: 3140 bytes --]

On Wed, Jan 11, 2023 at 02:05:41AM +0000, Prashant Malani wrote:
> The code to extract a peripheral's currently supported Pin Assignments
> is repeated in a couple of locations. Factor it out into a separate
> function.
> 
> This will also make it easier to add fixes (we only need to update 1
> location instead of 2).
> 
> Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles")
> Cc: stable@vger.kernel.org
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Benson Leung <bleung@chromium.org>


> ---
> 
> While this patch doesn't fix anything, it is required by the actual
> fix (which is Patch 2/3 in this series). So, I've add the "Fixes" tag
> and "Cc stable" tag to ensure that both patches are picked.
> 
> If this is the incorrect approach and there is a better way, my
> apologies, and please let me know the appropriate process.
> 
>  drivers/usb/typec/altmodes/displayport.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index 06fb4732f8cd..f9d4a7648bc9 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -420,6 +420,18 @@ static const char * const pin_assignments[] = {
>  	[DP_PIN_ASSIGN_F] = "F",
>  };
>  
> +/*
> + * Helper function to extract a peripheral's currently supported
> + * Pin Assignments from its DisplayPort alternate mode state.
> + */
> +static u8 get_current_pin_assignments(struct dp_altmode *dp)
> +{
> +	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
> +		return DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo);
> +	else
> +		return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
> +}
> +
>  static ssize_t
>  pin_assignment_store(struct device *dev, struct device_attribute *attr,
>  		     const char *buf, size_t size)
> @@ -446,10 +458,7 @@ pin_assignment_store(struct device *dev, struct device_attribute *attr,
>  		goto out_unlock;
>  	}
>  
> -	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
> -		assignments = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo);
> -	else
> -		assignments = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
> +	assignments = get_current_pin_assignments(dp);
>  
>  	if (!(DP_CONF_GET_PIN_ASSIGN(conf) & assignments)) {
>  		ret = -EINVAL;
> @@ -486,10 +495,7 @@ static ssize_t pin_assignment_show(struct device *dev,
>  
>  	cur = get_count_order(DP_CONF_GET_PIN_ASSIGN(dp->data.conf));
>  
> -	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
> -		assignments = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo);
> -	else
> -		assignments = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
> +	assignments = get_current_pin_assignments(dp);
>  
>  	for (i = 0; assignments; assignments >>= 1, i++) {
>  		if (assignments & 1) {
> -- 
> 2.39.0.314.g84b9a713c41-goog
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2023-01-11  2:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  2:05 [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Prashant Malani
2023-01-11  2:05 ` [PATCH 2/3] usb: typec: altmodes/displayport: Fix pin assignment calculation Prashant Malani
2023-01-11  2:12   ` Benson Leung
2023-01-12 13:23   ` Heikki Krogerus
2023-01-11  2:05 ` [PATCH 3/3] usb: typec: altmodes/displayport: Use proper macro for pin assignment check Prashant Malani
2023-01-11  2:13   ` Benson Leung
2023-01-12 13:24   ` Heikki Krogerus
2023-01-11  2:11 ` Benson Leung [this message]
2023-01-12 13:21 ` [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Heikki Krogerus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y74a53YFeYECjvH4@google.com \
    --to=bleung@google.com \
    --cc=bleung@chromium.org \
    --cc=granquet@baylibre.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=macpaul.lin@mediatek.com \
    --cc=pablo.sun@mediatek.com \
    --cc=pmalani@chromium.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox