From: "Pali Rohár" <pali@kernel.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] mmc: sdio: Extend sdio_config_attr macro and use it also for modalias
Date: Mon, 27 Jul 2020 15:38:36 +0200 [thread overview]
Message-ID: <20200727133837.19086-4-pali@kernel.org> (raw)
In-Reply-To: <20200727133837.19086-1-pali@kernel.org>
This simplify code for generating sdio config attributes and allows easily
define new sdio attributes.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
drivers/mmc/core/sdio_bus.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 3cc928282af7..2384829c8fb2 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -28,29 +28,21 @@
#define to_sdio_driver(d) container_of(d, struct sdio_driver, drv)
/* show configuration fields */
-#define sdio_config_attr(field, format_string) \
+#define sdio_config_attr(field, format_string, args...) \
static ssize_t \
field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
struct sdio_func *func; \
\
func = dev_to_sdio_func (dev); \
- return sprintf (buf, format_string, func->field); \
+ return sprintf(buf, format_string, args); \
} \
static DEVICE_ATTR_RO(field)
-sdio_config_attr(class, "0x%02x\n");
-sdio_config_attr(vendor, "0x%04x\n");
-sdio_config_attr(device, "0x%04x\n");
-
-static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct sdio_func *func = dev_to_sdio_func (dev);
-
- return sprintf(buf, "sdio:c%02Xv%04Xd%04X\n",
- func->class, func->vendor, func->device);
-}
-static DEVICE_ATTR_RO(modalias);
+sdio_config_attr(class, "0x%02x\n", func->class);
+sdio_config_attr(vendor, "0x%04x\n", func->vendor);
+sdio_config_attr(device, "0x%04x\n", func->device);
+sdio_config_attr(modalias, "sdio:c%02Xv%04Xd%04X\n", func->class, func->vendor, func->device);
static struct attribute *sdio_dev_attrs[] = {
&dev_attr_class.attr,
--
2.20.1
next prev parent reply other threads:[~2020-07-27 13:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-27 13:38 [PATCH 0/4] mmc: sdio: Export CISTPL_VERS_1 attributes to userspace Pali Rohár
2020-07-27 13:38 ` [PATCH 1/4] mmc: sdio: Check for CISTPL_VERS_1 buffer size Pali Rohár
2020-07-27 13:38 ` [PATCH 2/4] mmc: sdio: Parse CISTPL_VERS_1 major and minor revision numbers Pali Rohár
2020-07-27 13:38 ` Pali Rohár [this message]
2020-07-27 13:38 ` [PATCH 4/4] mmc: sdio: Export SDIO revision and info strings to userspace Pali Rohár
2020-08-22 9:41 ` [PATCH 0/4] mmc: sdio: Export CISTPL_VERS_1 attributes " Pali Rohár
2020-08-24 6:35 ` Ulf Hansson
2020-08-24 9:50 ` Ulf Hansson
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=20200727133837.19086-4-pali@kernel.org \
--to=pali@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.