From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] i2c: i2c-dev: Create 'name' attribute automatically
Date: Wed, 25 Sep 2013 22:20:35 +0200 [thread overview]
Message-ID: <20130925202035.GB4290@katana> (raw)
In-Reply-To: <1377966619-20197-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1644 bytes --]
On Sat, Aug 31, 2013 at 09:30:19AM -0700, Guenter Roeck wrote:
> The 'name' attribute is needed for all i2c-dev class devices, meaning
> it can be created automatically by pointing to it in the class data
> structure. This simplifies the code and reduces the probability for race
> conditions.
What race condition?
>
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
> ---
> drivers/i2c/i2c-dev.c | 32 ++++++++++++++++----------------
> 1 file changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
> index c3ccdea..46eea02 100644
> --- a/drivers/i2c/i2c-dev.c
> +++ b/drivers/i2c/i2c-dev.c
> @@ -111,7 +111,11 @@ static ssize_t show_adapter_name(struct device *dev,
> return -ENODEV;
> return sprintf(buf, "%s\n", i2c_dev->adap->name);
> }
> -static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
> +
> +static struct device_attribute i2c_dev_attributes[] = {
> + __ATTR(name, S_IRUGO, show_adapter_name, NULL),
> + { }
> +};
>
> /* ------------------------------------------------------------------------- */
>
> @@ -538,7 +542,11 @@ static const struct file_operations i2cdev_fops = {
>
> /* ------------------------------------------------------------------------- */
>
> -static struct class *i2c_dev_class;
> +static struct class i2c_dev_class = {
> + .owner = THIS_MODULE,
> + .name = "i2c-dev",
> + .dev_attrs = i2c_dev_attributes,
> +};
Have you tried this with two instances? I don't think it will work since
class_register modifies the class struct.
Regards,
Wolfram
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-09-25 20:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-31 16:30 [PATCH] i2c: i2c-dev: Create 'name' attribute automatically Guenter Roeck
[not found] ` <1377966619-20197-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-09-25 20:20 ` Wolfram Sang [this message]
2013-09-25 21:11 ` Guenter Roeck
2013-09-26 8:28 ` Wolfram Sang
2013-09-26 10:37 ` Guenter Roeck
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=20130925202035.GB4290@katana \
--to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).