[PATCH RFC 1/3] usb: phy: fix the error check

2012-09-13 Thread Shubhrajyoti D
The functions pm_runtime_get_sync and clk_enable
return a signed value. So the variable used to
store should be signed otherwise a negative value may be
wrongly interpreted.

While at it also remove the initialisation of ret to zero.

Signed-off-by: Shubhrajyoti D 
---
untested

 drivers/usb/phy/omap-usb2.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c
index 15ab3d6..d36c282 100644
--- a/drivers/usb/phy/omap-usb2.c
+++ b/drivers/usb/phy/omap-usb2.c
@@ -120,7 +120,7 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
 
 static int omap_usb2_suspend(struct usb_phy *x, int suspend)
 {
-   u32 ret;
+   int ret;
struct omap_usb *phy = phy_to_omapusb(x);
 
if (suspend && !phy->is_suspended) {
@@ -223,7 +223,7 @@ static int omap_usb2_runtime_suspend(struct device *dev)
 
 static int omap_usb2_runtime_resume(struct device *dev)
 {
-   u32 ret = 0;
+   int ret;
struct platform_device  *pdev = to_platform_device(dev);
struct omap_usb *phy = platform_get_drvdata(pdev);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC 2/3] usb: twl6030: fix the error check for omap_usb2_set_comparator

2012-09-13 Thread Shubhrajyoti D
The function omap_usb2_set_comparator may return -ENODEV.
Use a signed variable to store and check so that the value
is not wrongly interpreted as a large positive number.
While at it lets use the err variable to do the same.

Signed-off-by: Shubhrajyoti D 
---
untested

 drivers/usb/otg/twl6030-usb.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index fcadef7..11c22f3 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -312,7 +312,6 @@ static int twl6030_set_vbus(struct phy_companion 
*comparator, bool enabled)
 
 static int __devinit twl6030_usb_probe(struct platform_device *pdev)
 {
-   u32 ret;
struct twl6030_usb  *twl;
int status, err;
struct device_node  *np = pdev->dev.of_node;
@@ -331,8 +330,8 @@ static int __devinit twl6030_usb_probe(struct 
platform_device *pdev)
twl->comparator.set_vbus= twl6030_set_vbus;
twl->comparator.start_srp   = twl6030_start_srp;
 
-   ret = omap_usb2_set_comparator(&twl->comparator);
-   if (ret == -ENODEV) {
+   err = omap_usb2_set_comparator(&twl->comparator);
+   if (err == -ENODEV) {
dev_info(&pdev->dev, "phy not ready, deferring probe");
return -EPROBE_DEFER;
}
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC 3/3] usb: twl6030: remove the twl6030_readb function

2012-09-13 Thread Shubhrajyoti D
Currently upon the read errors twl6030_readb returns a negative number.
The return value may be wrongly interpreted as the read value. Call
twl_i2c_read_u8 directly and in case of errors return thus preventing a
possible spurious detection.

Signed-off-by: Shubhrajyoti D 
---
untested.

 drivers/usb/otg/twl6030-usb.c |   39 +--
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c
index 11c22f3..8be63bf 100644
--- a/drivers/usb/otg/twl6030-usb.c
+++ b/drivers/usb/otg/twl6030-usb.c
@@ -124,20 +124,6 @@ static inline int twl6030_writeb(struct twl6030_usb *twl, 
u8 module,
return ret;
 }
 
-static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address)
-{
-   u8 data, ret = 0;
-
-   ret = twl_i2c_read_u8(module, &data, address);
-   if (ret >= 0)
-   ret = data;
-   else
-   dev_err(twl->dev,
-   "readb[0x%x,0x%x] Error %d\n",
-   module, address, ret);
-   return ret;
-}
-
 static int twl6030_start_srp(struct phy_companion *comparator)
 {
struct twl6030_usb *twl = comparator_to_twl(comparator);
@@ -211,11 +197,22 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
struct twl6030_usb *twl = _twl;
enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
u8 vbus_state, hw_state;
+   int ret;
 
-   hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
+   ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, &hw_state, STS_HW_CONDITIONS);
+   if (ret < 0) {
+   dev_err(twl->dev, "readb[0x%x,0x%x] Error %d\n",
+   TWL6030_MODULE_ID0, STS_HW_CONDITIONS, ret);
+   return IRQ_HANDLED;
+   }
 
-   vbus_state = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE,
-   CONTROLLER_STAT1);
+   ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, &vbus_state,
+   CONTROLLER_STAT1);
+   if (ret < 0) {
+   dev_err(twl->dev, "readb[0x%x,0x%x] Error %d\n",
+   TWL_MODULE_MAIN_CHARGE, CONTROLLER_STAT1, ret);
+   return IRQ_HANDLED;
+   }
if (!(hw_state & STS_USB_ID)) {
if (vbus_state & VBUS_DET) {
regulator_enable(twl->usb3v3);
@@ -245,8 +242,14 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)
struct twl6030_usb *twl = _twl;
enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
u8 hw_state;
+   int ret;
 
-   hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
+   ret = twl_i2c_read_u8(TWL6030_MODULE_ID0, &hw_state, STS_HW_CONDITIONS);
+   if (ret < 0) {
+   dev_err(twl->dev, "readb[0x%x,0x%x] Error %d\n",
+   TWL6030_MODULE_ID0, STS_HW_CONDITIONS, ret);
+   return IRQ_HANDLED;
+   }
 
if (hw_state & STS_USB_ID) {
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC] usb: musb: Prevent the masking of the return value

2012-08-07 Thread Shubhrajyoti D
Currently the errors returned by fifo_setup get masked
by EINVAL, propagate the same to the caller.

Signed-off-by: Shubhrajyoti D 
---
 drivers/usb/musb/musb_core.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 5760de9..cf22953 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1302,7 +1302,7 @@ done:
if (offset < 0) {
pr_debug("%s: mem overrun, ep %d\n",
musb_driver_name, epn);
-   return -EINVAL;
+   return offset;
}
epn++;
musb->nr_endpoints = max(epn, musb->nr_endpoints);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC] usb: musb: Free NIrq in a missing error path

