Skip to contentSkip to conversation

ACPI: bus: Drop two fields from struct acpi_device_pnp

PATCH In review Rafael J. Wysocki 3 participants 4 messages Aug 31 – Sep 1

Subsystems (3)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 ACPI: bus: Drop two fields from struct acpi_device_pnp

From: "Rafael J. Wysocki" <[email protected]>

There are two fields in struct acpi_device_pnp, device_name and device_class, that were supposed to be populated and used by device drivers, but they have never been used consistently and now they are only set for the bus object in acpi_set_pnp_ids() (and never read afterward).

Drop them along with all of the associated symbols except for MAX_ACPI_CLASS_NAME_LEN and the acpi_device_class typedef that are used by the ACPI netlink messaging code. Move those two definitions closer to the struct acpi_bus_event that refers to the acpi_device_class type.

No intentional functional impact.

---
 drivers/acpi/scan.c     |    4 ----
 include/acpi/acpi_bus.h |   11 +++--------
 2 files changed, 3 insertions(+), 12 deletions(-)
drivers/acpi/scan.c +0 -4
@@ -28,9 +28,7 @@
 #include "internal.h"
 #include "sleep.h"
 
-#define ACPI_BUS_CLASS			"system_bus"
 #define ACPI_BUS_HID			"LNXSYBUS"
-#define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 #define INVALID_ACPI_HANDLE	((acpi_handle)ZERO_PAGE(0))
 
@@ -1446,8 +1444,6 @@ static void acpi_set_pnp_ids(acpi_handle
 			 acpi_object_is_system_bus(handle)) {
 			/* \_SB, \_TZ, LNXSYBUS */
 			acpi_add_id(pnp, ACPI_BUS_HID);
-			strscpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
-			strscpy(pnp->device_class, ACPI_BUS_CLASS);
 		}
 
 		break;
