mfd: Fix usbhs_enable error handling
Subsystems (2)
PATCH 1/1 mfd: Fix usbhs_enable error handling
In the case of missing platform_data we do not hold a spin_lock, thus we should not call spin_unlock_irqrestore in the error path.
Also simplify the error handling by separating the successful path from error path. I think this change improves readability.
--- drivers/mfd/omap-usb-host.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
drivers/mfd/omap-usb-host.c +3 -5
@@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)dev_dbg (dev,"starting TI HSUSB Controller\n" );if (!pdata) {dev_dbg (dev,"missing platform_data\n" ); - ret = -ENODEV ; - goto end_enable; +return -ENODEV ; }spin_lock_irqsave (&omap->lock, flags);
@@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev) end_count: omap->count++; - goto end_enable; +spin_unlock_irqrestore (&omap->lock, flags); +return 0 ; err_tll:if (pdata->ehci_data->phy_reset) {
@@ -931,8 +931,6 @@ err_tll:clk_disable (omap->usbhost_fs_fck);clk_disable (omap->usbhost_hs_fck);clk_disable (omap->usbhost_ick); - -end_enable:spin_unlock_irqrestore (&omap->lock, flags);return ret; }
Signature · 1 line
1.7.1
Quoted 52 lines
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Tuesday, March 29, 2011 3:38 PM
To: [email protected]
Cc: Keshava Munegowda; Samuel Ortiz
Subject: [PATCH] mfd: Fixusbhs_enableerror handlingIn the case of missing
platform_datawe do not hold aspin_lock, thus we should not callspin_unlock_irqrestorein the error path.Also simplify the error handling by separating the successful path from error path. I think this change improves readability.
Signed-off-by Axel Lin <[email protected]>--- drivers/mfd/omap-usb-host.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/mfd/omap-usb-host.c +3
-6@@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)dev_dbg (dev,"starting TI HSUSB Controller\n" );if (!pdata) {dev_dbg (dev,"missing platform_data\n" ); - ret = -ENODEV ; - goto end_enable; +return -ENODEV ; }spin_lock_irqsave (&omap->lock, flags);@@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev) end_count: omap->count++; - goto end_enable; +spin_unlock_irqrestore (&omap->lock, flags); +return 0 ; err_tll:if (pdata->ehci_data->phy_reset) {@@ -931,8 +931,6 @@ err_tll:clk_disable (omap->usbhost_fs_fck);clk_disable (omap->usbhost_hs_fck);clk_disable (omap->usbhost_ick); - -end_enable:spin_unlock_irqrestore (&omap->lock, flags);return ret; } --
Quoted 3 lines
1.7.1
Thanks Axel!
Quoted 52 lines
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Tuesday, March 29, 2011 3:38 PM
To: [email protected]
Cc: Keshava Munegowda; Samuel Ortiz
Subject: [PATCH] mfd: Fixusbhs_enableerror handlingIn the case of missing
platform_datawe do not hold aspin_lock, thus we should not callspin_unlock_irqrestorein the error path.Also simplify the error handling by separating the successful path from error path. I think this change improves readability.
Signed-off-by Axel Lin <[email protected]>--- drivers/mfd/omap-usb-host.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/mfd/omap-usb-host.c +3
-6@@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)dev_dbg (dev,"starting TI HSUSB Controller\n" );if (!pdata) {dev_dbg (dev,"missing platform_data\n" ); - ret = -ENODEV ; - goto end_enable; +return -ENODEV ; }spin_lock_irqsave (&omap->lock, flags);@@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev) end_count: omap->count++; - goto end_enable; +spin_unlock_irqrestore (&omap->lock, flags); +return 0 ; err_tll:if (pdata->ehci_data->phy_reset) {@@ -931,8 +931,6 @@ err_tll:clk_disable (omap->usbhost_fs_fck);clk_disable (omap->usbhost_hs_fck);clk_disable (omap->usbhost_ick); - -end_enable:spin_unlock_irqrestore (&omap->lock, flags);return ret; } --
Quoted 1 line
1.7.1
Thanks Axel!
Quoted 1 line
Felipe Balbi
Acked-byQuoted 55 lines · Keshava Munegowda
Quoted 52 lines
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Tuesday, March 29, 2011 3:38 PM
To: [email protected]
Cc: Keshava Munegowda; Samuel Ortiz
Subject: [PATCH] mfd: Fixusbhs_enableerror handlingIn the case of missing
platform_datawe do not hold aspin_lock, thus we should not callspin_unlock_irqrestorein the error path.Also simplify the error handling by separating the successful path from error path. I think this change improves readability.
Signed-off-by Axel Lin <[email protected]>--- drivers/mfd/omap-usb-host.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)drivers/mfd/omap-usb-host.c +3
-6@@ -700,8 +700,7 @@ static int usbhs_enable(struct device *dev)dev_dbg (dev,"starting TI HSUSB Controller\n" );if (!pdata) {dev_dbg (dev,"missing platform_data\n" ); - ret = -ENODEV ; - goto end_enable; +return -ENODEV ; }spin_lock_irqsave (&omap->lock, flags);@@ -915,7 +914,8 @@ static int usbhs_enable(struct device *dev) end_count: omap->count++; - goto end_enable; +spin_unlock_irqrestore (&omap->lock, flags); +return 0 ; err_tll:if (pdata->ehci_data->phy_reset) {@@ -931,8 +931,6 @@ err_tll:clk_disable (omap->usbhost_fs_fck);clk_disable (omap->usbhost_hs_fck);clk_disable (omap->usbhost_ick); - -end_enable:spin_unlock_irqrestore (&omap->lock, flags);return ret; } --Quoted 1 line
1.7.1
Thanks Axel!
Quoted 1 line
Samuel, Greg is out for the week, could you take this one through your tree instead of waiting for a week until we get this fix merged. If you need my Ack, here it goes:
Signature · 1 line
balbi
Hi Axel,
Quoted 5 lines · Axel Lin
In the case of missing
platform_datawe do not hold aspin_lock, thus we should not callspin_unlock_irqrestorein the error path.Also simplify the error handling by separating the successful path from error path. I think this change improves readability.
Patch applied to my for-next branch, thanks.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/