All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] extcon: ptn5150: Use defines for registers
@ 2020-09-09 15:01 ` Krzysztof Kozlowski
  2020-09-09 15:01   ` [PATCH 2/2] extcon: ptn5150: Do not print error during probe if nothing is attached Krzysztof Kozlowski
  2020-09-11  3:14   ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Chanwoo Choi
  0 siblings, 2 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-09 15:01 UTC (permalink / raw)
  To: Krzysztof Kozlowski, MyungJoo Ham, Chanwoo Choi, Vijai Kumar K,
	linux-kernel

The register addresses are not continuous, so use simple defines for
them.  This also makes it easier to find the address for register.

No functional change.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/extcon/extcon-ptn5150.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
index dda5b3a3a908..1b68f56d8372 100644
--- a/drivers/extcon/extcon-ptn5150.c
+++ b/drivers/extcon/extcon-ptn5150.c
@@ -19,18 +19,16 @@
 #include <linux/gpio/consumer.h>
 
 /* PTN5150 registers */
-enum ptn5150_reg {
-	PTN5150_REG_DEVICE_ID = 0x01,
-	PTN5150_REG_CONTROL,
-	PTN5150_REG_INT_STATUS,
-	PTN5150_REG_CC_STATUS,
-	PTN5150_REG_CON_DET = 0x09,
-	PTN5150_REG_VCONN_STATUS,
-	PTN5150_REG_RESET,
-	PTN5150_REG_INT_MASK = 0x18,
-	PTN5150_REG_INT_REG_STATUS,
-	PTN5150_REG_END,
-};
+#define PTN5150_REG_DEVICE_ID			0x01
+#define PTN5150_REG_CONTROL			0x02
+#define PTN5150_REG_INT_STATUS			0x03
+#define PTN5150_REG_CC_STATUS			0x04
+#define PTN5150_REG_CON_DET			0x09
+#define PTN5150_REG_VCONN_STATUS		0x0a
+#define PTN5150_REG_RESET			0x0b
+#define PTN5150_REG_INT_MASK			0x18
+#define PTN5150_REG_INT_REG_STATUS		0x19
+#define PTN5150_REG_END				PTN5150_REG_INT_REG_STATUS
 
 #define PTN5150_DFP_ATTACHED			0x1
 #define PTN5150_UFP_ATTACHED			0x2
-- 
2.17.1


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

* [PATCH 2/2] extcon: ptn5150: Do not print error during probe if nothing is attached
  2020-09-09 15:01 ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Krzysztof Kozlowski
@ 2020-09-09 15:01   ` Krzysztof Kozlowski
  2020-09-11  3:14   ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Chanwoo Choi
  1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-09 15:01 UTC (permalink / raw)
  To: Krzysztof Kozlowski, MyungJoo Ham, Chanwoo Choi, Vijai Kumar K,
	linux-kernel

The commit af71b7e384cd ("extcon: ptn5150: Check current USB mode when
probing") reused code for checking CC status register in the probe path
to determine what is initially connected.  However if nothing is
connected, the CC status register will have 0x0 value and print an error
message:

    ptn5150 1-003d: Unknown Port status : 0

This is not an error.  Also any other unknown port status values are not
really errors but unhandled cases.

Fixes: af71b7e384cd ("extcon: ptn5150: Check current USB mode when probing")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/extcon/extcon-ptn5150.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
index 1b68f56d8372..5b9a3cf8df26 100644
--- a/drivers/extcon/extcon-ptn5150.c
+++ b/drivers/extcon/extcon-ptn5150.c
@@ -97,7 +97,6 @@ static void ptn5150_check_state(struct ptn5150_info *info)
 		extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true);
 		break;
 	default:
-		dev_err(info->dev, "Unknown Port status : %x\n", port_status);
 		break;
 	}
 }
-- 
2.17.1


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

* Re: [PATCH 1/2] extcon: ptn5150: Use defines for registers
  2020-09-09 15:01 ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Krzysztof Kozlowski
  2020-09-09 15:01   ` [PATCH 2/2] extcon: ptn5150: Do not print error during probe if nothing is attached Krzysztof Kozlowski
@ 2020-09-11  3:14   ` Chanwoo Choi
  2020-09-11  5:38     ` Krzysztof Kozlowski
  1 sibling, 1 reply; 6+ messages in thread
