Skip to contentSkip to conversation

PNP: use DEVICE_ATTR_RO macro

PATCH Applied Zhen Lei 2 participants 2 messages Jun 2, 2021 – Jun 7, 2021

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 PNP: use DEVICE_ATTR_RO macro

Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which makes the code a bit shorter and easier to read.

---
 drivers/pnp/card.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pnp/card.c +6 -6
index 2430c14f472d26a..d40ed8621571b0a 100644
@@ -181,8 +181,8 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnp
 	return card;
 }
 
-static ssize_t pnp_show_card_name(struct device *dmdev,
-				  struct device_attribute *attr, char *buf)
+static ssize_t name_show(struct device *dmdev,
+			 struct device_attribute *attr, char *buf)
 {
 	char *str = buf;
 	struct pnp_card *card = to_pnp_card(dmdev);
@@ -191,10 +191,10 @@ static ssize_t pnp_show_card_name(struct device *dmdev,
 	return (str - buf);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
+static DEVICE_ATTR_RO(name);
 
-static ssize_t pnp_show_card_ids(struct device *dmdev,
-				 struct device_attribute *attr, char *buf)
+static ssize_t card_id_show(struct device *dmdev,
+			    struct device_attribute *attr, char *buf)
 {
 	char *str = buf;
 	struct pnp_card *card = to_pnp_card(dmdev);
@@ -207,7 +207,7 @@ static ssize_t pnp_show_card_ids(struct device *dmdev,
 	return (str - buf);
 }
 
-static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
+static DEVICE_ATTR_RO(card_id);
 
 static int pnp_interface_attach_card(struct pnp_card *card)
 {
Signature · 1 line
2.26.0.106.g9fadedd
maintainer Applied
#1 lore raw
Quoted 39 lines · Zhen Lei

Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which makes the code a bit shorter and easier to read.

---
 drivers/pnp/card.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pnp/card.c +5 -5
index 2430c14f472d26a..d40ed8621571b0a 100644
@@ -181,8 +181,8 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnp
        return card;
 }
 
-static ssize_t pnp_show_card_name(struct device *dmdev,
-                                 struct device_attribute *attr, char *buf)
+static ssize_t name_show(struct device *dmdev,
+                        struct device_attribute *attr, char *buf)
 {
        char *str = buf;
        struct pnp_card *card = to_pnp_card(dmdev);
@@ -191,10 +191,10 @@ static ssize_t pnp_show_card_name(struct device *dmdev,
        return (str - buf);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
+static DEVICE_ATTR_RO(name);
 
-static ssize_t pnp_show_card_ids(struct device *dmdev,
-                                struct device_attribute *attr, char *buf)
+static ssize_t card_id_show(struct device *dmdev,
+                           struct device_attribute *attr, char *buf)
 {
        char *str = buf;
        struct pnp_card *card = to_pnp_card(dmdev);

drivers/pnp/card.c static ssize_t pnp_show_card_ids(struct device *dmdev,

Quoted 9 lines
drivers/pnp/card.c +1 -2
@@ -207,7 +207,7 @@ static ssize_t pnp_show_card_ids(struct device *dmdev,
        return (str - buf);
 }
 
-static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
+static DEVICE_ATTR_RO(card_id);
 
 static int pnp_interface_attach_card(struct pnp_card *card)
 {
--

Applied as 5.14 material, thanks!