From: Guenter Roeck <linux@roeck-us.net>
To: Pawel Moll <pawel.moll@arm.com>
Cc: arm@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Jean Delvare <jdelvare@suse.de>,
lm-sensors@lm-sensors.org
Subject: Re: [PATCH 09/12] hwmon: vexpress: Use devm helper for hwmon device registration
Date: Tue, 11 Feb 2014 18:49:04 -0800 [thread overview]
Message-ID: <20140212024904.GA19352@roeck-us.net> (raw)
On Tue, Feb 11, 2014 at 05:10:33PM +0000, Pawel Moll wrote:
> Use devm_hwmon_device_register_with_groups instead of
> the old-style manual attributes and hwmon device registration.
>
[ ... ]
> static int vexpress_hwmon_probe(struct platform_device *pdev)
> {
> - int err;
> const struct of_device_id *match;
> struct vexpress_hwmon_data *data;
> + const char *name;
> + const struct attribute_group **groups;
>
> data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> @@ -176,42 +151,19 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
> return -ENODEV;
>
There is a leftover platform_set_drvdata() above which you can remove;
attributes are now attached to the hwmon device and no longer
to the platform device.
>
> - match = of_match_device(vexpress_hwmon_of_match, &pdev->dev);
> - sysfs_remove_group(&pdev->dev.kobj, match->data);
> + name = of_get_property(pdev->dev.of_node, "compatible", NULL);
Couple of problems, two of which escaped me earlier.
First, can of_get_property ever return NULL ? I think not, just wondering.
Second is a real problem. You have a '-' in the compatible property which is
illegal for the 'name' attribute in hwmon devices. It messes up libsensors
and thus every application using it. Not sure what a good fix (or name)
would be; simplest might be to copy the name string and replace it with '_'.
Sorry for not noticing this earlier; it might actually make sense to submit
a separate patch to address this so we can apply it to the current kernel
and if necessary patch it into earlier kernels.
Third, I noticed that the 'label' attribute is always created but returns
-ENOENT if there is no label. A much better implementation would be to use
.is_visible and not create the label attribute if its devicetree entry
does not exist. I don't know how libsensors reacts to -ENOENT on a read,
but no matter how it does react, it is pretty much undefined.
Again, that should be handled in a separate patch.
I agree with Arnd that it would be nice to get rid of the local macro,
but I won't mandate that.
Thanks,
Guenter
next reply other threads:[~2014-02-12 2:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 2:49 Guenter Roeck [this message]
2014-02-12 11:56 ` [PATCH 09/12] hwmon: vexpress: Use devm helper for hwmon device registration Pawel Moll
2014-02-12 11:59 ` Pawel Moll
2014-02-12 16:41 ` Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2014-02-11 17:10 [PATCH 00/12] Versatile Express updates Pawel Moll
2014-02-11 17:10 ` [PATCH 09/12] hwmon: vexpress: Use devm helper for hwmon device registration Pawel Moll
2014-02-11 20:57 ` Arnd Bergmann
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=20140212024904.GA19352@roeck-us.net \
--to=linux@roeck-us.net \
--cc=arm@kernel.org \
--cc=jdelvare@suse.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=pawel.moll@arm.com \
/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