2012-08-07 Thread Shubhrajyoti D
In one of the error paths the free of nIrq was missed.
Fix the same.

Signed-off-by: Shubhrajyoti D 
---
 drivers/usb/musb/musb_core.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index cf22953..d4504d5 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2034,7 +2034,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
 
}
if (status < 0)
-   goto fail3;
+   goto free_irq;
 
status = musb_init_debugfs(musb);
if (status < 0)
@@ -2066,12 +2066,12 @@ fail5:
musb_exit_debugfs(musb);
 
 fail4:
-   free_irq(musb->nIrq, musb);
if (!is_otg_enabled(musb) && is_host_enabled(musb))
usb_remove_hcd(musb_to_hcd(musb));
else
musb_gadget_cleanup(musb);
-
+free_irq:
+   free_irq(musb->nIrq, musb);
 fail3:
pm_runtime_put_sync(musb->controller);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC] usb: otg: Remove the unneeded NULL check

2012-08-07 Thread Shubhrajyoti D
The function usb_add_phy trusts the sanity of the caller.
Also it accesses x after the NULL check.
Remove the unneeded check.

Signed-off-by: Shubhrajyoti D 
---
 drivers/usb/otg/otg.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 1bf60a2..a30c041 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -159,7 +159,7 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
unsigned long   flags;
struct usb_phy  *phy;
 
-   if (x && x->type != USB_PHY_TYPE_UNDEFINED) {
+   if (x->type != USB_PHY_TYPE_UNDEFINED) {
dev_err(x->dev, "not accepting initialized PHY %s\n", x->label);
return -EINVAL;
}
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC] usb: musb: Make dma_controller_create __devinit

2012-08-07 Thread Shubhrajyoti D
dma_controller_create is called only from musb_init_controller
which is __devint so annotate dma_controller_create also with
__devint.

fixes the warn

WARNING: vmlinux.o(.devinit.text+0x6fa8): Section mismatch in reference from 
the function musb_init_controller() to the function 
.init.text:dma_controller_create()
The function __devinit musb_init_controller() references
a function __init dma_controller_create().
If dma_controller_create is only used by musb_init_controller then
annotate dma_controller_create with a matching annotation.

