diff mbox

[1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

Message ID 1361968035-18644-2-git-send-email-mkl@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Marc Kleine-Budde Feb. 27, 2013, 12:27 p.m. UTC
In patch "5d3c28b usb: otg: add device tree support to otg library"
devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
phy driver in memory. The corresponding module_put() is missing in that patch.

This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
Further the missing module_put() is added to usb_put_phy().

Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/usb/otg/otg.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Felipe Balbi Feb. 27, 2013, 12:31 p.m. UTC | #1
On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> In patch "5d3c28b usb: otg: add device tree support to otg library"
> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
> phy driver in memory. The corresponding module_put() is missing in that patch.
> 
> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
> Further the missing module_put() is added to usb_put_phy().
> 
> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
> Acked-by: Felipe Balbi <balbi@ti.com>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

this one doesn't apply to my tree. What did you use as a base ?
Marc Kleine-Budde Feb. 27, 2013, 12:40 p.m. UTC | #2
On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
>> In patch "5d3c28b usb: otg: add device tree support to otg library"
>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
>> phy driver in memory. The corresponding module_put() is missing in that patch.
>>
>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
>> Further the missing module_put() is added to usb_put_phy().
>>
>> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
>> Acked-by: Felipe Balbi <balbi@ti.com>
>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> 
> this one doesn't apply to my tree. What did you use as a base ?

As stated in the cover letter: Greg's usb-next.

git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

I'd really appreciate if this series goes into a single tree. So that
other chipidea developers can base their work on this.

Marc
Felipe Balbi Feb. 27, 2013, 12:43 p.m. UTC | #3
Hi,

On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> > On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> >> In patch "5d3c28b usb: otg: add device tree support to otg library"
> >> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
> >> phy driver in memory. The corresponding module_put() is missing in that patch.
> >>
> >> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
> >> Further the missing module_put() is added to usb_put_phy().
> >>
> >> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
> >> Acked-by: Felipe Balbi <balbi@ti.com>
> >> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> >> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> > 
> > this one doesn't apply to my tree. What did you use as a base ?
> 
> As stated in the cover letter: Greg's usb-next.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> 
> I'd really appreciate if this series goes into a single tree. So that
> other chipidea developers can base their work on this.

it eventually will all go through Greg's queue, but drivers/usb/phy and
drivers/usb/otg/ needs to go through my tree so we avoid conflicts
later, sorry.
Marc Kleine-Budde Feb. 27, 2013, 12:46 p.m. UTC | #4
On 02/27/2013 01:43 PM, Felipe Balbi wrote:
> Hi,
> 
> On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
>> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
>>> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
>>>> In patch "5d3c28b usb: otg: add device tree support to otg library"
>>>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
>>>> phy driver in memory. The corresponding module_put() is missing in that patch.
>>>>
>>>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
>>>> Further the missing module_put() is added to usb_put_phy().
>>>>
>>>> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
>>>> Acked-by: Felipe Balbi <balbi@ti.com>
>>>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>>>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>>>
>>> this one doesn't apply to my tree. What did you use as a base ?
>>
>> As stated in the cover letter: Greg's usb-next.
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
>>
>> I'd really appreciate if this series goes into a single tree. So that
>> other chipidea developers can base their work on this.
> 
> it eventually will all go through Greg's queue, but drivers/usb/phy and
> drivers/usb/otg/ needs to go through my tree so we avoid conflicts
> later, sorry.

Oh - this is going to be complicated. I'll rip the series into 3 parts
and repost.

Marc
Felipe Balbi Feb. 27, 2013, 12:47 p.m. UTC | #5
On Wed, Feb 27, 2013 at 01:46:21PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:43 PM, Felipe Balbi wrote:
> > Hi,
> > 
> > On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
> >> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> >>> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> >>>> In patch "5d3c28b usb: otg: add device tree support to otg library"
> >>>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
> >>>> phy driver in memory. The corresponding module_put() is missing in that patch.
> >>>>
> >>>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
> >>>> Further the missing module_put() is added to usb_put_phy().
> >>>>
> >>>> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
> >>>> Acked-by: Felipe Balbi <balbi@ti.com>
> >>>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> >>>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> >>>
> >>> this one doesn't apply to my tree. What did you use as a base ?
> >>
> >> As stated in the cover letter: Greg's usb-next.
> >>
> >> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> >>
> >> I'd really appreciate if this series goes into a single tree. So that
> >> other chipidea developers can base their work on this.
> > 
> > it eventually will all go through Greg's queue, but drivers/usb/phy and
> > drivers/usb/otg/ needs to go through my tree so we avoid conflicts
> > later, sorry.
> 
> Oh - this is going to be complicated. I'll rip the series into 3 parts
> and repost.

let's try like this:

drivers/usb/otg and drivers/usb/phy which don't create dependencies for
chipidea and other patches which create dependencies.

Then we can figure out how to handle the dependencies.
Marc Kleine-Budde Feb. 27, 2013, 12:55 p.m. UTC | #6
On 02/27/2013 01:47 PM, Felipe Balbi wrote:
> On Wed, Feb 27, 2013 at 01:46:21PM +0100, Marc Kleine-Budde wrote:
>> On 02/27/2013 01:43 PM, Felipe Balbi wrote:
>>> Hi,
>>>
>>> On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
>>>> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
>>>>> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
>>>>>> In patch "5d3c28b usb: otg: add device tree support to otg library"
>>>>>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
>>>>>> phy driver in memory. The corresponding module_put() is missing in that patch.
>>>>>>
>>>>>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
>>>>>> Further the missing module_put() is added to usb_put_phy().
>>>>>>
>>>>>> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
>>>>>> Acked-by: Felipe Balbi <balbi@ti.com>
>>>>>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>>>>>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>>>>>
>>>>> this one doesn't apply to my tree. What did you use as a base ?
>>>>
>>>> As stated in the cover letter: Greg's usb-next.
>>>>
>>>> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
>>>>
>>>> I'd really appreciate if this series goes into a single tree. So that
>>>> other chipidea developers can base their work on this.
>>>
>>> it eventually will all go through Greg's queue, but drivers/usb/phy and
>>> drivers/usb/otg/ needs to go through my tree so we avoid conflicts
>>> later, sorry.
>>
>> Oh - this is going to be complicated. I'll rip the series into 3 parts
>> and repost.
> 
> let's try like this:
> 
> drivers/usb/otg and drivers/usb/phy which don't create dependencies for
> chipidea and other patches which create dependencies.
> 
> Then we can figure out how to handle the dependencies.
> 

That'll be these 3 branches then:

otg-for-v3.9 (bugfix for v3.9):
6bef020 USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

otg-for-v3.10 (depends on otg-for-v3.9):
a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
8a4c9f8 USB mxs-phy: Register phy with framework

chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
9466e85 USB chipidea: add PTW and PTS handling
ad2cc0d USB chipidea: introduce dual role mode pdata flags
8e7f1bb USB chipidea i.MX: introduce dr_mode property
5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

Marc
Felipe Balbi Feb. 27, 2013, 1:42 p.m. UTC | #7
Hi,

On Wed, Feb 27, 2013 at 01:55:35PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:47 PM, Felipe Balbi wrote:
> > On Wed, Feb 27, 2013 at 01:46:21PM +0100, Marc Kleine-Budde wrote:
> >> On 02/27/2013 01:43 PM, Felipe Balbi wrote:
> >>> Hi,
> >>>
> >>> On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
> >>>> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> >>>>> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> >>>>>> In patch "5d3c28b usb: otg: add device tree support to otg library"
> >>>>>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
> >>>>>> phy driver in memory. The corresponding module_put() is missing in that patch.
> >>>>>>
> >>>>>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
> >>>>>> Further the missing module_put() is added to usb_put_phy().
> >>>>>>
> >>>>>> Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
> >>>>>> Acked-by: Felipe Balbi <balbi@ti.com>
> >>>>>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> >>>>>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> >>>>>
> >>>>> this one doesn't apply to my tree. What did you use as a base ?
> >>>>
> >>>> As stated in the cover letter: Greg's usb-next.
> >>>>
> >>>> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> >>>>
> >>>> I'd really appreciate if this series goes into a single tree. So that
> >>>> other chipidea developers can base their work on this.
> >>>
> >>> it eventually will all go through Greg's queue, but drivers/usb/phy and
> >>> drivers/usb/otg/ needs to go through my tree so we avoid conflicts
> >>> later, sorry.
> >>
> >> Oh - this is going to be complicated. I'll rip the series into 3 parts
> >> and repost.
> > 
> > let's try like this:
> > 
> > drivers/usb/otg and drivers/usb/phy which don't create dependencies for
> > chipidea and other patches which create dependencies.
> > 
> > Then we can figure out how to handle the dependencies.
> > 
> 
> That'll be these 3 branches then:
> 
> otg-for-v3.9 (bugfix for v3.9):
> 6bef020 USB otg: use try_module_get in all usb_get_phy functions and add missing module_put
> 
> otg-for-v3.10 (depends on otg-for-v3.9):
> a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
> a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
> 8a4c9f8 USB mxs-phy: Register phy with framework
> 
> chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
> 15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
> 9466e85 USB chipidea: add PTW and PTS handling
> ad2cc0d USB chipidea: introduce dual role mode pdata flags
> 8e7f1bb USB chipidea i.MX: introduce dr_mode property
> 5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

sounds good to me, please make sure to always split your series like
this. You can't expect me (or any maintainer for that matter) to pick
patches to proper branches based on your commit logs alone.

remeber that every single maintainer needs to handle hundreds of emails
a week (if not a day) and if patches are properly split and cleanly
mention if it's a bugfix or not, things will go wrong.
Marc Kleine-Budde Feb. 27, 2013, 1:55 p.m. UTC | #8
On 02/27/2013 02:42 PM, Felipe Balbi wrote:
>> That'll be these 3 branches then:
>>
>> otg-for-v3.9 (bugfix for v3.9):
>> 6bef020 USB otg: use try_module_get in all usb_get_phy functions and add missing module_put
>>
>> otg-for-v3.10 (depends on otg-for-v3.9):
>> a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
>> a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
>> 8a4c9f8 USB mxs-phy: Register phy with framework
>>
>> chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
>> 15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
>> 9466e85 USB chipidea: add PTW and PTS handling
>> ad2cc0d USB chipidea: introduce dual role mode pdata flags
>> 8e7f1bb USB chipidea i.MX: introduce dr_mode property
>> 5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
> 
> sounds good to me, please make sure to always split your series like
> this. You can't expect me (or any maintainer for that matter) to pick
> patches to proper branches based on your commit logs alone.
> 
> remeber that every single maintainer needs to handle hundreds of emails
> a week (if not a day) and if patches are properly split and cleanly
> mention if it's a bugfix or not, things will go wrong.

That was just a proposal. You'll find these series in your inbox in a
few minutes.

Marc
Marc Kleine-Budde Feb. 27, 2013, 2:21 p.m. UTC | #9
On 02/27/2013 02:55 PM, Marc Kleine-Budde wrote:
> On 02/27/2013 02:42 PM, Felipe Balbi wrote:
>>> That'll be these 3 branches then:
>>>
>>> otg-for-v3.9 (bugfix for v3.9):
>>> 6bef020 USB otg: use try_module_get in all usb_get_phy functions and add missing module_put
>>>
>>> otg-for-v3.10 (depends on otg-for-v3.9):
>>> a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
>>> a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
>>> 8a4c9f8 USB mxs-phy: Register phy with framework
>>>
>>> chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
>>> 15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
>>> 9466e85 USB chipidea: add PTW and PTS handling
>>> ad2cc0d USB chipidea: introduce dual role mode pdata flags
>>> 8e7f1bb USB chipidea i.MX: introduce dr_mode property
>>> 5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
>>
>> sounds good to me, please make sure to always split your series like
>> this. You can't expect me (or any maintainer for that matter) to pick
>> patches to proper branches based on your commit logs alone.
>>
>> remeber that every single maintainer needs to handle hundreds of emails
>> a week (if not a day) and if patches are properly split and cleanly
>> mention if it's a bugfix or not, things will go wrong.
> 
> That was just a proposal. You'll find these series in your inbox in a
> few minutes.

Done.

regards,
Marc
diff mbox

Patch

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index e181439..2bd03d2 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -130,7 +130,7 @@  struct usb_phy *usb_get_phy(enum usb_phy_type type)
 	spin_lock_irqsave(&phy_lock, flags);
 
 	phy = __usb_find_phy(&phy_list, type);
-	if (IS_ERR(phy)) {
+	if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
 		pr_err("unable to find transceiver of type %s\n",
 			usb_phy_type_string(type));
 		goto err0;
@@ -228,7 +228,7 @@  struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index)
 	spin_lock_irqsave(&phy_lock, flags);
 
 	phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
-	if (IS_ERR(phy)) {
+	if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
 		pr_err("unable to find transceiver\n");
 		goto err0;
 	}
@@ -301,8 +301,12 @@  EXPORT_SYMBOL(devm_usb_put_phy);
  */
 void usb_put_phy(struct usb_phy *x)
 {
-	if (x)
+	if (x) {
+		struct module *owner = x->dev->driver->owner;
+
 		put_device(x->dev);
+		module_put(owner);
+	}
 }
 EXPORT_SYMBOL(usb_put_phy);