kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: cdnsp: Fix the IMAN_IE_SET and IMAN_IE_CLEAR macro.
@ 2021-06-22 19:37 Christophe JAILLET
  2021-06-25  4:23 ` Pawel Laszczak
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2021-06-22 19:37 UTC (permalink / raw)
  To: pawell, gregkh, peter.chen
  Cc: linux-usb, linux-kernel, kernel-janitors, Christophe JAILLET

IMAN_IE is BIT(1), so these macro are respectively equivalent to BIT(1)
and 0, whatever the value of 'p'.

The purpose was to set and reset a single bit in 'p'.
Fix these macros to do that correctly.

Fixes: e93e58d27402 ("usb: cdnsp: Device side header file for CDNSP driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative. It is not tested.
Please, review with care.

Actually, the usage of these macros is:
   readl(somewhere)
   set or reset the IMAN_IE bit
   write(somewhere)
So it is likely that we want to preserve the other bits read. Otherwise,
the code could be much simpler.
---
 drivers/usb/cdns3/cdnsp-gadget.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
index 783ca8ffde00..f740fa6089d8 100644
--- a/drivers/usb/cdns3/cdnsp-gadget.h
+++ b/drivers/usb/cdns3/cdnsp-gadget.h
@@ -383,8 +383,8 @@ struct cdnsp_intr_reg {
 #define IMAN_IE			BIT(1)
 #define IMAN_IP			BIT(0)
 /* bits 2:31 need to be preserved */
-#define IMAN_IE_SET(p)		(((p) & IMAN_IE) | 0x2)
-#define IMAN_IE_CLEAR(p)	(((p) & IMAN_IE) & ~(0x2))
+#define IMAN_IE_SET(p)		((p) | IMAN_IE)
+#define IMAN_IE_CLEAR(p)	((p) & ~IMAN_IE)
 
 /* IMOD - Interrupter Moderation Register - irq_control bitmasks. */
 /*
-- 
2.30.2


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

* RE: [PATCH] usb: cdnsp: Fix the IMAN_IE_SET and IMAN_IE_CLEAR macro.
  2021-06-22 19:37 [PATCH] usb: cdnsp: Fix the IMAN_IE_SET and IMAN_IE_CLEAR macro Christophe JAILLET
@ 2021-06-25  4:23 ` Pawel Laszczak
  2021-06-25  4:39   ` Pawel Laszczak
  0 siblings, 1 reply; 3+ messages in thread
From: Pawel Laszczak @ 2021-06-25  4:23 UTC (permalink / raw)
  To: Christophe JAILLET, gregkh, peter.chen
  Cc: linux-usb, linux-kernel, kernel-janitors

>
>IMAN_IE is BIT(1), so these macro are respectively equivalent to BIT(1)
>and 0, whatever the value of 'p'.
>
>The purpose was to set and reset a single bit in 'p'.
>Fix these macros to do that correctly.
>
>Fixes: e93e58d27402 ("usb: cdnsp: Device side header file for CDNSP driver")
>Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Pawel Laszczak <pawell@cadence.com>

Currently the bit 1(RW) and bit 0 (W1toClr) are implemented. 
All other bits are not used and are reserved for future RW implementations.
I was a bit afraid about bit 0 which is "write 1 to clear" but I haven't found any
issue with this patch during testing so we can simplify these macros 

Thanks Christophe

>---
>This patch is speculative. It is not tested.
>Please, review with care.
>
>Actually, the usage of these macros is:
>   readl(somewhere)
>   set or reset the IMAN_IE bit
>   write(somewhere)
>So it is likely that we want to preserve the other bits read. Otherwise,
>the code could be much simpler.
>---
> drivers/usb/cdns3/cdnsp-gadget.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
>index 783ca8ffde00..f740fa6089d8 100644
>--- a/drivers/usb/cdns3/cdnsp-gadget.h
>+++ b/drivers/usb/cdns3/cdnsp-gadget.h
>@@ -383,8 +383,8 @@ struct cdnsp_intr_reg {
> #define IMAN_IE			BIT(1)
> #define IMAN_IP			BIT(0)
> /* bits 2:31 need to be preserved */
>-#define IMAN_IE_SET(p)		(((p) & IMAN_IE) | 0x2)
>-#define IMAN_IE_CLEAR(p)	(((p) & IMAN_IE) & ~(0x2))
>+#define IMAN_IE_SET(p)		((p) | IMAN_IE)
>+#define IMAN_IE_CLEAR(p)	((p) & ~IMAN_IE)
>
> /* IMOD - Interrupter Moderation Register - irq_control bitmasks. */
> /*
>--
>2.30.2

--

Regards,
Pawel Laszczak

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

* RE: [PATCH] usb: cdnsp: Fix the IMAN_IE_SET and IMAN_IE_CLEAR macro.
  2021-06-25  4:23 ` Pawel Laszczak