Signed-off-by: Shubhrajyoti D 
---
 drivers/usb/musb/cppi_dma.c  |2 +-
 drivers/usb/musb/musb_core.c |1 +
 drivers/usb/musb/musb_dma.h  |2 +-
 drivers/usb/musb/musbhsdma.c |2 +-
 drivers/usb/musb/tusb6010_omap.c |2 +-
 drivers/usb/musb/ux500_dma.c |2 +-
 6 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 8637c1f..e19da82 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -1316,7 +1316,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
 }
 
 /* Instantiate a software object representing a DMA controller. */
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *mregs)
 {
struct cppi *controller;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 26f1bef..5760de9 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2066,6 +2066,7 @@ fail5:
musb_exit_debugfs(musb);
 
 fail4:
+   free_irq(musb->nIrq, musb);
if (!is_otg_enabled(musb) && is_host_enabled(musb))
usb_remove_hcd(musb_to_hcd(musb));
else
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 3a97c4e..24d3921 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -178,7 +178,7 @@ struct dma_controller {
 extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit);
 
 
-extern struct dma_controller *__init
+extern struct dma_controller *__devinit
 dma_controller_create(struct musb *, void __iomem *);
 
 extern void dma_controller_destroy(struct dma_controller *);
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 57a6085..444b9ee 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -380,7 +380,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(controller);
 }
 
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *base)
 {
struct musb_dma_controller *controller;
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index b67b4bc..53e2596 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -662,7 +662,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(tusb_dma);
 }
 
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *base)
 {
void __iomem*tbase = musb->ctrl_base;
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index d05c7fb..639d58e 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -364,7 +364,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(controller);
 }
 
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *base)
 {
struct ux500_dma_controller *controller;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1] usb: musb: Make dma_controller_create __devinit

2012-08-09 Thread Shubhrajyoti D
dma_controller_create is called only from musb_init_controller
which is __devint so annotate dma_controller_create also with
__devint.

fixes the warn

WARNING: vmlinux.o(.devinit.text+0x6fa8): Section mismatch in reference from 
the function musb_init_controller() to the function 
.init.text:dma_controller_create()
The function __devinit musb_init_controller() references
a function __init dma_controller_create().
If dma_controller_create is only used by musb_init_controller then
annotate dma_controller_create with a matching annotation.

Signed-off-by: Shubhrajyoti D 
---
Changes from RFC remove the stray changes

 drivers/usb/musb/cppi_dma.c  |2 +-
 drivers/usb/musb/musb_dma.h  |2 +-
 drivers/usb/musb/musbhsdma.c |2 +-
 drivers/usb/musb/tusb6010_omap.c |2 +-
 drivers/usb/musb/ux500_dma.c |2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 8637c1f..e19da82 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -1316,7 +1316,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
 }
 
 /* Instantiate a software object representing a DMA controller. */
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *mregs)
 {
struct cppi *controller;
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 3a97c4e..24d3921 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -178,7 +178,7 @@ struct dma_controller {
 extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit);
 
 
-extern struct dma_controller *__init
+extern struct dma_controller *__devinit
 dma_controller_create(struct musb *, void __iomem *);
 
 extern void dma_controller_destroy(struct dma_controller *);
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 57a6085..444b9ee 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -380,7 +380,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(controller);
 }
 
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *base)
 {
struct musb_dma_controller *controller;
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index b67b4bc..53e2596 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -662,7 +662,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(tusb_dma);
 }
 
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *base)
 {
void __iomem*tbase = musb->ctrl_base;
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index d05c7fb..639d58e 100644
--- a/drivers/usb/musb/ux500_dma.c
+++ b/drivers/usb/musb/ux500_dma.c
@@ -364,7 +364,7 @@ void dma_controller_destroy(struct dma_controller *c)
kfree(controller);
 }
 
-struct dma_controller *__init
+struct dma_controller *__devinit
 dma_controller_create(struct musb *musb, void __iomem *base)
 {
struct ux500_dma_controller *controller;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC] usb: musb: convert the request_irq of NIrq to devm_*

2012-08-13 Thread Shubhrajyoti D
Convert the request_irq to devm_request_irq.
Also fixes the case where the in the function musb_init_controller
free_irq(called from musb_free) is called before it is allocated.

Signed-off-by: Shubhrajyoti D 
---
 drivers/usb/musb/musb_core.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index dd24f96..b5cf52a 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1834,7 +1834,6 @@ static void musb_free(struct musb *musb)
if (musb->nIrq >= 0) {
if (musb->irq_wake)
disable_irq_wake(musb->nIrq);
-   free_irq(musb->nIrq, musb);
}
if (is_dma_capable() && musb->dma_controller) {
struct dma_controller   *c = musb->dma_controller;
@@ -1947,7 +1946,8 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
INIT_WORK(&musb->irq_work, musb_irq_work);
 
/* attach to the IRQ */
-   if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+   if (devm_request_irq(musb->controller, nIrq, musb->isr, 0,
+   dev_name(dev), musb)) {
dev_err(dev, "request_irq %d failed!\n", nIrq);
status = -ENODEV;
goto fail3;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html