linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] power: supply: Constify static struct attribute_group
@ 2021-01-13 20:32 Rikard Falkeborn
  2021-01-13 20:32 ` [PATCH 1/2] power: supply: ltc4162-l: " Rikard Falkeborn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-01-13 20:32 UTC (permalink / raw)
  To: Sebastian Reichel, Mike Looijmans
  Cc: linux-pm, linux-kernel, Rikard Falkeborn

Constify two static struct attribute_group. The only place they are
used is to put their address in an array of pointers to const struct
attribute_group. With these patches applied, all static attribute_group
structs in drivers/power are const.

Rikard Falkeborn (2):
  power: supply: ltc4162-l: Constify static struct attribute_group
  power: supply: core: Constify static struct attribute_group

 drivers/power/supply/ltc4162-l-charger.c  | 2 +-
 drivers/power/supply/power_supply_sysfs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.30.0


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

* [PATCH 1/2] power: supply: ltc4162-l: Constify static struct attribute_group
  2021-01-13 20:32 [PATCH 0/2] power: supply: Constify static struct attribute_group Rikard Falkeborn
@ 2021-01-13 20:32 ` Rikard Falkeborn
  2021-01-13 20:32 ` [PATCH 2/2] power: supply: core: " Rikard Falkeborn
  2021-01-13 21:19 ` [PATCH 0/2] power: supply: " Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-01-13 20:32 UTC (permalink / raw)
  To: Sebastian Reichel, Mike Looijmans
  Cc: linux-pm, linux-kernel, Rikard Falkeborn

The only usage of it is to put its address in an array of pointers to
const static structs. Make it const to allow the compiler to put it in
read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/power/supply/ltc4162-l-charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/ltc4162-l-charger.c b/drivers/power/supply/ltc4162-l-charger.c
index cded6484febb..1a5cb4405ee3 100644
--- a/drivers/power/supply/ltc4162-l-charger.c
+++ b/drivers/power/supply/ltc4162-l-charger.c
@@ -666,7 +666,7 @@ static struct attribute *ltc4162l_sysfs_entries[] = {
 	NULL,
 };
 
-static struct attribute_group ltc4162l_attr_group = {
+static const struct attribute_group ltc4162l_attr_group = {
 	.name	= NULL,	/* put in device directory */
 	.attrs	= ltc4162l_sysfs_entries,
 };
-- 
2.30.0


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

* [PATCH 2/2] power: supply: core: Constify static struct attribute_group
  2021-01-13 20:32 [PATCH 0/2] power: supply: Constify static struct attribute_group Rikard Falkeborn
  2021-01-13 20:32 ` [PATCH 1/2] power: supply: ltc4162-l: " Rikard Falkeborn
@ 2021-01-13 20:32 ` Rikard Falkeborn
  2021-01-13 21:19 ` [PATCH 0/2] power: supply: " Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2021-01-13 20:32 UTC (permalink / raw)
  To: Sebastian Reichel, Mike Looijmans
  Cc: linux-pm, linux-kernel, Rikard Falkeborn

The only usage of it is to put its address in an array of pointers to
const static structs. Make it const to allow the compiler to put it in
read-only memory.

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

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 92dd63171193..c3d7cbcd4fad 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -374,7 +374,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj,
 	return 0;
 }
 
-static struct attribute_group power_supply_attr_group = {
+static const struct attribute_group power_supply_attr_group = {
 	.attrs = __power_supply_attrs,
 	.is_visible = power_supply_attr_is_visible,
 };
-- 
2.30.0


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

* Re: [PATCH 0/2] power: supply: Constify static struct attribute_group
  2021-01-13 20:32 [PATCH 0/2] power: supply: Constify static struct attribute_group Rikard Falkeborn
  2021-01-13 20:32 ` [PATCH 1/2] power: supply: ltc4162-l: " Rikard Falkeborn
  2021-01-13 20:32 ` [PATCH 2/2] power: supply: core: " Rikard Falkeborn
@ 2021-01-13 21:19 ` Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2021-01-13 21:19 UTC (permalink / raw)
  To: Rikard Falkeborn; +Cc: Mike Looijmans, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

Hi,

On Wed, Jan 13, 2021 at 09:32:41PM +0100, Rikard Falkeborn wrote:
> Constify two static struct attribute_group. The only place they are
> used is to put their address in an array of pointers to const struct
> attribute_group. With these patches applied, all static attribute_group
> structs in drivers/power are const.

Thanks, I queued both to power-supply's for-next branch.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-01-13 21:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 20:32 [PATCH 0/2] power: supply: Constify static struct attribute_group Rikard Falkeborn
2021-01-13 20:32 ` [PATCH 1/2] power: supply: ltc4162-l: " Rikard Falkeborn
2021-01-13 20:32 ` [PATCH 2/2] power: supply: core: " Rikard Falkeborn
2021-01-13 21:19 ` [PATCH 0/2] power: supply: " Sebastian Reichel

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).