From: Chanwoo Choi @ 2020-09-11  3:14 UTC (permalink / raw)
  To: Krzysztof Kozlowski, MyungJoo Ham, Vijai Kumar K, linux-kernel

On 9/10/20 12:01 AM, Krzysztof Kozlowski wrote:
> The register addresses are not continuous, so use simple defines for
> them.  This also makes it easier to find the address for register.
> 
> No functional change.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/extcon/extcon-ptn5150.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> index dda5b3a3a908..1b68f56d8372 100644
> --- a/drivers/extcon/extcon-ptn5150.c
> +++ b/drivers/extcon/extcon-ptn5150.c
> @@ -19,18 +19,16 @@
>  #include <linux/gpio/consumer.h>
>  
>  /* PTN5150 registers */
> -enum ptn5150_reg {
> -	PTN5150_REG_DEVICE_ID = 0x01,
> -	PTN5150_REG_CONTROL,
> -	PTN5150_REG_INT_STATUS,
> -	PTN5150_REG_CC_STATUS,
> -	PTN5150_REG_CON_DET = 0x09,
> -	PTN5150_REG_VCONN_STATUS,
> -	PTN5150_REG_RESET,
> -	PTN5150_REG_INT_MASK = 0x18,
> -	PTN5150_REG_INT_REG_STATUS,
> -	PTN5150_REG_END,
> -};
> +#define PTN5150_REG_DEVICE_ID			0x01
> +#define PTN5150_REG_CONTROL			0x02
> +#define PTN5150_REG_INT_STATUS			0x03
> +#define PTN5150_REG_CC_STATUS			0x04
> +#define PTN5150_REG_CON_DET			0x09
> +#define PTN5150_REG_VCONN_STATUS		0x0a
> +#define PTN5150_REG_RESET			0x0b
> +#define PTN5150_REG_INT_MASK			0x18
> +#define PTN5150_REG_INT_REG_STATUS		0x19
> +#define PTN5150_REG_END				PTN5150_REG_INT_REG_STATUS

PTN5150_REG_END should be (PTN5150_REG_INT_REG_STATUS + 1)
for regmap operation of PTN5150_REG_INT_REG_STATUS.

>  
>  #define PTN5150_DFP_ATTACHED			0x1
>  #define PTN5150_UFP_ATTACHED			0x2
> 
-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH 1/2] extcon: ptn5150: Use defines for registers
  2020-09-11  3:14   ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Chanwoo Choi
@ 2020-09-11  5:38     ` Krzysztof Kozlowski
  2020-09-11  8:03       ` Chanwoo Choi
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-11  5:38 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: MyungJoo Ham, Vijai Kumar K, linux-kernel

On Fri, Sep 11, 2020 at 12:14:19PM +0900, Chanwoo Choi wrote:
> On 9/10/20 12:01 AM, Krzysztof Kozlowski wrote:
> > The register addresses are not continuous, so use simple defines for
> > them.  This also makes it easier to find the address for register.
> > 
> > No functional change.
> > 
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > ---
> >  drivers/extcon/extcon-ptn5150.c | 22 ++++++++++------------
> >  1 file changed, 10 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> > index dda5b3a3a908..1b68f56d8372 100644
> > --- a/drivers/extcon/extcon-ptn5150.c
> > +++ b/drivers/extcon/extcon-ptn5150.c
> > @@ -19,18 +19,16 @@
> >  #include <linux/gpio/consumer.h>
> >  
> >  /* PTN5150 registers */
> > -enum ptn5150_reg {
> > -	PTN5150_REG_DEVICE_ID = 0x01,
> > -	PTN5150_REG_CONTROL,
> > -	PTN5150_REG_INT_STATUS,
> > -	PTN5150_REG_CC_STATUS,
> > -	PTN5150_REG_CON_DET = 0x09,
> > -	PTN5150_REG_VCONN_STATUS,
> > -	PTN5150_REG_RESET,
> > -	PTN5150_REG_INT_MASK = 0x18,
> > -	PTN5150_REG_INT_REG_STATUS,
> > -	PTN5150_REG_END,
> > -};
> > +#define PTN5150_REG_DEVICE_ID			0x01
> > +#define PTN5150_REG_CONTROL			0x02
> > +#define PTN5150_REG_INT_STATUS			0x03
> > +#define PTN5150_REG_CC_STATUS			0x04
> > +#define PTN5150_REG_CON_DET			0x09
> > +#define PTN5150_REG_VCONN_STATUS		0x0a
> > +#define PTN5150_REG_RESET			0x0b
> > +#define PTN5150_REG_INT_MASK			0x18
> > +#define PTN5150_REG_INT_REG_STATUS		0x19
> > +#define PTN5150_REG_END				PTN5150_REG_INT_REG_STATUS
> 
> PTN5150_REG_END should be (PTN5150_REG_INT_REG_STATUS + 1)
> for regmap operation of PTN5150_REG_INT_REG_STATUS.

