Skip to contentSkip to conversation

usb: cdns3: improvement for usb-next

PATCH In review Peter Chen 2 participants 5 messages Jun 23, 2020

Subsystems (3)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

cover usb: cdns3: improvement for usb-next

Peter Chen (3):
usb: cdns3: ep0: delete the duplicate code
usb: cdns3: gadget: unsigned int is dereferenced as a wider unsigned
long
usb: cdns3: gadget: use unsigned int for 32-bit number

 drivers/usb/cdns3/ep0.c    | 2 +-
 drivers/usb/cdns3/gadget.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/3 usb: cdns3: ep0: delete the duplicate code

The value '0' is duplicated with USB_DIR_OUT

---
 drivers/usb/cdns3/ep0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/ep0.c +1 -1
index 5aa69980e7ff..a2b9af5a80cc 100644
@@ -610,7 +610,7 @@ static bool cdns3_check_new_setup(struct cdns3_device *priv_dev)
 {
 	u32 ep_sts_reg;
 
-	cdns3_select_ep(priv_dev, 0 | USB_DIR_OUT);
+	cdns3_select_ep(priv_dev, USB_DIR_OUT);
 	ep_sts_reg = readl(&priv_dev->regs->ep_sts);
 
 	return !!(ep_sts_reg & (EP_STS_SETUP | EP_STS_STPWAIT));
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/3 usb: cdns3: gadget: unsigned int is dereferenced as a wider unsigned long

In reply to Peter Chen

It is reported by Coverity scan, and fixed it by declare the reg as unsigned long.

---
 drivers/usb/cdns3/gadget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/cdns3/gadget.c +2 -2
index eac01b1a4958..2362faf7efeb 100644
@@ -1813,7 +1813,7 @@ static irqreturn_t cdns3_device_thread_irq_handler(int irq, void *data)
 	irqreturn_t ret = IRQ_NONE;
 	unsigned long flags;
 	int bit;
-	u32 reg;
+	unsigned long reg;
 
 	spin_lock_irqsave(&priv_dev->lock, flags);
 
@@ -1844,7 +1844,7 @@ static irqreturn_t cdns3_device_thread_irq_handler(int irq, void *data)
 	if (!reg)
 		goto irqend;
 
-	for_each_set_bit(bit, (unsigned long *)&reg,
+	for_each_set_bit(bit, &reg,
 			 sizeof(u32) * BITS_PER_BYTE) {
 		cdns3_check_ep_interrupt_proceed(priv_dev->eps[bit]);
 		ret = IRQ_HANDLED;
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 3/3 usb: cdns3: gadget: use unsigned int for 32-bit number

In reply to Peter Chen

If it is 'int', it can't stands for the highest bit for 32-bit number, since the largest 'int' is 0x7fffffff.

---
 drivers/usb/cdns3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/gadget.c +1 -1
index 2362faf7efeb..ecd395397e2c 100644
@@ -1812,7 +1812,7 @@ static irqreturn_t cdns3_device_thread_irq_handler(int irq, void *data)
 	struct cdns3_device *priv_dev = data;
 	irqreturn_t ret = IRQ_NONE;
 	unsigned long flags;
-	int bit;
+	unsigned int bit;
 	unsigned long reg;
 
 	spin_lock_irqsave(&priv_dev->lock, flags);
Signature · 1 line
2.17.1
Acked-by on the v1 series
#4 lore raw
In reply to Peter Chen

Hi,

Quoted 5 lines · Peter Chen

Peter Chen (3):
usb: cdns3: ep0: delete the duplicate code
usb: cdns3: gadget: unsigned int is dereferenced as a wider unsigned
long
usb: cdns3: gadget: use unsigned int for 32-bit number

For this series.

Quoted 5 lines
  drivers/usb/cdns3/ep0.c    | 2 +-
  drivers/usb/cdns3/gadget.c | 6 +++---
  2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 5 lines
cheers,
-roger

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki