Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] iio: accel: mma8452: Constify static struct attribute_group
@ 2020-09-30 23:29 Rikard Falkeborn
  2020-10-10 17:05 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Rikard Falkeborn @ 2020-09-30 23:29 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Alexandru Ardelean,
	linux-iio, linux-kernel, Rikard Falkeborn

The only usage of mma8452_event_attribute_group is to assign its address
to the event_attrs field in the iio_info struct, which is a const
pointer. Make it const to allow the compiler to put it in read-only
memory. This was the only non-const static struct in drivers/iio.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/iio/accel/mma8452.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index bf1d2c8afdbd..b0176d936423 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1187,7 +1187,7 @@ static struct attribute *mma8452_event_attributes[] = {
 	NULL,
 };
 
-static struct attribute_group mma8452_event_attribute_group = {
+static const struct attribute_group mma8452_event_attribute_group = {
 	.attrs = mma8452_event_attributes,
 };
 
-- 
2.28.0


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

* Re: [PATCH] iio: accel: mma8452: Constify static struct attribute_group
  2020-09-30 23:29 [PATCH] iio: accel: mma8452: Constify static struct attribute_group Rikard Falkeborn
@ 2020-10-10 17:05 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-10-10 17:05 UTC (permalink / raw)
  To: Rikard Falkeborn
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Alexandru Ardelean,
	linux-iio, linux-kernel

On Thu,  1 Oct 2020 01:29:39 +0200
Rikard Falkeborn <rikard.falkeborn@gmail.com> wrote:

> The only usage of mma8452_event_attribute_group is to assign its address
> to the event_attrs field in the iio_info struct, which is a const
> pointer. Make it const to allow the compiler to put it in read-only
> memory. This was the only non-const static struct in drivers/iio.
> 
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
applied.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/mma8452.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index bf1d2c8afdbd..b0176d936423 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1187,7 +1187,7 @@ static struct attribute *mma8452_event_attributes[] = {
>  	NULL,
>  };
>  
> -static struct attribute_group mma8452_event_attribute_group = {
> +static const struct attribute_group mma8452_event_attribute_group = {
>  	.attrs = mma8452_event_attributes,
>  };
>  


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 23:29 [PATCH] iio: accel: mma8452: Constify static struct attribute_group Rikard Falkeborn
2020-10-10 17:05 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git