linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs
@ 2019-06-28  8:12 Nikolaus Voss
  2019-06-28  8:18 ` Greg Kroah-Hartman
  2019-06-28  8:34 ` Heikki Krogerus
  0 siblings, 2 replies; 11+ messages in thread
From: Nikolaus Voss @ 2019-06-28  8:12 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Nikolaus Voss, linux-usb, linux-kernel, nv

1. Portinfo bit field is 3 bits wide, not 2 bits. This led to
   a wrong driver configuration for some tps6598x configurations.

2. Writing 4CC commands with tps6598x_write_4cc() already has
   a pointer arg, don't reference it when using as arg to
   tps6598x_block_write(). Correcting this enforces the constness
   of the pointer to propagate to tps6598x_block_write(), so add
   the const qualifier there to avoid the warning.

Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
---
 drivers/usb/typec/tps6598x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index c674abe3cf99..a38d1409f15b 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -41,7 +41,7 @@
 #define TPS_STATUS_VCONN(s)		(!!((s) & BIT(7)))
 
 /* TPS_REG_SYSTEM_CONF bits */
-#define TPS_SYSCONF_PORTINFO(c)		((c) & 3)
+#define TPS_SYSCONF_PORTINFO(c)		((c) & 7)
 
 enum {
 	TPS_PORTINFO_SINK,
@@ -127,7 +127,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
 }
 
 static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
