From: Zhen Lei <thunder.leizhen@huawei.com> To: Alessandro Zummo <a.zummo@towertech.it>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Joshua Kinard <kumba@gentoo.org>, "Linus Walleij" <linus.walleij@linaro.org>, linux-arm-kernel <linux-arm-kernel@lists.infradead.org>, linux-rtc <linux-rtc@vger.kernel.org>, linux-kernel <linux-kernel@vger.kernel.org> Cc: Zhen Lei <thunder.leizhen@huawei.com> Subject: [PATCH 6/8] rtc: ds1343: use DEVICE_ATTR_* macro Date: Wed, 2 Jun 2021 15:38:18 +0800 [thread overview] Message-ID: <20210602073820.11011-7-thunder.leizhen@huawei.com> (raw) In-Reply-To: <20210602073820.11011-1-thunder.leizhen@huawei.com> 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@huawei.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
WARNING: multiple messages have this Message-ID (diff)
From: Zhen Lei <thunder.leizhen@huawei.com> To: Alessandro Zummo <a.zummo@towertech.it>, Alexandre Belloni <alexandre.belloni@bootlin.com>, Joshua Kinard <kumba@gentoo.org>, "Linus Walleij" <linus.walleij@linaro.org>, linux-arm-kernel <linux-arm-kernel@lists.infradead.org>, linux-rtc <linux-rtc@vger.kernel.org>, linux-kernel <linux-kernel@vger.kernel.org> Cc: Zhen Lei <thunder.leizhen@huawei.com> Subject: [PATCH 6/8] rtc: ds1343: use DEVICE_ATTR_* macro Date: Wed, 2 Jun 2021 15:38:18 +0800 [thread overview] Message-ID: <20210602073820.11011-7-thunder.leizhen@huawei.com> (raw) In-Reply-To: <20210602073820.11011-1-thunder.leizhen@huawei.com> 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@huawei.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-06-02 7:40 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-02 7:38 [PATCH 0/8] rtc: use DEVICE_ATTR_* macro to simplify code Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` [PATCH 1/8] rtc: x1205: use DEVICE_ATTR_RO macro Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` [PATCH 2/8] rtc: rx8025: use DEVICE_ATTR_RW macro Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` [PATCH 3/8] rtc: rs5c372: use DEVICE_ATTR_RO macro Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` [PATCH 4/8] rtc: isl1208: use DEVICE_ATTR_* macro Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` [PATCH 5/8] rtc: ds1685: use DEVICE_ATTR_RO macro Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` Zhen Lei [this message] 2021-06-02 7:38 ` [PATCH 6/8] rtc: ds1343: use DEVICE_ATTR_* macro Zhen Lei 2021-06-02 7:38 ` [PATCH 7/8] rtc: bq32k: use DEVICE_ATTR_RW macro Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-02 7:38 ` [PATCH 8/8] rtc: ab8500: " Zhen Lei 2021-06-02 7:38 ` Zhen Lei 2021-06-04 7:46 ` Linus Walleij 2021-06-04 7:46 ` Linus Walleij
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=20210602073820.11011-7-thunder.leizhen@huawei.com \ --to=thunder.leizhen@huawei.com \ --cc=a.zummo@towertech.it \ --cc=alexandre.belloni@bootlin.com \ --cc=kumba@gentoo.org \ --cc=linus.walleij@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-rtc@vger.kernel.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: linkBe 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.