@ 2021-06-25  4:39   ` Pawel Laszczak
  0 siblings, 0 replies; 3+ messages in thread
From: Pawel Laszczak @ 2021-06-25  4:39 UTC (permalink / raw)
  To: Christophe JAILLET, gregkh, Peter Chen
  Cc: linux-usb, linux-kernel, kernel-janitors

Corrected Peter Chen address - should be peter.chen@kernel.org

>>IMAN_IE is BIT(1), so these macro are respectively equivalent to BIT(1)
>>and 0, whatever the value of 'p'.
>>
>>The purpose was to set and reset a single bit in 'p'.
>>Fix these macros to do that correctly.
>>
>>Fixes: e93e58d27402 ("usb: cdnsp: Device side header file for CDNSP driver")
>>Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
>Acked-by: Pawel Laszczak <pawell@cadence.com>
>
>Currently the bit 1(RW) and bit 0 (W1toClr) are implemented.
>All other bits are not used and are reserved for future RW implementations.
>I was a bit afraid about bit 0 which is "write 1 to clear" but I haven't found any
>issue with this patch during testing so we can simplify these macros
>
>Thanks Christophe
>
>>---
>>This patch is speculative. It is not tested.
>>Please, review with care.
>>
>>Actually, the usage of these macros is:
>>   readl(somewhere)
>>   set or reset the IMAN_IE bit
>>   write(somewhere)
>>So it is likely that we want to preserve the other bits read. Otherwise,
>>the code could be much simpler.
>>---
>> drivers/usb/cdns3/cdnsp-gadget.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>>diff --git a/drivers/usb/cdns3/cdnsp-gadget.h b/drivers/usb/cdns3/cdnsp-gadget.h
>>index 783ca8ffde00..f740fa6089d8 100644
>>--- a/drivers/usb/cdns3/cdnsp-gadget.h
>>+++ b/drivers/usb/cdns3/cdnsp-gadget.h
>>@@ -383,8 +383,8 @@ struct cdnsp_intr_reg {
>> #define IMAN_IE			BIT(1)
>> #define IMAN_IP			BIT(0)
>> /* bits 2:31 need to be preserved */
>>-#define IMAN_IE_SET(p)		(((p) & IMAN_IE) | 0x2)
>>-#define IMAN_IE_CLEAR(p)	(((p) & IMAN_IE) & ~(0x2))
>>+#define IMAN_IE_SET(p)		((p) | IMAN_IE)
>>+#define IMAN_IE_CLEAR(p)	((p) & ~IMAN_IE)
>>
>> /* IMOD - Interrupter Moderation Register - irq_control bitmasks. */
>> /*
>>--
>>2.30.2
>
>--
>
>Regards,
>Pawel Laszczak

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

end of thread, other threads:[~2021-06-25  4:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 19:37 [PATCH] usb: cdnsp: Fix the IMAN_IE_SET and IMAN_IE_CLEAR macro Christophe JAILLET
2021-06-25  4:23 ` Pawel Laszczak
2021-06-25  4:39   ` Pawel Laszczak

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