Why? This goes to regmap's max_register which is the last register
allowed to read:

  drivers/base/regmap/regmap-debugfs.c:   for (i = 0; i <= map->max_register; i += map->reg_stride) {
  drivers/base/regmap/regmap.c:   if (map->max_register && reg > map->max_register)

  regmap_get_max_register() - Report the max register value

Best regards,
Krzysztof


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

* Re: [PATCH 1/2] extcon: ptn5150: Use defines for registers
  2020-09-11  8:03       ` Chanwoo Choi
@ 2020-09-11  7:54         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2020-09-11  7:54 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: MyungJoo Ham, Vijai Kumar K, linux-kernel

On Fri, Sep 11, 2020 at 05:03:02PM +0900, Chanwoo Choi wrote:
> On 9/11/20 2:38 PM, Krzysztof Kozlowski wrote:
> > On Fri, Sep 11, 2020 at 12:14:19PM +0900, Chanwoo Choi wrote:
> >> On 9/10/20 12:01 AM, Krzysztof Kozlowski wrote:
> >>> The register addresses are not continuous, so use simple defines for
> >>> them.  This also makes it easier to find the address for register.
> >>>
> >>> No functional change.
> >>>
> >>> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> >>> ---
> >>>  drivers/extcon/extcon-ptn5150.c | 22 ++++++++++------------
> >>>  1 file changed, 10 insertions(+), 12 deletions(-)
> >>>
> >>> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> >>> index dda5b3a3a908..1b68f56d8372 100644
> >>> --- a/drivers/extcon/extcon-ptn5150.c
> >>> +++ b/drivers/extcon/extcon-ptn5150.c
> >>> @@ -19,18 +19,16 @@
> >>>  #include <linux/gpio/consumer.h>
> >>>  
> >>>  /* PTN5150 registers */
> >>> -enum ptn5150_reg {
> >>> -	PTN5150_REG_DEVICE_ID = 0x01,
> >>> -	PTN5150_REG_CONTROL,
> >>> -	PTN5150_REG_INT_STATUS,
> >>> -	PTN5150_REG_CC_STATUS,
> >>> -	PTN5150_REG_CON_DET = 0x09,
> >>> -	PTN5150_REG_VCONN_STATUS,
> >>> -	PTN5150_REG_RESET,
> >>> -	PTN5150_REG_INT_MASK = 0x18,
> >>> -	PTN5150_REG_INT_REG_STATUS,
> >>> -	PTN5150_REG_END,
> >>> -};
> >>> +#define PTN5150_REG_DEVICE_ID			0x01
> >>> +#define PTN5150_REG_CONTROL			0x02
> >>> +#define PTN5150_REG_INT_STATUS			0x03
> >>> +#define PTN5150_REG_CC_STATUS			0x04
> >>> +#define PTN5150_REG_CON_DET			0x09
> >>> +#define PTN5150_REG_VCONN_STATUS		0x0a
> >>> +#define PTN5150_REG_RESET			0x0b
> >>> +#define PTN5150_REG_INT_MASK			0x18
> >>> +#define PTN5150_REG_INT_REG_STATUS		0x19
> >>> +#define PTN5150_REG_END				PTN5150_REG_INT_REG_STATUS
> >>
> >> PTN5150_REG_END should be (PTN5150_REG_INT_REG_STATUS + 1)
> >> for regmap operation of PTN5150_REG_INT_REG_STATUS.
> > 
> > Why? This goes to regmap's max_register which is the last register
> > allowed to read:
> > 
> >   drivers/base/regmap/regmap-debugfs.c:   for (i = 0; i <= map->max_register; i += map->reg_stride) {
> >   drivers/base/regmap/regmap.c:   if (map->max_register && reg > map->max_register)
> 
> It is my mismake. You're right.
> Applied them. Thanks.

Great, thank you!

Best regards,
Krzysztof


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

* Re: [PATCH 1/2] extcon: ptn5150: Use defines for registers
  2020-09-11  5:38     ` Krzysztof Kozlowski
@ 2020-09-11  8:03       ` Chanwoo Choi
  2020-09-11  7:54         ` Krzysztof Kozlowski
  0 siblings, 1 reply; 6+ messages in thread
From: Chanwoo Choi @ 2020-09-11  8:03 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: MyungJoo Ham, Vijai Kumar K, linux-kernel

On 9/11/20 2:38 PM, Krzysztof Kozlowski wrote:
> On Fri, Sep 11, 2020 at 12:14:19PM +0900, Chanwoo Choi wrote:
>> On 9/10/20 12:01 AM, Krzysztof Kozlowski wrote:
>>> The register addresses are not continuous, so use simple defines for
>>> them.  This also makes it easier to find the address for register.
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
>>> ---
>>>  drivers/extcon/extcon-ptn5150.c | 22 ++++++++++------------
>>>  1 file changed, 10 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
>>> index dda5b3a3a908..1b68f56d8372 100644
>>> --- a/drivers/extcon/extcon-ptn5150.c
>>> +++ b/drivers/extcon/extcon-ptn5150.c
>>> @@ -19,18 +19,16 @@
>>>  #include <linux/gpio/consumer.h>
>>>  
>>>  /* PTN5150 registers */
>>> -enum ptn5150_reg {
>>> -	PTN5150_REG_DEVICE_ID = 0x01,
>>> -	PTN5150_REG_CONTROL,
>>> -	PTN5150_REG_INT_STATUS,
>>> -	PTN5150_REG_CC_STATUS,
>>> -	PTN5150_REG_CON_DET = 0x09,
>>> -	PTN5150_REG_VCONN_STATUS,
>>> -	PTN5150_REG_RESET,
>>> -	PTN5150_REG_INT_MASK = 0x18,
>>> -	PTN5150_REG_INT_REG_STATUS,
>>> -	PTN5150_REG_END,
>>> -};
>>> +#define PTN5150_REG_DEVICE_ID			0x01
>>> +#define PTN5150_REG_CONTROL			0x02
>>> +#define PTN5150_REG_INT_STATUS			0x03
>>> +#define PTN5150_REG_CC_STATUS			0x04
>>> +#define PTN5150_REG_CON_DET			0x09
>>> +#define PTN5150_REG_VCONN_STATUS		0x0a
>>> +#define PTN5150_REG_RESET			0x0b
>>> +#define PTN5150_REG_INT_MASK			0x18
>>> +#define PTN5150_REG_INT_REG_STATUS		0x19
>>> +#define PTN5150_REG_END				PTN5150_REG_INT_REG_STATUS
>>
>> PTN5150_REG_END should be (PTN5150_REG_INT_REG_STATUS + 1)
>> for regmap operation of PTN5150_REG_INT_REG_STATUS.
> 
> Why? This goes to regmap's max_register which is the last register
> allowed to read:
> 
>   drivers/base/regmap/regmap-debugfs.c:   for (i = 0; i <= map->max_register; i += map->reg_stride) {
>   drivers/base/regmap/regmap.c:   if (map->max_register && reg > map->max_register)

It is my mismake. You're right.
Applied them. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

end of thread, other threads:[~2020-09-11  7:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200909172007epcas1p2fe01380c62ca112a19283f2dc63e75f9@epcas1p2.samsung.com>
2020-09-09 15:01 ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Krzysztof Kozlowski
2020-09-09 15:01   ` [PATCH 2/2] extcon: ptn5150: Do not print error during probe if nothing is attached Krzysztof Kozlowski
2020-09-11  3:14   ` [PATCH 1/2] extcon: ptn5150: Use defines for registers Chanwoo Choi
2020-09-11  5:38     ` Krzysztof Kozlowski
2020-09-11  8:03       ` Chanwoo Choi
2020-09-11  7:54         ` Krzysztof Kozlowski

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.