Received: by 10.192.165.148 with SMTP id m20csp2507650imm; Sun, 6 May 2018 16:58:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTzo+Cu96kbxfnXTNY19bsC6EudHWZe3NOG/vHv+eF6oOt+0iBj5KtyiPfGLnkoSjEzCdS X-Received: by 2002:a63:41c7:: with SMTP id o190-v6mr29219132pga.57.1525651134552; Sun, 06 May 2018 16:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525651134; cv=none; d=google.com; s=arc-20160816; b=oK2li2300MQvN8TYzWVWEZvMOkIcVSYGhUPa1NWH2xjFPIlOwWaf+qKclj7zOn9J8H gplwBPkwj8LRhMM0ZRTRpACQixfEYFhuEMEyqavBkoZypfJkSmxl3LOI47+RWIODgtuf Wj7zHzVe48LRhTRlRC3DAx05/z0YNEalQeUrLOZjnusI2BDgl/ZLv4LBh7LeWMKk2dY9 ee+p2kXwTmVzIk00gAMUpGGFi60tKyLuER4Hhq9spO6zmWYcroiSIXitn6ZoQVgyt2U6 U2p+9Lo0xlcGhsDIKiLoyAuCEB+doBjseQIRrpph08h6kSdjEhNCJocUuAGxRck2KZOy MUgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date:arc-authentication-results; bh=904Zf7hCKvMeI6wbDgOpcSqLW4QRIHYKT9N6f18rm5E=; b=gZBmXyqnMuU5u20KhRBt/fiDTA/lSkltdpQ0a215DGFgG7N39p7MPwBkOmdFAG9anL YiQ+crgUT5+5+fcmk/3zdB4myBxhQ1kwIYovWinlHGmbjFi5MCUWRf96R5ObPksYT55v I3ag8XSN378zws+QQbps4oksa4jcikQtTCjKKN5may7fbCPlniCJhYmC//GgzU8AkYcg x9+6zYLK/i+XCebjstPFEvr12BIT5GLwA2aPTu0g4ZQPs0bJjLiSFfkDw8skZLQx1d2g IZ+iyVatdN6Uad7Qqmq21wxzfITRPLf4Y2RYQVCLQ72wF8h0GL9tY5mxDL8vu5nx+Hgq oBSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si20787206plc.203.2018.05.06.16.58.38; Sun, 06 May 2018 16:58:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751919AbeEFX5X (ORCPT + 99 others); Sun, 6 May 2018 19:57:23 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:37180 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751849AbeEFX5V (ORCPT ); Sun, 6 May 2018 19:57:21 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id F1AEE23F1C; Sun, 6 May 2018 19:57:17 -0400 (EDT) Date: Mon, 7 May 2018 09:57:22 +1000 (AEST) From: Finn Thain To: Greg Kroah-Hartman cc: Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nubus: Unconditionally register bus type In-Reply-To: <20180506202018.GC8924@kroah.com> Message-ID: References: <5aee5ed3.1c69fb81.19d98.ef06SMTPIN_ADDED_MISSING@mx.google.com> <20180506045530.GA5328@kroah.com> <20180506202018.GC8924@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 6 May 2018, Greg Kroah-Hartman wrote: > > > Why not just have an "bus is registered" flag in your driver > > > register function that refuses to let drivers register with the > > > driver core if it isn't set? > > > > Perhaps that should happen in the core driver_register() function. > > BUG_ON is frowned upon, after all. Would that be acceptable? > > I don't understand what you mean here, perhaps make a patch to show it? > As an alternative to your suggestion (add flag to avoid the BUG_ON): --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -148,7 +148,10 @@ int driver_register(struct device_driver *drv) int ret; struct device_driver *other; - BUG_ON(!drv->bus->p); + if (!drv->bus->p) { + WARN_ONCE(1, "Cannot register driver with invalid bus\n"); + return -EPROBE_DEFER; + } if ((drv->bus->probe && drv->probe) || (drv->bus->remove && drv->remove) || I'm not actually proposing this change; just responding to your question. For the bug at hand, I still prefer the patch at the beginning of this thread, because it seems to follow the conventional pattern. > > I found a few drivers that set a flag the way you describe, which > > could then be simplified. > > > > But that pattern is rare. Most buses use the postcore_initcall() > > pattern, and so my patch took the conventional approach. > > It all depends on link order, not necessarily the postcore stuff. > > > > And then fix your linking error, the bus should come first in link > > > order, before your drivers :) > > > > > > > I didn't encounter any errors. How shall I reproduce this? > > If you have not seen this error, then why change the code at all if it > is working properly? I never saw the link error you mentioned. Please see this thread for one example of how to hit the BUG_ON. https://marc.info/?l=linux-m68k&m=152522162801182&w=2 Another way to trigger the BUG_ON is to set, CONFIG_ATARI=y CONFIG_MAC=y CONFIG_NUBUS=y CONFIG_MAC8390=y and try to boot the result on aranym. -- > Most busses do not need this as they have their link order set up > correctly, no need to mess with stuff that is not broken :) > > thanks, > > greg k-h > -- > To unsubscribe from this list: send the line "unsubscribe linux-m68k" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >