All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper
@ 2023-01-11  2:05 Prashant Malani
  2023-01-11  2:05 ` [PATCH 2/3] usb: typec: altmodes/displayport: Fix pin assignment calculation Prashant Malani
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Prashant Malani @ 2023-01-11  2:05 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: bleung, Prashant Malani, stable, Heikki Krogerus,
	Greg Kroah-Hartman, Guillaume Ranquet, Macpaul Lin, Pablo Sun

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

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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] usb: typec: altmodes/displayport: Fix pin assignment calculation
  2023-01-11  2:05 [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Prashant Malani
@ 2023-01-11  2:05 ` 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
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Prashant Malani @ 2023-01-11  2:05 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: bleung, Prashant Malani, stable, Heikki Krogerus,
	Greg Kroah-Hartman, Guillaume Ranquet, Macpaul Lin, Pablo Sun

Commit c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin
assignment for UFP receptacles") fixed the pin assignment calculation
to take into account whether the peripheral was a plug or a receptacle.

But the "pin_assignments" sysfs logic was not updated. Address this by
using the macros introduced in the aforementioned commit in the sysfs
logic too.

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>
---
 drivers/usb/typec/altmodes/displayport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index f9d4a7648bc9..c0d65c93cefe 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -427,9 +427,9 @@ static const char * const pin_assignments[] = {
 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);
+		return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo);
 	else
-		return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
+		return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo);
 }
 
 static ssize_t
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] usb: typec: altmodes/displayport: Use proper macro for pin assignment check
  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:05 ` Prashant Malani
  2023-01-11  2:13   ` Benson Leung
  2023-01-12 13:24   ` Heikki Krogerus
  2023-01-11  2:11 ` [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Benson Leung
  2023-01-12 13:21 ` Heikki Krogerus
  3 siblings, 2 replies; 9+ messages in thread
From: Prashant Malani @ 2023-01-11  2:05 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: bleung, Prashant Malani, Heikki Krogerus, Greg Kroah-Hartman,
	Guillaume Ranquet, Macpaul Lin, Pablo Sun

While looking at the DP configuration VDO to determine the peripheral
configuration, the spec (Table 8-5: DisplayPort Configurations, VESA
DisplayPort Alt Mode Standard v2.0) lists the options as "UFP_U as a DP
Source/Sink Device".

So, use the correct macro while performing this check. Effectively it's
the same as the existing code, but the proposed macro describes the
state a little better.

No functional changes introduced.

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/usb/typec/altmodes/displayport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index c0d65c93cefe..746bfbf3d557 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -426,7 +426,7 @@ static const char * const pin_assignments[] = {
  */
 static u8 get_current_pin_assignments(struct dp_altmode *dp)
 {
-	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
+	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_UFP_U_AS_DFP_D)
 		return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo);
 	else
 		return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo);
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper
  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:05 ` [PATCH 3/3] usb: typec: altmodes/displayport: Use proper macro for pin assignment check Prashant Malani
@ 2023-01-11  2:11 ` Benson Leung
  2023-01-12 13:21 ` Heikki Krogerus
  3 siblings, 0 replies; 9+ messages in thread
From: Benson Leung @ 2023-01-11  2:11 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, bleung, stable, Heikki Krogerus,
	Greg Kroah-Hartman, Guillaume Ranquet, Macpaul Lin, Pablo Sun

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] usb: typec: altmodes/displayport: Fix pin assignment calculation
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Benson Leung @ 2023-01-11  2:12 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, bleung, stable, Heikki Krogerus,
	Greg Kroah-Hartman, Guillaume Ranquet, Macpaul Lin, Pablo Sun

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

On Wed, Jan 11, 2023 at 02:05:42AM +0000, Prashant Malani wrote:
> Commit c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin
> assignment for UFP receptacles") fixed the pin assignment calculation
> to take into account whether the peripheral was a plug or a receptacle.
> 
> But the "pin_assignments" sysfs logic was not updated. Address this by
> using the macros introduced in the aforementioned commit in the sysfs
> logic too.
> 
> 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>


> ---
>  drivers/usb/typec/altmodes/displayport.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index f9d4a7648bc9..c0d65c93cefe 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -427,9 +427,9 @@ static const char * const pin_assignments[] = {
>  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);
> +		return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo);
>  	else
> -		return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
> +		return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo);
>  }
>  
>  static ssize_t
> -- 
> 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 --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] usb: typec: altmodes/displayport: Use proper macro for pin assignment check
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Benson Leung @ 2023-01-11  2:13 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, bleung, Heikki Krogerus,
	Greg Kroah-Hartman, Guillaume Ranquet, Macpaul Lin, Pablo Sun

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

