Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752434AbbEYLmZ (ORCPT ); Mon, 25 May 2015 07:42:25 -0400 Received: from mga09.intel.com ([134.134.136.24]:42342 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752398AbbEYLmX (ORCPT ); Mon, 25 May 2015 07:42:23 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,491,1427785200"; d="scan'208";a="734881911" Date: Mon, 25 May 2015 14:40:10 +0300 From: Heikki Krogerus To: Tal Shorer , Greg KH Cc: 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: <20150525114010.GA30679@kuha.fi.intel.com> References: <1432150406-20550-1-git-send-email-sasha.levin@oracle.com> <20150524071948.GA20923@kroah.com> <20150524080940.GA4033@sudip-PC> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: 2117 Lines: 54 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? Thanks, -- heikki -- 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/