* [PATCH 1/3] crypto: omap-aes - Constify static attribute_group
2022-02-10 20:28 [PATCH 0/3] drivers/crypto: Constify static attribute_group Rikard Falkeborn
@ 2022-02-10 20:28 ` Rikard Falkeborn
2022-02-10 20:28 ` [PATCH 2/3] crypto: omap-sham " Rikard Falkeborn
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2022-02-10 20:28 UTC (permalink / raw)
To: Herbert Xu, David S. Miller
Cc: linux-kernel, Rikard Falkeborn, Paul Mackerras, linux-crypto,
linuxppc-dev
The only usage of omap_aes_attr_group is to pass its address to
sysfs_{create,remove}_group(), which takes pointers to const struct
attribute_group. Make it const to allow the compiler to put it in
read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/crypto/omap-aes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index a196bb8b1701..581211a92628 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -1093,7 +1093,7 @@ static struct attribute *omap_aes_attrs[] = {
NULL,
};
-static struct attribute_group omap_aes_attr_group = {
+static const struct attribute_group omap_aes_attr_group = {
.attrs = omap_aes_attrs,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] crypto: omap-sham - Constify static attribute_group
2022-02-10 20:28 [PATCH 0/3] drivers/crypto: Constify static attribute_group Rikard Falkeborn
2022-02-10 20:28 ` [PATCH 1/3] crypto: omap-aes - " Rikard Falkeborn
@ 2022-02-10 20:28 ` Rikard Falkeborn
2022-02-10 20:28 ` [PATCH 3/3] crypto/nx: Constify static attribute_group structs Rikard Falkeborn
2022-02-18 5:37 ` [PATCH 0/3] drivers/crypto: Constify static attribute_group Herbert Xu
3 siblings, 0 replies; 6+ messages in thread
From: Rikard Falkeborn @ 2022-02-10 20:28 UTC (permalink / raw)
To: Herbert Xu, David S. Miller
Cc: linux-kernel, Rikard Falkeborn, Paul Mackerras, linux-crypto,
linuxppc-dev
The only usage of omap_sham_attr_group is to pass its address to
sysfs_{create,remove}_group(), which takes pointers to const struct
attribute_group. Make it const to allow the compiler to put it in
read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/crypto/omap-sham.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index f6bf53c00b61..4b37dc69a50c 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -2045,7 +2045,7 @@ static struct attribute *omap_sham_attrs[] = {
NULL,
};
-static struct attribute_group omap_sham_attr_group = {
+static const struct attribute_group omap_sham_attr_group = {
.attrs = omap_sham_attrs,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] crypto/nx: Constify static attribute_group structs
2022-02-10 20:28 [PATCH 0/3] drivers/crypto: Constify static attribute_group Rikard Falkeborn
2022-02-10 20:28 ` [PATCH 1/3] crypto: omap-aes - " Rikard Falkeborn
2022-02-10 20:28 ` [PATCH 2/3] crypto: omap-sham " Rikard Falkeborn
@ 2022-02-10 20:28 ` Rikard Falkeborn
2022-02-11 6:27 ` Daniel Axtens
2022-02-18 5:37 ` [PATCH 0/3] drivers/crypto: Constify static attribute_group Herbert Xu
3 siblings, 1 reply; 6+ messages in thread
From: Rikard Falkeborn @ 2022-02-10 20:28 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-crypto, Rikard Falkeborn, linux-kernel
The only usage of these is to pass their address to
sysfs_{create,remove}_group(), which takes pointers to const struct
attribute_group. Make them const to allow the compiler to put them in
read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/crypto/nx/nx-common-pseries.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
index 4e304f6081e4..7584a34ba88c 100644
--- a/drivers/crypto/nx/nx-common-pseries.c
+++ b/drivers/crypto/nx/nx-common-pseries.c
@@ -962,7 +962,7 @@ static struct attribute *nx842_sysfs_entries[] = {
NULL,
};
-static struct attribute_group nx842_attribute_group = {
+static const struct attribute_group nx842_attribute_group = {
.name = NULL, /* put in device directory */
.attrs = nx842_sysfs_entries,
};
@@ -992,7 +992,7 @@ static struct attribute *nxcop_caps_sysfs_entries[] = {
NULL,
};
-static struct attribute_group nxcop_caps_attr_group = {
+static const struct attribute_group nxcop_caps_attr_group = {
.name = "nx_gzip_caps",
.attrs = nxcop_caps_sysfs_entries,
};
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] crypto/nx: Constify static attribute_group structs
2022-02-10 20:28 ` [PATCH 3/3] crypto/nx: Constify static attribute_group structs Rikard Falkeborn
@ 2022-02-11 6:27 ` Daniel Axtens
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Axtens @ 2022-02-11 6:27 UTC (permalink / raw)
To: Rikard Falkeborn, Herbert Xu, David S. Miller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-crypto, Rikard Falkeborn, linux-kernel
Hi Rikard,
> The only usage of these is to pass their address to
> sysfs_{create,remove}_group(), which takes pointers to const struct
> attribute_group. Make them const to allow the compiler to put them in
> read-only memory.
I checked the file. Indeed, those structs are only used in
sysfs_{create,remove}_group. So I agree that they can be constified.
They also pass all the automated tests:
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220210202805.7750-4-rikard.falkeborn@gmail.com/
Reviewed-by: Daniel Axtens <dja@axtens.net>
Kind regards,
Daniel
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
> ---
> drivers/crypto/nx/nx-common-pseries.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
> index 4e304f6081e4..7584a34ba88c 100644
> --- a/drivers/crypto/nx/nx-common-pseries.c
> +++ b/drivers/crypto/nx/nx-common-pseries.c
> @@ -962,7 +962,7 @@ static struct attribute *nx842_sysfs_entries[] = {
> NULL,
> };
>
> -static struct attribute_group nx842_attribute_group = {
> +static const struct attribute_group nx842_attribute_group = {
> .name = NULL, /* put in device directory */
> .attrs = nx842_sysfs_entries,
> };
> @@ -992,7 +992,7 @@ static struct attribute *nxcop_caps_sysfs_entries[] = {
> NULL,
> };
>
> -static struct attribute_group nxcop_caps_attr_group = {
> +static const struct attribute_group nxcop_caps_attr_group = {
> .name = "nx_gzip_caps",
> .attrs = nxcop_caps_sysfs_entries,
> };
> --
> 2.35.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] drivers/crypto: Constify static attribute_group
2022-02-10 20:28 [PATCH 0/3] drivers/crypto: Constify static attribute_group Rikard Falkeborn
` (2 preceding siblings ...)
2022-02-10 20:28 ` [PATCH 3/3] crypto/nx: Constify static attribute_group structs Rikard Falkeborn
@ 2022-02-18 5:37 ` Herbert Xu
3 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2022-02-18 5:37 UTC (permalink / raw)
To: Rikard Falkeborn
Cc: linux-kernel, Paul Mackerras, linux-crypto, linuxppc-dev,
David S. Miller
On Thu, Feb 10, 2022 at 09:28:02PM +0100, Rikard Falkeborn wrote:
> This series constifies a couple of static attribute_group structs that
> are not modified. This allows the compiler to put them in read-only
> memory. The patches are independent and can be applied in any order (and
> go through different trees if needed).
>
> Rikard Falkeborn (3):
> crypto: omap-aes - Constify static attribute_group
> crypto: omap-sham - Constify static attribute_group
> crypto/nx: Constify static attribute_group structs
>
> drivers/crypto/nx/nx-common-pseries.c | 4 ++--
> drivers/crypto/omap-aes.c | 2 +-
> drivers/crypto/omap-sham.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread