From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754103AbbE1MhP (ORCPT ); Thu, 28 May 2015 08:37:15 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:46416 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750756AbbE1MhJ (ORCPT ); Thu, 28 May 2015 08:37:09 -0400 Message-ID: <55670BDE.5070103@oracle.com> Date: Thu, 28 May 2015 08:36:46 -0400 From: Sasha Levin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Sudip Mukherjee , Greg KH CC: Alan Stern , Heikki Krogerus , Tal Shorer , USB list , "" , David Cohen , Felipe Balbi , Lu Baolu Subject: Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist References: <20150527083933.GA13844@kuha.fi.intel.com> <20150527152116.GA1972@kroah.com> <20150528053938.GB2944@sudip-PC> In-Reply-To: <20150528053938.GB2944@sudip-PC> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/28/2015 01:39 AM, Sudip Mukherjee wrote: > diff --git a/drivers/base/driver.c b/drivers/base/driver.c > index 4eabfe2..1acae5b 100644 > --- a/drivers/base/driver.c > +++ b/drivers/base/driver.c > @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv) > int ret; > struct device_driver *other; > > + if (!drv->bus->registered) { > + pr_err("Driver %s registration failed. bus not yet registered\n", > + drv->name); > + return -ENODEV; > + } > BUG_ON(!drv->bus->p); This is a design issue with the code in the layer above, there's no reason driver_register() should be called with a bus that wasn't registered to begin with. This is why there's a BUG_ON there to catch these issues - it's a bug, not a desired behaviour. Thanks, Sasha