From: Drew Moseley <dmoseley@mvista.com>
To: Kay Sievers <kay.sievers@vrfy.org>
Cc: ambx1@neo.rr.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Create PNP device attributes via dev_attrs field of struct device
Date: Wed, 24 Sep 2008 12:37:38 -0700 [thread overview]
Message-ID: <48DA9702.4020106@mvista.com> (raw)
In-Reply-To: <3ae72650809241203o41b62a10m31377887d44fd05e@mail.gmail.com>
Kay Sievers wrote:
> Yeah, it looks weird to mangle the bus_type values from a device
> routine, and set the same value again and again with every device
> creation. Just declare the array non-static, if moving the code around
> between files does not allow a static declaration.
Updated patch.
Drew
Signed-off-by: Drew Moseley <dmoseley@mvista.com>
Index: linux-2.6.21/drivers/pnp/base.h
===================================================================
--- linux-2.6.21.orig/drivers/pnp/base.h
+++ linux-2.6.21/drivers/pnp/base.h
@@ -1,6 +1,5 @@
extern spinlock_t pnp_lock;
void *pnp_alloc(long size);
-int pnp_interface_attach_device(struct pnp_dev *dev);
void pnp_fixup_device(struct pnp_dev *dev);
void pnp_free_option(struct pnp_option *option);
int __pnp_add_device(struct pnp_dev *dev);
Index: linux-2.6.21/drivers/pnp/core.c
===================================================================
--- linux-2.6.21.orig/drivers/pnp/core.c
+++ linux-2.6.21/drivers/pnp/core.c
@@ -111,7 +111,6 @@ static void pnp_release_device(struct de
int __pnp_add_device(struct pnp_dev *dev)
{
- int ret;
pnp_fixup_device(dev);
dev->dev.bus = &pnp_bus_type;
dev->dev.release = &pnp_release_device;
@@ -120,11 +119,7 @@ int __pnp_add_device(struct pnp_dev *dev
list_add_tail(&dev->global_list, &pnp_global);
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
spin_unlock(&pnp_lock);
-
- ret = device_register(&dev->dev);
- if (ret == 0)
- pnp_interface_attach_device(dev);
- return ret;
+ return device_register(&dev->dev);
}
/*
Index: linux-2.6.21/drivers/pnp/interface.c
===================================================================
--- linux-2.6.21.orig/drivers/pnp/interface.c
+++ linux-2.6.21/drivers/pnp/interface.c
@@ -233,9 +233,6 @@ static ssize_t pnp_show_options(struct d
return ret;
}
-static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL);
-
-
static ssize_t pnp_show_current_resources(struct device *dmdev, struct
device_attribute *attr, char *buf)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
@@ -441,9 +438,6 @@ pnp_set_current_resources(struct device
return count;
}
-static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR,
- pnp_show_current_resources,pnp_set_current_resources);
-
static ssize_t pnp_show_current_ids(struct device *dmdev, struct
device_attribute *attr, char *buf)
{
char *str = buf;
@@ -457,23 +451,11 @@ static ssize_t pnp_show_current_ids(stru
return (str - buf);
}
-static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
-
-int pnp_interface_attach_device(struct pnp_dev *dev)
-{
- int rc = device_create_file(&dev->dev,&dev_attr_options);
- if (rc) goto err;
- rc = device_create_file(&dev->dev,&dev_attr_resources);
- if (rc) goto err_opt;
- rc = device_create_file(&dev->dev,&dev_attr_id);
- if (rc) goto err_res;
-
- return 0;
-
-err_res:
- device_remove_file(&dev->dev,&dev_attr_resources);
-err_opt:
- device_remove_file(&dev->dev,&dev_attr_options);
-err:
- return rc;
-}
+struct device_attribute pnp_interface_attrs[] = {
+ __ATTR(resources, S_IRUGO | S_IWUSR,
+ pnp_show_current_resources,
+ pnp_set_current_resources),
+ __ATTR(options, S_IRUGO, pnp_show_options, NULL),
+ __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
+ __ATTR_NULL,
+};
Index: linux-2.6.21/drivers/pnp/driver.c
===================================================================
--- linux-2.6.21.orig/drivers/pnp/driver.c
+++ linux-2.6.21/drivers/pnp/driver.c
@@ -191,6 +191,7 @@ static int pnp_bus_resume(struct device
return 0;
}
+extern struct device_attribute pnp_interface_attrs[];
struct bus_type pnp_bus_type = {
.name = "pnp",
.match = pnp_bus_match,
@@ -198,6 +199,7 @@ struct bus_type pnp_bus_type = {
.remove = pnp_device_remove,
.suspend = pnp_bus_suspend,
.resume = pnp_bus_resume,
+ .dev_attrs = pnp_interface_attrs,
};
int pnp_register_driver(struct pnp_driver *drv)
next prev parent reply other threads:[~2008-09-24 19:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 21:24 [PATCH] Create PNP device attributes via dev_attrs field of struct device Drew Moseley
2008-09-24 4:59 ` Kay Sievers
2008-09-24 17:22 ` Drew Moseley
2008-09-24 19:03 ` Kay Sievers
2008-09-24 19:37 ` Drew Moseley [this message]
2008-09-25 10:13 ` Kay Sievers
2008-09-25 16:42 ` Drew Moseley
2008-09-27 23:31 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48DA9702.4020106@mvista.com \
--to=dmoseley@mvista.com \
--cc=ambx1@neo.rr.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox