linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] usb: typec: ucsi: glink: fix and improve orientation handling
@ 2024-11-09  0:04 Dmitry Baryshkov
  2024-11-09  0:04 ` [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status Dmitry Baryshkov
  2024-11-09  0:04 ` [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports Dmitry Baryshkov
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Baryshkov @ 2024-11-09  0:04 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Heikki Krogerus, linux-usb, linux-kernel, linux-arm-msm,
	Abel Vesa, Johan Hovold, stable, Neil Armstrong

Fix an off-by-one issue which resulted in USB-C connector #2 orientation
being reported as unknown. While we are at it, correct the way we set
orientation_aware flag for the USB-C connectors.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Changes in v2:
- Added cc:stable to the first patch (Greg's bot)
- Expanded the commit message for the second patch.
- Link to v1: https://lore.kernel.org/r/20241106-ucsi-glue-fixes-v1-0-d0183d78c522@linaro.org

---
Dmitry Baryshkov (2):
      usb: typec: ucsi: glink: fix off-by-one in connector_status
      usb: typec: ucsi: glink: be more precise on orientation-aware ports

 drivers/usb/typec/ucsi/ucsi_glink.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
base-commit: 0a2598971f04649933bd38f5db241b3bf23c04ec
change-id: 20241106-ucsi-glue-fixes-a20e2b2a0e3a

Best regards,
-- 
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


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

* [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status
  2024-11-09  0:04 [PATCH v2 0/2] usb: typec: ucsi: glink: fix and improve orientation handling Dmitry Baryshkov
@ 2024-11-09  0:04 ` Dmitry Baryshkov
  2024-11-11  9:09   ` Heikki Krogerus
  2024-11-09  0:04 ` [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports Dmitry Baryshkov
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Baryshkov @ 2024-11-09  0:04 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Heikki Krogerus, linux-usb, linux-kernel, linux-arm-msm,
	Abel Vesa, Johan Hovold, stable, Neil Armstrong

UCSI connector's indices start from 1 up to 3, PMIC_GLINK_MAX_PORTS.
Correct the condition in the pmic_glink_ucsi_connector_status()
callback, fixing Type-C orientation reporting for the third USB-C
connector.

Fixes: 76716fd5bf09 ("usb: typec: ucsi: glink: move GPIO reading into connector_status callback")
Cc: stable@vger.kernel.org
Reported-by: Abel Vesa <abel.vesa@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index 3e4d88ab338e50d4265df15fc960907c36675282..2e12758000a7d2d62f6e0b273cb29eafa631122c 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -185,7 +185,7 @@ static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)
 	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
 	int orientation;
 
-	if (con->num >= PMIC_GLINK_MAX_PORTS ||
+	if (con->num > PMIC_GLINK_MAX_PORTS ||
 	    !ucsi->port_orientation[con->num - 1])
 		return;
 

-- 
2.39.5


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

* [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports
  2024-11-09  0:04 [PATCH v2 0/2] usb: typec: ucsi: glink: fix and improve orientation handling Dmitry Baryshkov
  2024-11-09  0:04 ` [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status Dmitry Baryshkov
@ 2024-11-09  0:04 ` Dmitry Baryshkov
  2024-11-11  9:10   ` Heikki Krogerus
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Baryshkov @ 2024-11-09  0:04 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Heikki Krogerus, linux-usb, linux-kernel, linux-arm-msm,
	Abel Vesa, Johan Hovold, Neil Armstrong

Instead of checking if any of the USB-C ports have orientation GPIO and
thus is orientation-aware, check for the GPIO for the port being
registered. There are no boards that are affected by this change at this
moment, so the patch is not marked as a fix, but it might affect other
boards in future.

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/usb/typec/ucsi/ucsi_glink.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index 2e12758000a7d2d62f6e0b273cb29eafa631122c..90948cd6d2972402465a2adaba3e1ed055cf0cfa 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -172,12 +172,12 @@ static int pmic_glink_ucsi_async_control(struct ucsi *__ucsi, u64 command)
 static void pmic_glink_ucsi_update_connector(struct ucsi_connector *con)
 {
 	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
-	int i;
 
-	for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) {
-		if (ucsi->port_orientation[i])
-			con->typec_cap.orientation_aware = true;
-	}
+	if (con->num > PMIC_GLINK_MAX_PORTS ||
+	    !ucsi->port_orientation[con->num - 1])
+		return;
+
+	con->typec_cap.orientation_aware = true;
 }
 
 static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)

-- 
2.39.5


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

* Re: [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status
  2024-11-09  0:04 ` [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status Dmitry Baryshkov
@ 2024-11-11  9:09   ` Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2024-11-11  9:09 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Greg Kroah-Hartman, Heikki Krogerus, linux-usb, linux-kernel,
	linux-arm-msm, Abel Vesa, Johan Hovold, stable, Neil Armstrong

On Sat, Nov 09, 2024 at 02:04:14AM +0200, Dmitry Baryshkov wrote:
> UCSI connector's indices start from 1 up to 3, PMIC_GLINK_MAX_PORTS.
> Correct the condition in the pmic_glink_ucsi_connector_status()
> callback, fixing Type-C orientation reporting for the third USB-C
> connector.
> 
> Fixes: 76716fd5bf09 ("usb: typec: ucsi: glink: move GPIO reading into connector_status callback")
> Cc: stable@vger.kernel.org
> Reported-by: Abel Vesa <abel.vesa@linaro.org>
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
> Tested-by: Johan Hovold <johan+linaro@kernel.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

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

> ---
>  drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index 3e4d88ab338e50d4265df15fc960907c36675282..2e12758000a7d2d62f6e0b273cb29eafa631122c 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -185,7 +185,7 @@ static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)
>  	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
>  	int orientation;
>  
> -	if (con->num >= PMIC_GLINK_MAX_PORTS ||
> +	if (con->num > PMIC_GLINK_MAX_PORTS ||
>  	    !ucsi->port_orientation[con->num - 1])
>  		return;
>  
> 
> -- 
> 2.39.5

-- 
heikki

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

* Re: [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports
  2024-11-09  0:04 ` [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports Dmitry Baryshkov
@ 2024-11-11  9:10   ` Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2024-11-11  9:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Greg Kroah-Hartman, Heikki Krogerus, linux-usb, linux-kernel,
	linux-arm-msm, Abel Vesa, Johan Hovold, Neil Armstrong

On Sat, Nov 09, 2024 at 02:04:15AM +0200, Dmitry Baryshkov wrote:
> Instead of checking if any of the USB-C ports have orientation GPIO and
> thus is orientation-aware, check for the GPIO for the port being
> registered. There are no boards that are affected by this change at this
> moment, so the patch is not marked as a fix, but it might affect other
> boards in future.
> 
> Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
> Tested-by: Johan Hovold <johan+linaro@kernel.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

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

> ---
>  drivers/usb/typec/ucsi/ucsi_glink.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index 2e12758000a7d2d62f6e0b273cb29eafa631122c..90948cd6d2972402465a2adaba3e1ed055cf0cfa 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -172,12 +172,12 @@ static int pmic_glink_ucsi_async_control(struct ucsi *__ucsi, u64 command)
>  static void pmic_glink_ucsi_update_connector(struct ucsi_connector *con)
>  {
>  	struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi);
> -	int i;
>  
> -	for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) {
> -		if (ucsi->port_orientation[i])
> -			con->typec_cap.orientation_aware = true;
> -	}
> +	if (con->num > PMIC_GLINK_MAX_PORTS ||
> +	    !ucsi->port_orientation[con->num - 1])
> +		return;
> +
> +	con->typec_cap.orientation_aware = true;
>  }
>  
>  static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con)
> 
> -- 
> 2.39.5

-- 
heikki

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

end of thread, other threads:[~2024-11-11  9:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-09  0:04 [PATCH v2 0/2] usb: typec: ucsi: glink: fix and improve orientation handling Dmitry Baryshkov
2024-11-09  0:04 ` [PATCH v2 1/2] usb: typec: ucsi: glink: fix off-by-one in connector_status Dmitry Baryshkov
2024-11-11  9:09   ` Heikki Krogerus
2024-11-09  0:04 ` [PATCH v2 2/2] usb: typec: ucsi: glink: be more precise on orientation-aware ports Dmitry Baryshkov
2024-11-11  9:10   ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).