On Wed, Jan 11, 2023 at 02:05:43AM +0000, Prashant Malani wrote:
> While looking at the DP configuration VDO to determine the peripheral
> configuration, the spec (Table 8-5: DisplayPort Configurations, VESA
> DisplayPort Alt Mode Standard v2.0) lists the options as "UFP_U as a DP
> Source/Sink Device".
> 
> So, use the correct macro while performing this check. Effectively it's
> the same as the existing code, but the proposed macro describes the
> state a little better.
> 
> No functional changes introduced.
> 
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

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


> ---
>  drivers/usb/typec/altmodes/displayport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index c0d65c93cefe..746bfbf3d557 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -426,7 +426,7 @@ static const char * const pin_assignments[] = {
>   */
>  static u8 get_current_pin_assignments(struct dp_altmode *dp)
>  {
> -	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
> +	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_UFP_U_AS_DFP_D)
>  		return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo);
>  	else
>  		return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo);
> -- 
> 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 --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper
  2023-01-11  2:05 [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Prashant Malani
                   ` (2 preceding siblings ...)
  2023-01-11  2:11 ` [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Benson Leung
@ 2023-01-12 13:21 ` Heikki Krogerus
  3 siblings, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2023-01-12 13:21 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, bleung, stable, Greg Kroah-Hartman,
	Guillaume Ranquet, Macpaul Lin, Pablo Sun

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: Heikki Krogerus <heikki.krogerus@linux.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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] usb: typec: altmodes/displayport: Fix pin assignment calculation
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2023-01-12 13:23 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, bleung, stable, Greg Kroah-Hartman,
	Guillaume Ranquet, Macpaul Lin, Pablo Sun

On Wed, Jan 11, 2023 at 02:05:42AM +0000, Prashant Malani wrote:
> Commit c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin
> assignment for UFP receptacles") fixed the pin assignment calculation
> to take into account whether the peripheral was a plug or a receptacle.
> 
> But the "pin_assignments" sysfs logic was not updated. Address this by
> using the macros introduced in the aforementioned commit in the sysfs
> logic too.
> 
> 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: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/altmodes/displayport.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index f9d4a7648bc9..c0d65c93cefe 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -427,9 +427,9 @@ static const char * const pin_assignments[] = {
>  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);
> +		return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo);
>  	else
> -		return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo);
> +		return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo);
>  }
>  
>  static ssize_t
> -- 
> 2.39.0.314.g84b9a713c41-goog

-- 
heikki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] usb: typec: altmodes/displayport: Use proper macro for pin assignment check
  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
  1 sibling, 0 replies; 9+ messages in thread
From: Heikki Krogerus @ 2023-01-12 13:24 UTC (permalink / raw)
  To: Prashant Malani
  Cc: linux-kernel, linux-usb, bleung, Greg Kroah-Hartman,
	Guillaume Ranquet, Macpaul Lin, Pablo Sun

On Wed, Jan 11, 2023 at 02:05:43AM +0000, Prashant Malani wrote:
> While looking at the DP configuration VDO to determine the peripheral
> configuration, the spec (Table 8-5: DisplayPort Configurations, VESA
> DisplayPort Alt Mode Standard v2.0) lists the options as "UFP_U as a DP
> Source/Sink Device".
> 
> So, use the correct macro while performing this check. Effectively it's
> the same as the existing code, but the proposed macro describes the
> state a little better.
> 
> No functional changes introduced.
> 
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

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

> ---
>  drivers/usb/typec/altmodes/displayport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index c0d65c93cefe..746bfbf3d557 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -426,7 +426,7 @@ static const char * const pin_assignments[] = {
>   */
>  static u8 get_current_pin_assignments(struct dp_altmode *dp)
>  {
> -	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D)
> +	if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_UFP_U_AS_DFP_D)
>  		return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo);
>  	else
>  		return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo);
> -- 
> 2.39.0.314.g84b9a713c41-goog

-- 
heikki

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-01-12 13:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/3] usb: typec: altmodes/displayport: Add pin assignment helper Benson Leung
2023-01-12 13:21 ` Heikki Krogerus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.