From: tip-bot for Vivien Didelot <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
vivien.didelot@savoirfairelinux.com, hpa@zytor.com,
mingo@kernel.org, kernel@savoirfairelinux.com,
tglx@linutronix.de
Subject: [tip:x86/platform] x86/platform/ts5500: Use the DEVICE_ATTR_RO() macro
Date: Wed, 16 Jul 2014 12:45:29 -0700 [thread overview]
Message-ID: <tip-1d2408754d2c1376d67c00852548758e1ec2a94c@git.kernel.org> (raw)
In-Reply-To: <1404860269-11837-2-git-send-email-vivien.didelot@savoirfairelinux.com>
Commit-ID: 1d2408754d2c1376d67c00852548758e1ec2a94c
Gitweb: http://git.kernel.org/tip/1d2408754d2c1376d67c00852548758e1ec2a94c
Author: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
AuthorDate: Tue, 8 Jul 2014 18:57:47 -0400
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 16 Jul 2014 21:17:40 +0200
x86/platform/ts5500: Use the DEVICE_ATTR_RO() macro
Use the DEVICE_ATTR_RO() helper macro to simplify the declaration
of read-only sysfs attributes in the TS5500 code..
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Savoir-faire Linux Inc. <kernel@savoirfairelinux.com>
Link: http://lkml.kernel.org/r/1404860269-11837-2-git-send-email-vivien.didelot@savoirfairelinux.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/platform/ts5500/ts5500.c | 50 +++++++++++++++++----------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
index 9471b94..1bbf17b 100644
--- a/arch/x86/platform/ts5500/ts5500.c
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -147,45 +147,39 @@ cleanup:
return ret;
}
-static ssize_t ts5500_show_id(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t id_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct ts5500_sbc *sbc = dev_get_drvdata(dev);
return sprintf(buf, "0x%.2x\n", sbc->id);
}
+static DEVICE_ATTR_RO(id);
-static ssize_t ts5500_show_jumpers(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t jumpers_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct ts5500_sbc *sbc = dev_get_drvdata(dev);
return sprintf(buf, "0x%.2x\n", sbc->jumpers >> 1);
}
-
-#define TS5500_SHOW(field) \
- static ssize_t ts5500_show_##field(struct device *dev, \
- struct device_attribute *attr, \
- char *buf) \
- { \
- struct ts5500_sbc *sbc = dev_get_drvdata(dev); \
- return sprintf(buf, "%d\n", sbc->field); \
- }
-
-TS5500_SHOW(sram)
-TS5500_SHOW(rs485)
-TS5500_SHOW(adc)
-TS5500_SHOW(ereset)
-TS5500_SHOW(itr)
-
-static DEVICE_ATTR(id, S_IRUGO, ts5500_show_id, NULL);
-static DEVICE_ATTR(jumpers, S_IRUGO, ts5500_show_jumpers, NULL);
-static DEVICE_ATTR(sram, S_IRUGO, ts5500_show_sram, NULL);
-static DEVICE_ATTR(rs485, S_IRUGO, ts5500_show_rs485, NULL);
-static DEVICE_ATTR(adc, S_IRUGO, ts5500_show_adc, NULL);
-static DEVICE_ATTR(ereset, S_IRUGO, ts5500_show_ereset, NULL);
-static DEVICE_ATTR(itr, S_IRUGO, ts5500_show_itr, NULL);
+static DEVICE_ATTR_RO(jumpers);
+
+#define TS5500_ATTR_BOOL(_field) \
+ static ssize_t _field##_show(struct device *dev, \
+ struct device_attribute *attr, char *buf) \
+ { \
+ struct ts5500_sbc *sbc = dev_get_drvdata(dev); \
+ \
+ return sprintf(buf, "%d\n", sbc->_field); \
+ } \
+ static DEVICE_ATTR_RO(_field)
+
+TS5500_ATTR_BOOL(sram);
+TS5500_ATTR_BOOL(rs485);
+TS5500_ATTR_BOOL(adc);
+TS5500_ATTR_BOOL(ereset);
+TS5500_ATTR_BOOL(itr);
static struct attribute *ts5500_attributes[] = {
&dev_attr_id.attr,
next prev parent reply other threads:[~2014-07-16 19:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-08 22:57 [PATCH 0/3] Add support for Technologic Systems TS-5400 Vivien Didelot
2014-07-08 22:57 ` [PATCH 1/3] x86: (ts5500) use DEVICE_ATTR_RO macro Vivien Didelot
2014-07-16 19:45 ` tip-bot for Vivien Didelot [this message]
2014-07-08 22:57 ` [PATCH 2/3] x86: (ts5500) add a name attribute Vivien Didelot
2014-07-16 19:45 ` [tip:x86/platform] x86/platform/ts5500: Add a 'name' sysfs attribute tip-bot for Vivien Didelot
2014-07-08 22:57 ` [PATCH 3/3] x86: (ts5500) add support for TS-5400 Vivien Didelot
2014-07-16 19:45 ` [tip:x86/platform] x86/platform/ts5500: Add support for TS-5400 boards tip-bot for Vivien Didelot
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=tip-1d2408754d2c1376d67c00852548758e1ec2a94c@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@zytor.com \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=vivien.didelot@savoirfairelinux.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