From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mundt Date: Mon, 15 Mar 2010 08:03:59 +0000 Subject: Re: [PATCH] driver core: Early dev_name() support. Message-Id: <20100315080359.GA15171@linux-sh.org> List-Id: References: <20100309065753.GA8287@linux-sh.org> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Kay Sievers Cc: Greg KH , Magnus Damm , linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org On Thu, Mar 11, 2010 at 08:59:18PM +0100, Kay Sievers wrote: > On Tue, Mar 9, 2010 at 07:57, Paul Mundt wrote: > > This implements early init_name construction from the matched name/id > > pair following the semantics of the late device/driver match. As a > > result, matched IDs (inclusive of requested ones) are preserved when the > > handoff from the early platform code happens at kobject initialization > > time. > > > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 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; > > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? } > > This can be kasprintf() I guess. > Yeah, that looks fine. I'll update it. > > ??static inline const char *dev_name(const struct device *dev) > > ??{ > > + ?? ?? ?? /* Use the init name until the kobject becomes available */ > > This should probably state that it's used for getting names out of > unregistered devices. Otherwise it sounds confusing. > It's not clear that that distinction makes things any less confusing. Early devices are registered, they just haven't been fully initialized yet. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759778Ab0COIE6 (ORCPT ); Mon, 15 Mar 2010 04:04:58 -0400 Received: from 124x34x33x190.ap124.ftth.ucom.ne.jp ([124.34.33.190]:60214 "EHLO master.linux-sh.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759617Ab0COIE4 (ORCPT ); Mon, 15 Mar 2010 04:04:56 -0400 Date: Mon, 15 Mar 2010 17:03:59 +0900 From: Paul Mundt To: Kay Sievers Cc: Greg KH , Magnus Damm , linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org Subject: Re: [PATCH] driver core: Early dev_name() support. Message-ID: <20100315080359.GA15171@linux-sh.org> References: <20100309065753.GA8287@linux-sh.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 11, 2010 at 08:59:18PM +0100, Kay Sievers wrote: > On Tue, Mar 9, 2010 at 07:57, Paul Mundt wrote: > > This implements early init_name construction from the matched name/id > > pair following the semantics of the late device/driver match. As a > > result, matched IDs (inclusive of requested ones) are preserved when the > > handoff from the early platform code happens at kobject initialization > > time. > > > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 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; > > + ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? } > > This can be kasprintf() I guess. > Yeah, that looks fine. I'll update it. > > ??static inline const char *dev_name(const struct device *dev) > > ??{ > > + ?? ?? ?? /* Use the init name until the kobject becomes available */ > > This should probably state that it's used for getting names out of > unregistered devices. Otherwise it sounds confusing. > It's not clear that that distinction makes things any less confusing. Early devices are registered, they just haven't been fully initialized yet.