[PATCH RFC 1/3] usb: phy: fix the error check
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 shubhrajy...@ti.com --- 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
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 shubhrajy...@ti.com --- 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
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 shubhrajy...@ti.com --- 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
Re: [PATCH RFC] usb: musb: Make dma_controller_create __devinit
On Thursday 09 August 2012 03:01 PM, Felipe Balbi wrote: On Tue, Aug 07, 2012 at 08:12:24PM +0530, Shubhrajyoti D wrote: 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); trailing change. not part of this patch. Yes indeed will remove this stray change. -- 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
Re: [PATCH RFC] usb: musb: Free NIrq in a missing error path
On Thursday 09 August 2012 04:59 PM, Felipe Balbi wrote: +free_irq(musb-nIrq, musb); a nicer patch (if you want to provide it) would be to convert musb to devm_* apis, so a bunch of this pointless error path handling can be dropped ;-) Yes agree that would be nicer. thanks, -- 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
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 shubhrajy...@ti.com --- 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: Prevent the masking of the return value
Currently the errors returned by fifo_setup get masked by EINVAL, propagate the same to the caller. Signed-off-by: Shubhrajyoti D shubhrajy...@ti.com --- 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: otg: Remove the unneeded NULL check
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 shubhrajy...@ti.com --- 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
Re: [PATCH v6 01/11] drivers: usb: otg: add a new driver for omap usb2 phy
On Monday 30 July 2012 03:16 PM, ABRAHAM, KISHON VIJAY wrote: Hi, On Mon, Jul 30, 2012 at 3:07 PM, Shubhrajyoti shubhrajy...@ti.com wrote: On Monday 30 July 2012 02:39 PM, Kishon Vijay Abraham I wrote: + writel(~PHY_PD, phy-control_dev); + /* XXX: add proper documentation for this delay */ + mdelay(200); Do you need this to be busy? This might be called from interrupt context. This delay was initially added in omap_phy_internal.c and I just inherited it. Thanks for the explanation. Thanks Kishon -- 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