[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210602073820.11011-7-thunder.leizhen@huawei.com>
Date: Wed, 2 Jun 2021 15:38:18 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Alessandro Zummo <a.zummo@...ertech.it>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Joshua Kinard <kumba@...too.org>,
"Linus Walleij" <linus.walleij@...aro.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
linux-rtc <linux-rtc@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
CC: Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 6/8] rtc: ds1343: use DEVICE_ATTR_* macro
Use DEVICE_ATTR_* macro helper instead of plain DEVICE_ATTR, which makes
the code a bit shorter and easier to read.
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
drivers/rtc/rtc-ds1343.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index f14ed6c96437b44..ffabb8b69e6d8e6 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -80,8 +80,8 @@ struct ds1343_priv {
int irq;
};
-static ssize_t ds1343_show_glitchfilter(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t glitch_filter_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int glitch_filt_status, data;
@@ -99,9 +99,9 @@ static ssize_t ds1343_show_glitchfilter(struct device *dev,
return sprintf(buf, "disabled\n");
}
-static ssize_t ds1343_store_glitchfilter(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
+static ssize_t glitch_filter_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int data = 0;
@@ -120,8 +120,7 @@ static ssize_t ds1343_store_glitchfilter(struct device *dev,
return count;
}
-static DEVICE_ATTR(glitch_filter, S_IRUGO | S_IWUSR, ds1343_show_glitchfilter,
- ds1343_store_glitchfilter);
+static DEVICE_ATTR_RW(glitch_filter);
static int ds1343_nvram_write(void *priv, unsigned int off, void *val,
size_t bytes)
@@ -139,8 +138,8 @@ static int ds1343_nvram_read(void *priv, unsigned int off, void *val,
return regmap_bulk_read(ds1343->map, DS1343_NVRAM + off, val, bytes);
}
-static ssize_t ds1343_show_tricklecharger(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t trickle_charger_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int res, data;
@@ -183,7 +182,7 @@ static ssize_t ds1343_show_tricklecharger(struct device *dev,
return sprintf(buf, "%s %s\n", diodes, resistors);
}
-static DEVICE_ATTR(trickle_charger, S_IRUGO, ds1343_show_tricklecharger, NULL);
+static DEVICE_ATTR_RO(trickle_charger);
static struct attribute *ds1343_attrs[] = {
&dev_attr_glitch_filter.attr,
--
2.26.0.106.g9fadedd
Powered by blists - more mailing lists