From patchwork Tue Mar 9 06:57:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mundt X-Patchwork-Id: 84235 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o296whtF003540 for ; Tue, 9 Mar 2010 06:58:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752584Ab0CIG6m (ORCPT ); Tue, 9 Mar 2010 01:58:42 -0500 Received: from 124x34x33x190.ap124.ftth.ucom.ne.jp ([124.34.33.190]:41225 "EHLO master.linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751873Ab0CIG6m (ORCPT ); Tue, 9 Mar 2010 01:58:42 -0500 Received: from localhost (unknown [127.0.0.1]) by master.linux-sh.org (Postfix) with ESMTP id BC75063758; Tue, 9 Mar 2010 06:57:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at linux-sh.org Received: from master.linux-sh.org ([127.0.0.1]) by localhost (master.linux-sh.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9mu8emwn-PGe; Tue, 9 Mar 2010 15:57:53 +0900 (JST) Received: by master.linux-sh.org (Postfix, from userid 500) id BDF486375A; Tue, 9 Mar 2010 15:57:53 +0900 (JST) Date: Tue, 9 Mar 2010 15:57:53 +0900 From: Paul Mundt To: Greg KH Cc: Magnus Damm , linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org Subject: [PATCH] driver core: Early dev_name() support. Message-ID: <20100309065753.GA8287@linux-sh.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 09 Mar 2010 06:58:44 +0000 (UTC) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 58efaf2..bc38f63 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1181,6 +1181,25 @@ static int __init early_platform_driver_probe_id(char *class_str, } if (match) { + /* + * Set up a sensible init_name to enable + * dev_name() and others to be used before the + * rest of the driver core is initialized. + */ + if (!match->dev.init_name) { + char buf[32]; + + if (match->id != -1) + snprintf(buf, sizeof(buf), "%s.%d", + match->name, match->id); + else + snprintf(buf, sizeof(buf), "%s", + match->name); + + match->dev.init_name = kstrdup(buf, GFP_KERNEL); + if (!match->dev.init_name) + return -ENOMEM; + } if (epdrv->pdrv->probe(match)) pr_warning("%s: unable to probe %s early.\n", class_str, match->name); diff --git a/include/linux/device.h b/include/linux/device.h index b30527d..3af5bce 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -432,6 +432,10 @@ struct device { static inline const char *dev_name(const struct device *dev) { + /* Use the init name until the kobject becomes available */ + if (dev->init_name) + return dev->init_name; + return kobject_name(&dev->kobj); }