Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751592AbbEYQNR (ORCPT ); Mon, 25 May 2015 12:13:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45551 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750803AbbEYQNN (ORCPT ); Mon, 25 May 2015 12:13:13 -0400 Date: Mon, 25 May 2015 09:13:12 -0700 From: Greg KH To: Heikki Krogerus Cc: Tal Shorer , Sudip Mukherjee , Sasha Levin , USB list , "" , David Cohen , Felipe Balbi , Lu Baolu Subject: Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist Message-ID: <20150525161312.GB9772@kroah.com> References: <1432150406-20550-1-git-send-email-sasha.levin@oracle.com> <20150524071948.GA20923@kroah.com> <20150524080940.GA4033@sudip-PC> <20150525114010.GA30679@kuha.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150525114010.GA30679@kuha.fi.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2443 Lines: 58 On Mon, May 25, 2015 at 02:40:10PM +0300, Heikki Krogerus wrote: > Hi, > > > Why do we even need that? If you take patch that makes ulpi_init a > > subsys_initcall you won't have this problem, and no additional weird > > hacks and errors will be needed > > Using subsys_initcall will work around the problem for now, but I > would not make the assumption that there will never be ulpi phy > drivers and ulpi interface drivers that don't use subsys_initcall > themselves. By checking the old phy drivers at drivers/usb/phy/, at > least so far it hasn't been uncommon for them to use subsys_initcall. > > I would much prefer to have a proper fix for this issue instead of > just working around it, but we need to use subsys_initcall in any > case. > > > >> > + /* Was the bus registered successfully? */ > > >> > + if (!ulpi_bus.p) > > >> > + return -ENODEV; > > >> > > >> Ick, no, don't go mucking around in the bus internals like this, that's > > >> not ok. You should either "know" the bus is registered, or something is > > >> really wrong with the design here. > > > can't we use a variable which can be initialized to 1 in ulpi_init() if > > > the bus registers successfully and later check that? > > Just a note. We should also be aware if the bus registration failed or > if it just hasn't been loaded yet. > > If we used a variable like that, I guess it could initially have the > value -EAGAIN. If bus_register returns error, we store -ENODEV to it. > If bus_register succeeds we store 0 to it. I don't know if we can just > store the return value from bus_register to it. > > In ulpi_register_driver and ulpi_register_interface we can then just > return it if it has a value other then 0. > > But couldn't we add a helper function to drivers/base/bus.c that the > bus drivers can use to at least check was the bus already loaded or > not? It looks like there are a couple of bus drivers that use the > struct bus member "p" to check that. > > Greg, what do you think? I think your design is wrong if you need to worry about this :) If there are other bus drivers that do this, I'll go fix them up, pointers to those files would be appreciated. thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/