[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231009165741.746184-4-max.kellermann@ionos.com>
Date: Mon, 9 Oct 2023 18:57:37 +0200
From: Max Kellermann <max.kellermann@...os.com>
To: William Breathitt Gray <william.gray@...aro.org>
Cc: Max Kellermann <max.kellermann@...os.com>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 4/7] drivers/counter: add local variable for newly allocated attribute_group**
This allows the compiler to keep the pointer in a register and
prepares for making the struct field "const".
Signed-off-by: Max Kellermann <max.kellermann@...os.com>
---
drivers/counter/counter-sysfs.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
index 42c523343d32..47e1e2c61cf0 100644
--- a/drivers/counter/counter-sysfs.c
+++ b/drivers/counter/counter-sysfs.c
@@ -1122,6 +1122,7 @@ int counter_sysfs_add(struct counter_device *const counter)
struct counter_attribute_group *cattr_groups;
size_t i, j;
int err;
+ const struct attribute_group **dev_groups;
struct attribute_group *groups;
struct counter_attribute *p;
@@ -1141,9 +1142,9 @@ int counter_sysfs_add(struct counter_device *const counter)
return err;
/* Allocate attribute group pointers for association with device */
- dev->groups = devm_kcalloc(dev, num_groups + 1, sizeof(*dev->groups),
+ dev->groups = dev_groups = devm_kcalloc(dev, num_groups + 1, sizeof(*dev_groups),
GFP_KERNEL);
- if (!dev->groups)
+ if (!dev_groups)
return -ENOMEM;
/* Allocate space for attribute groups */
@@ -1169,7 +1170,7 @@ int counter_sysfs_add(struct counter_device *const counter)
groups[i].attrs[j++] = &p->dev_attr.attr;
/* Associate attribute group */
- dev->groups[i] = &groups[i];
+ dev_groups[i] = &groups[i];
}
return 0;
--
2.39.2
Powered by blists - more mailing lists