From patchwork Tue Jun 8 14:26:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 54988 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 5BFF3101636 for ; Wed, 9 Jun 2010 00:27:12 +1000 (EST) Received: from mail-pv0-f179.google.com (mail-pv0-f179.google.com [74.125.83.179]) by ozlabs.org (Postfix) with ESMTP id 83658B7E5C; Wed, 9 Jun 2010 00:26:31 +1000 (EST) Received: by mail-pv0-f179.google.com with SMTP id 13so457581pvg.38 for ; Tue, 08 Jun 2010 07:26:31 -0700 (PDT) Received: by 10.115.39.39 with SMTP id r39mr12980961waj.157.1276007190981; Tue, 08 Jun 2010 07:26:30 -0700 (PDT) Received: from angua (S01060002b3d79728.cg.shawcable.net [70.72.87.49]) by mx.google.com with ESMTPS id c1sm51164667wam.19.2010.06.08.07.26.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Jun 2010 07:26:30 -0700 (PDT) Received: from [127.0.1.1] (unknown [IPv6:::1]) by angua (Postfix) with ESMTP id 8C88E3C0110; Tue, 8 Jun 2010 08:26:28 -0600 (MDT) Subject: [PATCH 3/6] of: Modify of_device_get_modalias to be passed struct device To: ben@kernel.crashing.org, sfr@canb.auug.org.au, monstr@monstr.eu, microblaze-uclinux@itee.uq.edu.au, devicetree-discuss@lists.ozlabs.org, jeremy.kerr@canonical.com, linuxppc-dev@lists.ozlabs.org From: Grant Likely Date: Tue, 08 Jun 2010 08:26:28 -0600 Message-ID: <20100608142628.26088.82089.stgit@angua> In-Reply-To: <20100608142152.26088.1108.stgit@angua> References: <20100608142152.26088.1108.stgit@angua> User-Agent: StGit/0.15 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Now that the of_node pointer is part of struct device, of_device_get_modalias could be used on any struct device that has the device node pointer set. This patch changes of_device_get_modalias to accept a struct device instead of a struct of_device. Signed-off-by: Grant Likely CC: Michal Simek CC: Benjamin Herrenschmidt CC: Wolfram Sang CC: Stephen Rothwell CC: microblaze-uclinux@itee.uq.edu.au CC: linuxppc-dev@ozlabs.org --- arch/microblaze/include/asm/of_device.h | 3 --- drivers/macintosh/macio_sysfs.c | 5 +---- drivers/of/device.c | 16 ++++++---------- include/linux/of_device.h | 2 +- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/arch/microblaze/include/asm/of_device.h b/arch/microblaze/include/asm/of_device.h index 58e627d..c9be534 100644 --- a/arch/microblaze/include/asm/of_device.h +++ b/arch/microblaze/include/asm/of_device.h @@ -15,9 +15,6 @@ #include #include -extern ssize_t of_device_get_modalias(struct of_device *ofdev, - char *str, ssize_t len); - extern struct of_device *of_device_alloc(struct device_node *np, const char *bus_id, struct device *parent); diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c index 6999ce5..6024038 100644 --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c @@ -41,10 +41,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf) static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, char *buf) { - struct of_device *ofdev = to_of_device(dev); - int len; - - len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); + int len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); buf[len] = '\n'; buf[len+1] = 0; diff --git a/drivers/of/device.c b/drivers/of/device.c index 275cc9c..c2a98f5 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -68,10 +68,7 @@ static ssize_t name_show(struct device *dev, static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct of_device *ofdev = to_of_device(dev); - ssize_t len = 0; - - len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); + ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); buf[len] = '\n'; buf[len+1] = 0; return len+1; @@ -123,19 +120,18 @@ void of_device_unregister(struct of_device *ofdev) } EXPORT_SYMBOL(of_device_unregister); -ssize_t of_device_get_modalias(struct of_device *ofdev, - char *str, ssize_t len) +ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) { const char *compat; int cplen, i; ssize_t tsize, csize, repend; /* Name & Type */ - csize = snprintf(str, len, "of:N%sT%s", ofdev->dev.of_node->name, - ofdev->dev.of_node->type); + csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name, + dev->of_node->type); /* Get compatible property if any */ - compat = of_get_property(ofdev->dev.of_node, "compatible", &cplen); + compat = of_get_property(dev->of_node, "compatible", &cplen); if (!compat) return csize; @@ -210,7 +206,7 @@ int of_device_uevent(struct device *dev, struct kobj_uevent_env *env) if (add_uevent_var(env, "MODALIAS=")) return -ENOMEM; - sl = of_device_get_modalias(to_of_device(dev), &env->buf[env->buflen-1], + sl = of_device_get_modalias(dev, &env->buf[env->buflen-1], sizeof(env->buf) - env->buflen); if (sl >= (sizeof(env->buf) - env->buflen)) return -ENOMEM; diff --git a/include/linux/of_device.h b/include/linux/of_device.h index da83e73..238e92e 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -42,7 +42,7 @@ static inline void of_device_free(struct of_device *dev) of_release_dev(&dev->dev); } -extern ssize_t of_device_get_modalias(struct of_device *ofdev, +extern ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len); extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env);