-				void *val, size_t len)
+				const void *val, size_t len)
 {
 	u8 data[TPS_MAX_LEN + 1];
 
@@ -173,7 +173,7 @@ static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
 static inline int
 tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
 {
-	return tps6598x_block_write(tps, reg, &val, sizeof(u32));
+	return tps6598x_block_write(tps, reg, val, 4);
 }
 
 static int tps6598x_read_partner_identity(struct tps6598x *tps)
-- 
2.17.1


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

* Re: [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs
  2019-06-28  8:12 [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs Nikolaus Voss
@ 2019-06-28  8:18 ` Greg Kroah-Hartman
  2019-06-28  8:34 ` Heikki Krogerus
  1 sibling, 0 replies; 11+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-28  8:18 UTC (permalink / raw)
  To: Nikolaus Voss; +Cc: Heikki Krogerus, linux-usb, linux-kernel, nv

On Fri, Jun 28, 2019 at 10:12:35AM +0200, Nikolaus Voss wrote:
> 1. Portinfo bit field is 3 bits wide, not 2 bits. This led to
>    a wrong driver configuration for some tps6598x configurations.
> 
> 2. Writing 4CC commands with tps6598x_write_4cc() already has
>    a pointer arg, don't reference it when using as arg to
>    tps6598x_block_write(). Correcting this enforces the constness
>    of the pointer to propagate to tps6598x_block_write(), so add
>    the const qualifier there to avoid the warning.

Please split this up into two seprate patches as these are doing two
different things.

thanks,

greg k-h

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

* Re: [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs
  2019-06-28  8:12 [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs Nikolaus Voss
  2019-06-28  8:18 ` Greg Kroah-Hartman
@ 2019-06-28  8:34 ` Heikki Krogerus
  2019-06-28  9:01   ` [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width Nikolaus Voss
  2019-06-28  9:01   ` [PATCH 2/2] drivers/usb/typec/tps6598x.c: fix 4CC cmd write Nikolaus Voss
  1 sibling, 2 replies; 11+ messages in thread
From: Heikki Krogerus @ 2019-06-28  8:34 UTC (permalink / raw)
  To: Nikolaus Voss; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, nv

On Fri, Jun 28, 2019 at 10:12:35AM +0200, Nikolaus Voss wrote:
> 1. Portinfo bit field is 3 bits wide, not 2 bits. This led to
>    a wrong driver configuration for some tps6598x configurations.
> 
> 2. Writing 4CC commands with tps6598x_write_4cc() already has
>    a pointer arg, don't reference it when using as arg to
>    tps6598x_block_write(). Correcting this enforces the constness
>    of the pointer to propagate to tps6598x_block_write(), so add
>    the const qualifier there to avoid the warning.

Like Greg said, if please supply separate patches. Also, if these are
fixes, then please mark them as such with appropriate tags:

        Fixes: ....
        Cc: stable@...


> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
> ---
>  drivers/usb/typec/tps6598x.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
> index c674abe3cf99..a38d1409f15b 100644
> --- a/drivers/usb/typec/tps6598x.c
> +++ b/drivers/usb/typec/tps6598x.c
> @@ -41,7 +41,7 @@
>  #define TPS_STATUS_VCONN(s)		(!!((s) & BIT(7)))
>  
>  /* TPS_REG_SYSTEM_CONF bits */
> -#define TPS_SYSCONF_PORTINFO(c)		((c) & 3)
> +#define TPS_SYSCONF_PORTINFO(c)		((c) & 7)
>  
>  enum {
>  	TPS_PORTINFO_SINK,
> @@ -127,7 +127,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
>  }
>  
>  static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
> -				void *val, size_t len)
> +				const void *val, size_t len)
>  {
>  	u8 data[TPS_MAX_LEN + 1];
>  
> @@ -173,7 +173,7 @@ static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
>  static inline int
>  tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
>  {
> -	return tps6598x_block_write(tps, reg, &val, sizeof(u32));
> +	return tps6598x_block_write(tps, reg, val, 4);
>  }
>  
>  static int tps6598x_read_partner_identity(struct tps6598x *tps)
> -- 
> 2.17.1

thanks,

-- 
heikki

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

* [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width
  2019-06-28  8:34 ` Heikki Krogerus
@ 2019-06-28  9:01   ` Nikolaus Voss
  2019-06-28  9:58     ` Heikki Krogerus
  2019-06-28  9:01   ` [PATCH 2/2] drivers/usb/typec/tps6598x.c: fix 4CC cmd write Nikolaus Voss
  1 sibling, 1 reply; 11+ messages in thread
From: Nikolaus Voss @ 2019-06-28  9:01 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Nikolaus Voss, linux-usb, linux-kernel, nv

Portinfo bit field is 3 bits wide, not 2 bits. This led to
a wrong driver configuration for some tps6598x configurations.

Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
---
 drivers/usb/typec/tps6598x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index c674abe3cf99..a170c49c2542 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -41,7 +41,7 @@
 #define TPS_STATUS_VCONN(s)		(!!((s) & BIT(7)))
 
 /* TPS_REG_SYSTEM_CONF bits */
-#define TPS_SYSCONF_PORTINFO(c)		((c) & 3)
+#define TPS_SYSCONF_PORTINFO(c)		((c) & 7)
 
 enum {
 	TPS_PORTINFO_SINK,
-- 
2.17.1


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

* [PATCH 2/2] drivers/usb/typec/tps6598x.c: fix 4CC cmd write
  2019-06-28  8:34 ` Heikki Krogerus
  2019-06-28  9:01   ` [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width Nikolaus Voss
@ 2019-06-28  9:01   ` Nikolaus Voss
  2019-06-28  9:59     ` Heikki Krogerus
  1 sibling, 1 reply; 11+ messages in thread
From: Nikolaus Voss @ 2019-06-28  9:01 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Nikolaus Voss, linux-usb, linux-kernel, nv

Writing 4CC commands with tps6598x_write_4cc() already has
a pointer arg, don't reference it when using as arg to
tps6598x_block_write(). Correcting this enforces the constness
of the pointer to propagate to tps6598x_block_write(), so add
the const qualifier there to avoid the warning.

Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
---
 drivers/usb/typec/tps6598x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index a170c49c2542..a38d1409f15b 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -127,7 +127,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
 }
 
 static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
-				void *val, size_t len)
+				const void *val, size_t len)
 {
 	u8 data[TPS_MAX_LEN + 1];
 
@@ -173,7 +173,7 @@ static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
 static inline int
 tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
 {
-	return tps6598x_block_write(tps, reg, &val, sizeof(u32));
+	return tps6598x_block_write(tps, reg, val, 4);
 }
 
 static int tps6598x_read_partner_identity(struct tps6598x *tps)
-- 
2.17.1


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

* Re: [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width
  2019-06-28  9:01   ` [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width Nikolaus Voss
@ 2019-06-28  9:58     ` Heikki Krogerus
  2019-06-28 10:10       ` Nikolaus Voss
  0 siblings, 1 reply; 11+ messages in thread
From: Heikki Krogerus @ 2019-06-28  9:58 UTC (permalink / raw)
  To: Nikolaus Voss; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, nv

On Fri, Jun 28, 2019 at 11:01:08AM +0200, Nikolaus Voss wrote:
> Portinfo bit field is 3 bits wide, not 2 bits. This led to
> a wrong driver configuration for some tps6598x configurations.
> 
> Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>

Shouldn't this be applied to the stable trees as well?

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

> ---
>  drivers/usb/typec/tps6598x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
> index c674abe3cf99..a170c49c2542 100644
> --- a/drivers/usb/typec/tps6598x.c
> +++ b/drivers/usb/typec/tps6598x.c
> @@ -41,7 +41,7 @@
>  #define TPS_STATUS_VCONN(s)		(!!((s) & BIT(7)))
>  
>  /* TPS_REG_SYSTEM_CONF bits */
> -#define TPS_SYSCONF_PORTINFO(c)		((c) & 3)
> +#define TPS_SYSCONF_PORTINFO(c)		((c) & 7)
>  
>  enum {
>  	TPS_PORTINFO_SINK,
> -- 
> 2.17.1

thanks,

-- 
heikki

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

* Re: [PATCH 2/2] drivers/usb/typec/tps6598x.c: fix 4CC cmd write
  2019-06-28  9:01   ` [PATCH 2/2] drivers/usb/typec/tps6598x.c: fix 4CC cmd write Nikolaus Voss
@ 2019-06-28  9:59     ` Heikki Krogerus
  0 siblings, 0 replies; 11+ messages in thread
From: Heikki Krogerus @ 2019-06-28  9:59 UTC (permalink / raw)
  To: Nikolaus Voss; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, nv

On Fri, Jun 28, 2019 at 11:01:09AM +0200, Nikolaus Voss wrote:
> Writing 4CC commands with tps6598x_write_4cc() already has
> a pointer arg, don't reference it when using as arg to
> tps6598x_block_write(). Correcting this enforces the constness
> of the pointer to propagate to tps6598x_block_write(), so add
> the const qualifier there to avoid the warning.
> 
> Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>

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

> ---
>  drivers/usb/typec/tps6598x.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
> index a170c49c2542..a38d1409f15b 100644
> --- a/drivers/usb/typec/tps6598x.c
> +++ b/drivers/usb/typec/tps6598x.c
> @@ -127,7 +127,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
>  }
>  
>  static int tps6598x_block_write(struct tps6598x *tps, u8 reg,
> -				void *val, size_t len)
> +				const void *val, size_t len)
>  {
>  	u8 data[TPS_MAX_LEN + 1];
>  
> @@ -173,7 +173,7 @@ static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val)
>  static inline int
>  tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val)
>  {
> -	return tps6598x_block_write(tps, reg, &val, sizeof(u32));
> +	return tps6598x_block_write(tps, reg, val, 4);
>  }
>  
>  static int tps6598x_read_partner_identity(struct tps6598x *tps)
> -- 
> 2.17.1

thanks,

-- 
heikki

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

* Re: [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width
  2019-06-28  9:58     ` Heikki Krogerus
@ 2019-06-28 10:10       ` Nikolaus Voss
  2019-07-03 16:39         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Nikolaus Voss @ 2019-06-28 10:10 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On Fri, 28 Jun 2019, Heikki Krogerus wrote:
> On Fri, Jun 28, 2019 at 11:01:08AM +0200, Nikolaus Voss wrote:
>> Portinfo bit field is 3 bits wide, not 2 bits. This led to
>> a wrong driver configuration for some tps6598x configurations.
>>
>> Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
>> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
>
> Shouldn't this be applied to the stable trees as well?

Oh, yes, forgot that again... Greg, could you...?

Niko

[...]

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

* Re: [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width
  2019-06-28 10:10       ` Nikolaus Voss
@ 2019-07-03 16:39         ` Greg Kroah-Hartman
  2019-07-03 17:25           ` Nikolaus Voss
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-03 16:39 UTC (permalink / raw)
  To: Nikolaus Voss; +Cc: Heikki Krogerus, linux-usb, linux-kernel

On Fri, Jun 28, 2019 at 12:10:41PM +0200, Nikolaus Voss wrote:
> On Fri, 28 Jun 2019, Heikki Krogerus wrote:
> > On Fri, Jun 28, 2019 at 11:01:08AM +0200, Nikolaus Voss wrote:
> > > Portinfo bit field is 3 bits wide, not 2 bits. This led to
> > > a wrong driver configuration for some tps6598x configurations.
> > > 
> > > Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
> > > Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
> > 
> > Shouldn't this be applied to the stable trees as well?
> 
> Oh, yes, forgot that again... Greg, could you...?

It's not like I have anything else to do... :)


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

* Re: [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width
  2019-07-03 16:39         ` Greg Kroah-Hartman
@ 2019-07-03 17:25           ` Nikolaus Voss
  2019-07-03 17:37             ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Nikolaus Voss @ 2019-07-03 17:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Heikki Krogerus, linux-usb, linux-kernel

On Wed, 3 Jul 2019, Greg Kroah-Hartman wrote:
> On Fri, Jun 28, 2019 at 12:10:41PM +0200, Nikolaus Voss wrote:
>> On Fri, 28 Jun 2019, Heikki Krogerus wrote:
>>> On Fri, Jun 28, 2019 at 11:01:08AM +0200, Nikolaus Voss wrote:
>>>> Portinfo bit field is 3 bits wide, not 2 bits. This led to
>>>> a wrong driver configuration for some tps6598x configurations.
>>>>
>>>> Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
>>>> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
>>>
>>> Shouldn't this be applied to the stable trees as well?
>>
>> Oh, yes, forgot that again... Greg, could you...?
>
> It's not like I have anything else to do... :)

I know. Sorry. I'll repost if you want, just say ick or something then...

Nikolaus

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

* Re: [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width
  2019-07-03 17:25           ` Nikolaus Voss
@ 2019-07-03 17:37             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 11+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-03 17:37 UTC (permalink / raw)
  To: Nikolaus Voss; +Cc: Heikki Krogerus, linux-usb, linux-kernel

On Wed, Jul 03, 2019 at 07:25:53PM +0200, Nikolaus Voss wrote:
> On Wed, 3 Jul 2019, Greg Kroah-Hartman wrote:
> > On Fri, Jun 28, 2019 at 12:10:41PM +0200, Nikolaus Voss wrote:
> > > On Fri, 28 Jun 2019, Heikki Krogerus wrote:
> > > > On Fri, Jun 28, 2019 at 11:01:08AM +0200, Nikolaus Voss wrote:
> > > > > Portinfo bit field is 3 bits wide, not 2 bits. This led to
> > > > > a wrong driver configuration for some tps6598x configurations.
> > > > > 
> > > > > Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
> > > > > Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
> > > > 
> > > > Shouldn't this be applied to the stable trees as well?
> > > 
> > > Oh, yes, forgot that again... Greg, could you...?
> > 
> > It's not like I have anything else to do... :)
> 
> I know. Sorry. I'll repost if you want, just say ick or something then...

Already merged, no worries.

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

end of thread, other threads:[~2019-07-03 17:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-28  8:12 [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs Nikolaus Voss
2019-06-28  8:18 ` Greg Kroah-Hartman
2019-06-28  8:34 ` Heikki Krogerus
2019-06-28  9:01   ` [PATCH 1/2] drivers/usb/typec/tps6598x.c: fix portinfo width Nikolaus Voss
2019-06-28  9:58     ` Heikki Krogerus
2019-06-28 10:10       ` Nikolaus Voss
2019-07-03 16:39         ` Greg Kroah-Hartman
2019-07-03 17:25           ` Nikolaus Voss
2019-07-03 17:37             ` Greg Kroah-Hartman
2019-06-28  9:01   ` [PATCH 2/2] drivers/usb/typec/tps6598x.c: fix 4CC cmd write Nikolaus Voss
2019-06-28  9:59     ` 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).