Skip to contentSkip to conversation

PNP: constify driver name

PATCH Applied Corentin Labbe 2 participants 4 messages Mar 6, 2020 – Mar 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 PNP: constify driver name

struct pnp_driver has name set as char* instead of const char* like platform_driver, pci_driver, usb_driver, etc... Let's unify a bit by setting name as const char*.
Furthermore, all users of this structures set name from already const
data.

---
 include/linux/pnp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pnp.h +1 -1
index 3b12fd28af78..b18dca67253d 100644
@@ -379,7 +379,7 @@ struct pnp_id {
 };
 
 struct pnp_driver {
-	char *name;
+	const char *name;
 	const struct pnp_device_id *id_table;
 	unsigned int flags;
 	int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);
Signature · 1 line
2.24.1
#1 lore raw

PATCH 2/2 rtc: cmos: remove useless cast for driver_name

Now the pnp_driver name is "const char *", there are no need to cast driver_name.

---
 drivers/rtc/rtc-cmos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-cmos.c +1 -1
index fb13993fad31..bcc96ab7793f 100644
@@ -1346,7 +1346,7 @@ static const struct pnp_device_id rtc_ids[] = {
 MODULE_DEVICE_TABLE(pnp, rtc_ids);
 
 static struct pnp_driver cmos_pnp_driver = {
-	.name		= (char *) driver_name,
+	.name		= driver_name,
 	.id_table	= rtc_ids,
 	.probe		= cmos_pnp_probe,
 	.remove		= cmos_pnp_remove,
Signature · 1 line
2.24.1
#2 lore raw
In reply to Corentin Labbe
Quoted 15 lines · Corentin Labbe

struct pnp_driver has name set as char* instead of const char* like platform_driver, pci_driver, usb_driver, etc... Let's unify a bit by setting name as const char*.
Furthermore, all users of this structures set name from already const
data.

---
  include/linux/pnp.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pnp.h +0 -0
index 3b12fd28af78..b18dca67253d 100644

include/linux/pnp.h struct pnp_id { · line 385

Quoted 8 lines
include/linux/pnp.h +1 -1
@@ -379,7 +379,7 @@ struct pnp_id {
  };
 
  struct pnp_driver {
-	char *name;
+	const char *name;
  	const struct pnp_device_id *id_table;
  	unsigned int flags;
  	int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);

Applied as 5.7 material along with the [2/2].

BTW, please CC PNP patches to linux-acpi in the future.

#3 lore raw
Quoted 27 lines · Rafael J. Wysocki
Quoted 15 lines · Corentin Labbe

struct pnp_driver has name set as char* instead of const char* like platform_driver, pci_driver, usb_driver, etc... Let's unify a bit by setting name as const char*.
Furthermore, all users of this structures set name from already const
data.

---
  include/linux/pnp.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pnp.h +0 -0
index 3b12fd28af78..b18dca67253d 100644

include/linux/pnp.h struct pnp_id { · line 385

Quoted 8 lines
include/linux/pnp.h +1 -1
@@ -379,7 +379,7 @@ struct pnp_id {
  };
 
  struct pnp_driver {
-	char *name;
+	const char *name;
  	const struct pnp_device_id *id_table;
  	unsigned int flags;
  	int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);

Applied as 5.7 material along with the [2/2].

Quoted 2 lines

BTW, please CC PNP patches to linux-acpi in the future.

Perhaps it is better to update MAINTAINERS ?
I will send a patch for it.