lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y8AJak+munzDqTPK@kuha.fi.intel.com>
Date:   Thu, 12 Jan 2023 15:21:46 +0200
From:   Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To:     Prashant Malani <pmalani@...omium.org>
Cc:     linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
        bleung@...omium.org, stable@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Guillaume Ranquet <granquet@...libre.com>,
        Macpaul Lin <macpaul.lin@...iatek.com>,
        Pablo Sun <pablo.sun@...iatek.com>
Subject: Re: [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment
 helper

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@...r.kernel.org
> Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> Signed-off-by: Prashant Malani <pmalani@...omium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>

> ---
> 
> 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

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