include/acpi/acpi_bus.h +3 -8
@@ -206,12 +206,8 @@ struct acpi_device_dir {
 
 /* Plug and Play */
 
-#define MAX_ACPI_DEVICE_NAME_LEN	40
-#define MAX_ACPI_CLASS_NAME_LEN		20
 typedef char acpi_bus_id[8];
 typedef u64 acpi_bus_address;
-typedef char acpi_device_name[MAX_ACPI_DEVICE_NAME_LEN];
-typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
 
 struct acpi_hardware_id {
 	struct list_head list;
@@ -233,16 +229,12 @@ struct acpi_device_pnp {
 	acpi_bus_address bus_address;	/* _ADR */
 	char *unique_id;		/* _UID */
 	struct list_head ids;		/* _HID and _CIDs */
-	acpi_device_name device_name;	/* Driver-determined */
-	acpi_device_class device_class;	/*        "          */
 };
 
 #define acpi_device_bid(d)	((d)->pnp.bus_id)
 #define acpi_device_adr(d)	((d)->pnp.bus_address)
 const char *acpi_device_hid(struct acpi_device *device);
 #define acpi_device_uid(d)	((d)->pnp.unique_id)
-#define acpi_device_name(d)	((d)->pnp.device_name)
-#define acpi_device_class(d)	((d)->pnp.device_class)
 
 /* Power Management */
 
@@ -582,6 +574,9 @@ int acpi_dev_for_each_child_reverse(stru
  * ------
  */
 
+#define MAX_ACPI_CLASS_NAME_LEN		20
+typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
+
 struct acpi_bus_event {
 	struct list_head node;
 	acpi_device_class device_class;
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 14 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

There are two fields in struct acpi_device_pnp, device_name and device_class, that were supposed to be populated and used by device drivers, but they have never been used consistently and now they are only set for the bus object in acpi_set_pnp_ids() (and never read afterward).

Drop them along with all of the associated symbols except for MAX_ACPI_CLASS_NAME_LEN and the acpi_device_class typedef that are used by the ACPI netlink messaging code. Move those two definitions closer to the struct acpi_bus_event that refers to the acpi_device_class type.

Quoted 3 lines

No intentional functional impact.

Nice :) Patch looks good to me:

Regards,

Hans

Quoted 71 lines
---
 drivers/acpi/scan.c     |    4 ----
 include/acpi/acpi_bus.h |   11 +++--------
 2 files changed, 3 insertions(+), 12 deletions(-)
drivers/acpi/scan.c +0 -4
@@ -28,9 +28,7 @@
 #include "internal.h"
 #include "sleep.h"
 
-#define ACPI_BUS_CLASS			"system_bus"
 #define ACPI_BUS_HID			"LNXSYBUS"
-#define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 #define INVALID_ACPI_HANDLE	((acpi_handle)ZERO_PAGE(0))
 
@@ -1446,8 +1444,6 @@ static void acpi_set_pnp_ids(acpi_handle
 			 acpi_object_is_system_bus(handle)) {
 			/* \_SB, \_TZ, LNXSYBUS */
 			acpi_add_id(pnp, ACPI_BUS_HID);
-			strscpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
-			strscpy(pnp->device_class, ACPI_BUS_CLASS);
 		}
 
 		break;
include/acpi/acpi_bus.h +3 -8
@@ -206,12 +206,8 @@ struct acpi_device_dir {
 
 /* Plug and Play */
 
-#define MAX_ACPI_DEVICE_NAME_LEN	40
-#define MAX_ACPI_CLASS_NAME_LEN		20
 typedef char acpi_bus_id[8];
 typedef u64 acpi_bus_address;
-typedef char acpi_device_name[MAX_ACPI_DEVICE_NAME_LEN];
-typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
 
 struct acpi_hardware_id {
 	struct list_head list;
@@ -233,16 +229,12 @@ struct acpi_device_pnp {
 	acpi_bus_address bus_address;	/* _ADR */
 	char *unique_id;		/* _UID */
 	struct list_head ids;		/* _HID and _CIDs */
-	acpi_device_name device_name;	/* Driver-determined */
-	acpi_device_class device_class;	/*        "          */
 };
 
 #define acpi_device_bid(d)	((d)->pnp.bus_id)
 #define acpi_device_adr(d)	((d)->pnp.bus_address)
 const char *acpi_device_hid(struct acpi_device *device);
 #define acpi_device_uid(d)	((d)->pnp.unique_id)
-#define acpi_device_name(d)	((d)->pnp.device_name)
-#define acpi_device_class(d)	((d)->pnp.device_class)
 
 /* Power Management */
 
@@ -582,6 +574,9 @@ int acpi_dev_for_each_child_reverse(stru
  * ------
  */
 
+#define MAX_ACPI_CLASS_NAME_LEN		20
+typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
+
 struct acpi_bus_event {
 	struct list_head node;
 	acpi_device_class device_class;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki

There are two fields in struct acpi_device_pnp, device_name and device_class, that were supposed to be populated and used by device drivers, but they have never been used consistently and now they are only set for the bus object in acpi_set_pnp_ids() (and never read afterward).

Drop them along with all of the associated symbols except for MAX_ACPI_CLASS_NAME_LEN and the acpi_device_class typedef that are used by the ACPI netlink messaging code. Move those two definitions closer to the struct acpi_bus_event that refers to the acpi_device_class type.

...

include/acpi/acpi_bus.h int acpi_dev_for_each_child_reverse(stru · line 578

Quoted 2 lines
include/acpi/acpi_bus.h +2 -0
+#define MAX_ACPI_CLASS_NAME_LEN		20
+typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];

Are you planning to use this in some future code?

include/acpi/acpi_bus.h int acpi_dev_for_each_child_reverse(stru · line 582

Quoted 3 lines

struct acpi_bus_event {

include/acpi/acpi_bus.h +0 -0
 	struct list_head node;
 	acpi_device_class device_class;

Otherwise I would go with complete replacement of the above to simple

	char acpi_device_class[20];

here.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw
Quoted 28 lines · Andy Shevchenko
Quoted 11 lines · Rafael J. Wysocki

There are two fields in struct acpi_device_pnp, device_name and device_class, that were supposed to be populated and used by device drivers, but they have never been used consistently and now they are only set for the bus object in acpi_set_pnp_ids() (and never read afterward).

Drop them along with all of the associated symbols except for MAX_ACPI_CLASS_NAME_LEN and the acpi_device_class typedef that are used by the ACPI netlink messaging code. Move those two definitions closer to the struct acpi_bus_event that refers to the acpi_device_class type.

...

include/acpi/acpi_bus.h int acpi_dev_for_each_child_reverse(stru · line 578

Quoted 2 lines
include/acpi/acpi_bus.h +2 -0
+#define MAX_ACPI_CLASS_NAME_LEN              20
+typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];

Are you planning to use this in some future code?

Quoted 3 lines
 struct acpi_bus_event {
      struct list_head node;
      acpi_device_class device_class;
Quoted 5 lines

Otherwise I would go with complete replacement of the above to simple

        char acpi_device_class[20];

here.

This is in use in the Thinkpad driver.

It might be replaced with something else, but that would be a separate patch.