linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/7] drivers/counter: add local variable for newly allocated attribute_group**
       [not found] <20231009165741.746184-1-max.kellermann@ionos.com>
@ 2023-10-09 16:57 ` Max Kellermann
  2023-10-09 17:28   ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Max Kellermann @ 2023-10-09 16:57 UTC (permalink / raw)
  To: William Breathitt Gray; +Cc: Max Kellermann, linux-iio, linux-kernel

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@ionos.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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4/7] drivers/counter: add local variable for newly allocated attribute_group**
  2023-10-09 16:57 ` [PATCH 4/7] drivers/counter: add local variable for newly allocated attribute_group** Max Kellermann
@ 2023-10-09 17:28   ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-10-09 17:28 UTC (permalink / raw)
  To: Max Kellermann; +Cc: William Breathitt Gray, linux-iio, linux-kernel

On Mon, Oct 09, 2023 at 06:57:37PM +0200, Max Kellermann wrote:
> This allows the compiler to keep the pointer in a register and
> prepares for making the struct field "const".

Again, nothing about registers makes sense here.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-09 17:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20231009165741.746184-1-max.kellermann@ionos.com>
2023-10-09 16:57 ` [PATCH 4/7] drivers/counter: add local variable for newly allocated attribute_group** Max Kellermann
2023-10-09 17:28   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).