From: Ma Jun <Jun.Ma2@amd.com>
To: <jdelvare@suse.com>, <linux@roeck-us.net>,
<linux-hwmon@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Ma Jun <Jun.Ma2@amd.com>
Subject: [PATCH] hwmon: Add a new macro sensor_sysfs_attr
Date: Thu, 9 Nov 2023 13:14:29 +0800 [thread overview]
Message-ID: <20231109051429.2250774-1-Jun.Ma2@amd.com> (raw)
The attribute definiations like &sensor_dev_attr_xx_xx.dev_attr.attr
are widely used in drivers. So add a new macro sensor_sysfs_attr t
to make it easier to understand and use.
For example, user can use the sensor_sysfs_attr(xx_xx) instead of
&sensor_dev_attr_xx_xx.dev_attr.attr
Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
---
include/linux/hwmon-sysfs.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
index d896713359cd..7feae637e3b5 100644
--- a/include/linux/hwmon-sysfs.h
+++ b/include/linux/hwmon-sysfs.h
@@ -14,6 +14,10 @@ struct sensor_device_attribute{
struct device_attribute dev_attr;
int index;
};
+
+#define to_sensor_sysfs_attr(_name) \
+ (&sensor_dev_attr_##_name.dev_attr.attr)
+
#define to_sensor_dev_attr(_dev_attr) \
container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
--
2.34.1
next reply other threads:[~2023-11-09 5:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 5:14 Ma Jun [this message]
2023-11-09 5:28 ` Guenter Roeck
2023-11-10 1:15 ` Ma, Jun
2023-11-10 2:50 ` 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=20231109051429.2250774-1-Jun.Ma2@amd.com \
--to=jun.ma2@amd.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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
all inboxes | Powered by JetHome®