From: "Lu, Baolu" <baolu.lu@linux.intel.com>
To: David Cohen <david.a.cohen@linux.intel.com>,
Sasha Levin <sasha.levin@oracle.com>
Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
balbi@ti.com
Subject: Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist
Date: Thu, 21 May 2015 14:39:48 +0800 [thread overview]
Message-ID: <555D7DB4.6030606@linux.intel.com> (raw)
In-Reply-To: <20150520212235.GA20943@psi-dev26.jf.intel.com>
On 05/21/2015 05:22 AM, David Cohen wrote:
> Hi,
>
> On Wed, May 20, 2015 at 03:33:26PM -0400, Sasha Levin wrote:
>> ULPI registers it's bus at module_init so if the bus fails to register, the
> A minor comment: s/it's/its/
>
>> module will fail to load and all will be well in the world.
>>
>> However, if the ULPI code is built-in rather than a module, the bus
>> initialization may fail but we'd still try to register drivers later onto
>> a non-existant bus, which will panic the kernel.
>>
>> Fix that by checking that the bus was indeed initialized before trying to
>> register drivers on top of it.
>>
>> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
>> ---
>> drivers/usb/common/ulpi.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
>> index 0e6f968..0b0a5e7 100644
>> --- a/drivers/usb/common/ulpi.c
>> +++ b/drivers/usb/common/ulpi.c
>> @@ -132,6 +132,10 @@ int ulpi_register_driver(struct ulpi_driver *drv)
>> if (!drv->probe)
>> return -EINVAL;
>>
>> + /* Was the bus registered successfully? */
>> + if (!ulpi_bus.p)
>> + return -ENODEV;
>> +
> Good catch. Otherwise it may trigger BUG() on driver_register().
> I wonder if it would be nice to have a macro for that checking :)
>
> Anyway,
>
> Reviewed-by: David Cohen <david.a.cohen@linux.intel.com>
Well, I was also encountering panic issue when running it on
Intel Bay Trail tablets. In my case, it's due to the execution
sequence. When ulpi bus is built-in, driver or device registered
before ulpi bus registration.
Thanks,
Baolu
>
>> drv->driver.bus = &ulpi_bus;
>>
>> return driver_register(&drv->driver);
>> --
>> 1.7.10.4
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
next prev parent reply other threads:[~2015-05-21 6:40 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-20 19:33 [PATCH] usb: ulpi: don't register drivers if bus doesn't exist Sasha Levin
2015-05-20 21:22 ` David Cohen
2015-05-21 6:39 ` Lu, Baolu [this message]
2015-05-21 7:21 ` Heikki Krogerus
2015-05-22 10:16 ` Heikki Krogerus
2015-05-22 10:52 ` Heikki Krogerus
2015-05-22 14:21 ` Sasha Levin
2015-05-24 7:19 ` Greg KH
2015-05-24 8:09 ` Sudip Mukherjee
2015-05-24 14:30 ` Tal Shorer
2015-05-25 11:40 ` Heikki Krogerus
2015-05-25 16:13 ` Greg KH
2015-05-25 17:00 ` Bjørn Mork
2015-05-26 17:54 ` David Cohen
2015-05-27 2:41 ` Greg KH
2015-05-27 4:35 ` Sudip Mukherjee
2015-05-27 16:49 ` David Cohen
2015-05-27 2:39 ` Greg KH
2015-05-27 8:39 ` Heikki Krogerus
2015-05-27 9:05 ` Sudip Mukherjee
2015-05-27 15:16 ` Alan Stern
2015-05-27 15:21 ` Greg KH
2015-05-28 5:39 ` Sudip Mukherjee
2015-05-28 5:54 ` Felipe Balbi
2015-05-28 6:42 ` Sudip Mukherjee
2015-05-28 6:53 ` Sudip Mukherjee
2015-05-28 15:57 ` Alan Stern
2015-05-28 12:36 ` Sasha Levin
2015-05-28 13:24 ` Heikki Krogerus
2015-05-28 16:23 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555D7DB4.6030606@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=balbi@ti.com \
--cc=david.a.cohen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sasha.levin@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox