login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
September
»
24
Re: [PATCH] Create PNP device attributes via dev_attrs field of struct device
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Kay Sievers
Subject:
Re: [PATCH] Create PNP device attributes via dev_attrs field of struct device
Date: Tuesday, September 23, 2008 - 9:59 pm
On Tue, Sep 23, 2008 at 14:24, Drew Moseley <dmoseley@mvista.com> wrote:
quoted text
> I have seen an issue where the sysfs entries for a PNP device are > created nonatomically resulting in a race condition with freedesktop > HAL. The patch below is my first attempt at addressing this by creating > the device attributes as default bus attributes and allowing the > device_register() call to create them. Any nasty side effects I am not > addressing? Comments?
quoted text
> diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h > index 9fd7bb9..b07787f 100644 > --- a/drivers/pnp/base.h > +++ b/drivers/pnp/base.h > @@ -16,7 +16,7 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *, > int id, char *pnpid); > > int pnp_add_device(struct pnp_dev *dev); > struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); > -int pnp_interface_attach_device(struct pnp_dev *dev); > +void pnp_interface_attach_device(struct pnp_dev *dev); > > int pnp_add_card(struct pnp_card *card); > void pnp_remove_card(struct pnp_card *card); > diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c > index a411582..bcd49ba 100644 > --- a/drivers/pnp/core.c > +++ b/drivers/pnp/core.c > @@ -159,8 +159,6 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol > *protocol, int id, char *pnpid > > int __pnp_add_device(struct pnp_dev *dev) > { > - int ret; > - > pnp_fixup_device(dev); > dev->status = PNP_READY; > spin_lock(&pnp_lock); > @@ -168,12 +166,8 @@ int __pnp_add_device(struct pnp_dev *dev) > list_add_tail(&dev->protocol_list, &dev->protocol->devices); > spin_unlock(&pnp_lock); > > - ret = device_register(&dev->dev); > - if (ret) > - return ret; > - > pnp_interface_attach_device(dev); > - return 0; > + return device_register(&dev->dev); > } > > /* > diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c > index a876ecf..442684d 100644 > --- a/drivers/pnp/interface.c > +++ b/drivers/pnp/interface.c > @@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev, > 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) > @@ -420,9 +418,6 @@ done: > 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) > { > @@ -437,27 +432,16 @@ static ssize_t pnp_show_current_ids(struct device > *dmdev, > return (str - buf); > } > > -static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); > +static 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, > +}; > > -int pnp_interface_attach_device(struct pnp_dev *dev) > +void 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; > + dev->dev.bus->dev_attrs = pnp_interface_attrs;
Any reason not to assign it statically to pnp_bus_type at in drivers/pnp/driver.c?
quoted text
> }
Thanks, Kay --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] Create PNP device attributes via dev_attrs field o ...
, Drew Moseley
, (Tue Sep 23, 2:24 pm)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Kay Sievers
, (Tue Sep 23, 9:59 pm)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Drew Moseley
, (Wed Sep 24, 10:22 am)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Kay Sievers
, (Wed Sep 24, 12:03 pm)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Drew Moseley
, (Wed Sep 24, 12:37 pm)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Kay Sievers
, (Thu Sep 25, 3:13 am)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Drew Moseley
, (Thu Sep 25, 9:42 am)
Re: [PATCH] Create PNP device attributes via dev_attrs fie ...
, Kay Sievers
, (Sat Sep 27, 4:31 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
FUJITA Tomonori
Re: [Scst-devel] Integration of SCST in the mainstream Linux kernel
Ingo Molnar
Re: [RFC/RFT PATCH] sched: automated per tty task groups
Uwe Kleine-König
Re: [PATCH v2] ARM: allow, but warn, when issuing ioremap() on RAM
Josef Bacik
[PATCH] fallocate.2: add FALLOC_FL_PUNCH_HOLE flag definition
Andrew Morton
Re: [PATCH v3 0/4] Introduce hardware spinlock framework
git
:
Stefan Richter
Re: [kernel.org users] [RFD] On deprecating "git-foo" for builtins
Bert Wesarg
[TopGit PATCH v3 06/12] list_deps: accept -i/-w
Junio C Hamano
Re: [PATCH] Detached HEAD (experimental)
A Large Angry SCM
Re: [RFC] origin link for cherry-pick and revert
Petr Baudis
Re: PPC SHA-1 Updates in "pu"
git-commits-head
:
Linux Kernel Mailing List
libata: disable ATAPI AN by default
Linux Kernel Mailing List
ARM: 5905/1: ARM: Global ASID allocation on SMP
Linux Kernel Mailing List
misc: replace remaining __FUNCTION__ with __func__
Linux Kernel Mailing List
Disallow gcc versions 4.1.{0,1}
Linux Kernel Mailing List
timer: Try to survive timer callback preempt_count leak
linux-netdev
:
Arnaldo Carvalho de Melo
Re: [PATCH 06/37] dccp: Limit feature negotiation to connection setup phase
Gerrit Renker
[PATCH 1/5] dccp: Initialisation framework for feature negotiation
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
David Miller
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugins for negotiation
openbsd-misc
:
Boris Goldberg
Re: HP ProLiant DL320 v. Sun Fire V125
Stuart Henderson
Re: Kuro5hin: OpenBSD Founder Theo deRaadt Has Conflict of Interest With AMD
Darrin Chandler
Re: strange output on openbsd C code
Karel Kulhavy
Re: No Blob without Puffy
Nick Holland
Re: Install OpenBSD from USB ?
Colocation donated by:
Syndicate