X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH 0/6] Deduplicate string exposure in sysfs
@ 2024-04-20 20:00 Lukas Wunner
  2024-04-20 20:00 ` [PATCH 5/6] platform/x86: Use device_show_string() helper for sysfs attributes Lukas Wunner
  2024-05-04 14:31 ` [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
  0 siblings, 2 replies; 5+ messages in thread
From: Lukas Wunner @ 2024-04-20 20:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
  Cc: Michael Ellerman, linuxppc-dev, Jean Delvare, Guenter Roeck,
	linux-hwmon, Dennis Dalessandro, linux-rdma, Shuai Xue,
	Will Deacon, Mark Rutland, Jonathan Cameron, Yicong Yang,
	Jijie Shao, Bjorn Andersson, Konrad Dybcio, Khuong Dinh,
	linux-arm-kernel, Corentin Chary, Luke D. Jones,
	Henrique de Moraes Holschuh, ibm-acpi-devel, Azael Avalos,
	Hans de Goede, Ilpo Jaervinen, platform-driver-x86,
	Anil Gurumur thy, Sudarsana Kalluru, Tyrel Datwyler,
	Nilesh Javali, GR-QLogic-Storage-Upstream, Don Brace, storagedev,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

Introduce a generic ->show() callback to expose a string as a device
attribute in sysfs.  Deduplicate various identical callbacks across
the tree.

Result:  Minus 216 LoC, minus 1576 bytes vmlinux size (x86_64 allyesconfig).

This is a byproduct of my upcoming PCI device authentication v2 patches.


Lukas Wunner (6):
  driver core: Add device_show_string() helper for sysfs attributes
  hwmon: Use device_show_string() helper for sysfs attributes
  IB/qib: Use device_show_string() helper for sysfs attributes
  perf: Use device_show_string() helper for sysfs attributes
  platform/x86: Use device_show_string() helper for sysfs attributes
  scsi: Use device_show_string() helper for sysfs attributes

 arch/powerpc/perf/hv-24x7.c              | 10 ----
 arch/x86/events/intel/core.c             | 13 ++---
 drivers/base/core.c                      |  9 ++++
 drivers/hwmon/i5k_amb.c                  | 15 ++----
 drivers/hwmon/ibmpex.c                   | 14 ++----
 drivers/infiniband/hw/qib/qib.h          |  1 -
 drivers/infiniband/hw/qib/qib_driver.c   |  6 ---
 drivers/infiniband/hw/qib/qib_sysfs.c    | 10 +---
 drivers/perf/alibaba_uncore_drw_pmu.c    | 12 +----
 drivers/perf/arm-cci.c                   | 12 +----
 drivers/perf/arm-ccn.c                   | 11 +----
 drivers/perf/arm_cspmu/arm_cspmu.c       | 10 ----
 drivers/perf/arm_cspmu/arm_cspmu.h       |  7 +--
 drivers/perf/arm_dsu_pmu.c               | 11 +----
 drivers/perf/cxl_pmu.c                   | 13 +----
 drivers/perf/hisilicon/hisi_pcie_pmu.c   | 13 +----
 drivers/perf/hisilicon/hisi_uncore_pmu.c | 14 ------
 drivers/perf/hisilicon/hisi_uncore_pmu.h |  4 +-
 drivers/perf/hisilicon/hns3_pmu.c        | 12 +----
 drivers/perf/qcom_l3_pmu.c               | 11 +----
 drivers/perf/xgene_pmu.c                 | 11 +----
 drivers/platform/x86/asus-wmi.c          | 62 ++++++------------------
 drivers/platform/x86/thinkpad_acpi.c     | 10 +---
 drivers/platform/x86/toshiba_acpi.c      |  9 +---
 drivers/scsi/bfa/bfad_attr.c             | 28 +++--------
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 11 +----
 drivers/scsi/mvsas/mv_init.c             | 10 +---
 drivers/scsi/qla2xxx/qla_attr.c          | 11 +----
 drivers/scsi/smartpqi/smartpqi_init.c    | 11 ++---
 include/linux/device.h                   | 15 ++++++
 30 files changed, 85 insertions(+), 301 deletions(-)

-- 
2.43.0


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

* [PATCH 5/6] platform/x86: Use device_show_string() helper for sysfs attributes
  2024-04-20 20:00 [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
@ 2024-04-20 20:00 ` Lukas Wunner
  2024-04-22 13:52   ` Hans de Goede
  2024-05-04 14:31 ` [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
  1 sibling, 1 reply; 5+ messages in thread
From: Lukas Wunner @ 2024-04-20 20:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
  Cc: Corentin Chary, Luke D. Jones, Henrique de Moraes Holschuh,
	ibm-acpi-devel, Azael Avalos, Hans de Goede, Ilpo Jaervinen,
	platform-driver-x86

Deduplicate sysfs ->show() callbacks which expose a string at a static
memory location.  Use the newly introduced device_show_string() helper
in the driver core instead by declaring those sysfs attributes with
DEVICE_STRING_ATTR_RO().

No functional change intended.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/platform/x86/asus-wmi.c      | 62 +++++++---------------------
 drivers/platform/x86/thinkpad_acpi.c | 10 +----
 drivers/platform/x86/toshiba_acpi.c  |  9 +---
 3 files changed, 20 insertions(+), 61 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f07bbf809ef..78d7579b2fdd 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -915,17 +915,12 @@ static ssize_t kbd_rgb_mode_store(struct device *dev,
 }
 static DEVICE_ATTR_WO(kbd_rgb_mode);
 
-static ssize_t kbd_rgb_mode_index_show(struct device *device,
-						 struct device_attribute *attr,
-						 char *buf)
-{
-	return sysfs_emit(buf, "%s\n", "cmd mode red green blue speed");
-}
-static DEVICE_ATTR_RO(kbd_rgb_mode_index);
+static DEVICE_STRING_ATTR_RO(kbd_rgb_mode_index, 0444,
+			     "cmd mode red green blue speed");
 
 static struct attribute *kbd_rgb_mode_attrs[] = {
 	&dev_attr_kbd_rgb_mode.attr,
-	&dev_attr_kbd_rgb_mode_index.attr,
+	&dev_attr_kbd_rgb_mode_index.attr.attr,
 	NULL,
 };
 
@@ -967,17 +962,12 @@ static ssize_t kbd_rgb_state_store(struct device *dev,
 }
 static DEVICE_ATTR_WO(kbd_rgb_state);
 
-static ssize_t kbd_rgb_state_index_show(struct device *device,
-						 struct device_attribute *attr,
-						 char *buf)
-{
-	return sysfs_emit(buf, "%s\n", "cmd boot awake sleep keyboard");
-}
-static DEVICE_ATTR_RO(kbd_rgb_state_index);
+static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444,
+			     "cmd boot awake sleep keyboard");
 
 static struct attribute *kbd_rgb_state_attrs[] = {
 	&dev_attr_kbd_rgb_state.attr,
-	&dev_attr_kbd_rgb_state_index.attr,
+	&dev_attr_kbd_rgb_state_index.attr.attr,
 	NULL,
 };
 
@@ -2493,13 +2483,6 @@ static ssize_t pwm1_enable_store(struct device *dev,
 	return count;
 }
 
-static ssize_t fan1_label_show(struct device *dev,
-					  struct device_attribute *attr,
-					  char *buf)
-{
-	return sysfs_emit(buf, "%s\n", ASUS_FAN_DESC);
-}
-
 static ssize_t asus_hwmon_temp1(struct device *dev,
 				struct device_attribute *attr,
 				char *buf)
@@ -2534,13 +2517,6 @@ static ssize_t fan2_input_show(struct device *dev,
 	return sysfs_emit(buf, "%d\n", value * 100);
 }
 
-static ssize_t fan2_label_show(struct device *dev,
-					  struct device_attribute *attr,
-					  char *buf)
-{
-	return sysfs_emit(buf, "%s\n", ASUS_GPU_FAN_DESC);
-}
-
 /* Middle/Center fan on modern ROG laptops */
 static ssize_t fan3_input_show(struct device *dev,
 					struct device_attribute *attr,
@@ -2559,13 +2535,6 @@ static ssize_t fan3_input_show(struct device *dev,
 	return sysfs_emit(buf, "%d\n", value * 100);
 }
 
-static ssize_t fan3_label_show(struct device *dev,
-					  struct device_attribute *attr,
-					  char *buf)
-{
-	return sysfs_emit(buf, "%s\n", ASUS_MID_FAN_DESC);
-}
-
 static ssize_t pwm2_enable_show(struct device *dev,
 				struct device_attribute *attr,
 				char *buf)
@@ -2662,15 +2631,16 @@ static ssize_t pwm3_enable_store(struct device *dev,
 static DEVICE_ATTR_RW(pwm1);
 static DEVICE_ATTR_RW(pwm1_enable);
 static DEVICE_ATTR_RO(fan1_input);
-static DEVICE_ATTR_RO(fan1_label);
+static DEVICE_STRING_ATTR_RO(fan1_label, 0444, ASUS_FAN_DESC);
+
 /* Fan2 - GPU fan */
 static DEVICE_ATTR_RW(pwm2_enable);
 static DEVICE_ATTR_RO(fan2_input);
-static DEVICE_ATTR_RO(fan2_label);
+static DEVICE_STRING_ATTR_RO(fan2_label, 0444, ASUS_GPU_FAN_DESC);
 /* Fan3 - Middle/center fan */
 static DEVICE_ATTR_RW(pwm3_enable);
 static DEVICE_ATTR_RO(fan3_input);
-static DEVICE_ATTR_RO(fan3_label);
+static DEVICE_STRING_ATTR_RO(fan3_label, 0444, ASUS_MID_FAN_DESC);
 
 /* Temperature */
 static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL);
@@ -2681,11 +2651,11 @@ static struct attribute *hwmon_attributes[] = {
 	&dev_attr_pwm2_enable.attr,
 	&dev_attr_pwm3_enable.attr,
 	&dev_attr_fan1_input.attr,
-	&dev_attr_fan1_label.attr,
+	&dev_attr_fan1_label.attr.attr,
 	&dev_attr_fan2_input.attr,
-	&dev_attr_fan2_label.attr,
+	&dev_attr_fan2_label.attr.attr,
 	&dev_attr_fan3_input.attr,
-	&dev_attr_fan3_label.attr,
+	&dev_attr_fan3_label.attr.attr,
 
 	&dev_attr_temp1_input.attr,
 	NULL
@@ -2702,17 +2672,17 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
 		if (asus->fan_type != FAN_TYPE_AGFN)
 			return 0;
 	} else if (attr == &dev_attr_fan1_input.attr
-	    || attr == &dev_attr_fan1_label.attr
+	    || attr == &dev_attr_fan1_label.attr.attr
 	    || attr == &dev_attr_pwm1_enable.attr) {
 		if (asus->fan_type == FAN_TYPE_NONE)
 			return 0;
 	} else if (attr == &dev_attr_fan2_input.attr
-	    || attr == &dev_attr_fan2_label.attr
+	    || attr == &dev_attr_fan2_label.attr.attr
 	    || attr == &dev_attr_pwm2_enable.attr) {
 		if (asus->gpu_fan_type == FAN_TYPE_NONE)
 			return 0;
 	} else if (attr == &dev_attr_fan3_input.attr
-	    || attr == &dev_attr_fan3_label.attr
+	    || attr == &dev_attr_fan3_label.attr.attr
 	    || attr == &dev_attr_pwm3_enable.attr) {
 		if (asus->mid_fan_type == FAN_TYPE_NONE)
 			return 0;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 82429e59999d..47a64a213d14 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10991,13 +10991,7 @@ static struct ibm_struct auxmac_data = {
 	.name = "auxmac",
 };
 
-static ssize_t auxmac_show(struct device *dev,
-			   struct device_attribute *attr,
-			   char *buf)
-{
-	return sysfs_emit(buf, "%s\n", auxmac);
-}
-static DEVICE_ATTR_RO(auxmac);
+static DEVICE_STRING_ATTR_RO(auxmac, 0444, auxmac);
 
 static umode_t auxmac_attr_is_visible(struct kobject *kobj,
 				      struct attribute *attr, int n)
@@ -11006,7 +11000,7 @@ static umode_t auxmac_attr_is_visible(struct kobject *kobj,
 }
 
 static struct attribute *auxmac_attributes[] = {
-	&dev_attr_auxmac.attr,
+	&dev_attr_auxmac.attr.attr,
 	NULL
 };
 
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 291f14ef6702..01cf60a015bf 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1814,12 +1814,7 @@ static DECLARE_WORK(kbd_bl_work, toshiba_acpi_kbd_bl_work);
 /*
  * Sysfs files
  */
-static ssize_t version_show(struct device *dev,
-			    struct device_attribute *attr, char *buf)
-{
-	return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION);
-}
-static DEVICE_ATTR_RO(version);
+static DEVICE_STRING_ATTR_RO(version, 0444, TOSHIBA_ACPI_VERSION);
 
 static ssize_t fan_store(struct device *dev,
 			 struct device_attribute *attr,
@@ -2428,7 +2423,7 @@ static ssize_t cooling_method_store(struct device *dev,
 static DEVICE_ATTR_RW(cooling_method);
 
 static struct attribute *toshiba_attributes[] = {
-	&dev_attr_version.attr,
+	&dev_attr_version.attr.attr,
 	&dev_attr_fan.attr,
 	&dev_attr_kbd_backlight_mode.attr,
 	&dev_attr_kbd_type.attr,
-- 
2.43.0


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

* Re: [PATCH 5/6] platform/x86: Use device_show_string() helper for sysfs attributes
  2024-04-20 20:00 ` [PATCH 5/6] platform/x86: Use device_show_string() helper for sysfs attributes Lukas Wunner
@ 2024-04-22 13:52   ` Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2024-04-22 13:52 UTC (permalink / raw)
  To: Lukas Wunner, Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
  Cc: Corentin Chary, Luke D. Jones, Henrique de Moraes Holschuh,
	ibm-acpi-devel, Azael Avalos, Ilpo Jaervinen, platform-driver-x86

Hi,

On 4/20/24 10:00 PM, Lukas Wunner wrote:
> Deduplicate sysfs ->show() callbacks which expose a string at a static
> memory location.  Use the newly introduced device_show_string() helper
> in the driver core instead by declaring those sysfs attributes with
> DEVICE_STRING_ATTR_RO().
> 
> No functional change intended.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Thanks, patch looks good to me:

Acked-by: Hans de Goede <hdegoede@redhat.com>

Feel free to upstream this though whatever git tree is convenient.

Regards,

Hans



> ---
>  drivers/platform/x86/asus-wmi.c      | 62 +++++++---------------------
>  drivers/platform/x86/thinkpad_acpi.c | 10 +----
>  drivers/platform/x86/toshiba_acpi.c  |  9 +---
>  3 files changed, 20 insertions(+), 61 deletions(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 3f07bbf809ef..78d7579b2fdd 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -915,17 +915,12 @@ static ssize_t kbd_rgb_mode_store(struct device *dev,
>  }
>  static DEVICE_ATTR_WO(kbd_rgb_mode);
>  
> -static ssize_t kbd_rgb_mode_index_show(struct device *device,
> -						 struct device_attribute *attr,
> -						 char *buf)
> -{
> -	return sysfs_emit(buf, "%s\n", "cmd mode red green blue speed");
> -}
> -static DEVICE_ATTR_RO(kbd_rgb_mode_index);
> +static DEVICE_STRING_ATTR_RO(kbd_rgb_mode_index, 0444,
> +			     "cmd mode red green blue speed");
>  
>  static struct attribute *kbd_rgb_mode_attrs[] = {
>  	&dev_attr_kbd_rgb_mode.attr,
> -	&dev_attr_kbd_rgb_mode_index.attr,
> +	&dev_attr_kbd_rgb_mode_index.attr.attr,
>  	NULL,
>  };
>  
> @@ -967,17 +962,12 @@ static ssize_t kbd_rgb_state_store(struct device *dev,
>  }
>  static DEVICE_ATTR_WO(kbd_rgb_state);
>  
> -static ssize_t kbd_rgb_state_index_show(struct device *device,
> -						 struct device_attribute *attr,
> -						 char *buf)
> -{
> -	return sysfs_emit(buf, "%s\n", "cmd boot awake sleep keyboard");
> -}
> -static DEVICE_ATTR_RO(kbd_rgb_state_index);
> +static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444,
> +			     "cmd boot awake sleep keyboard");
>  
>  static struct attribute *kbd_rgb_state_attrs[] = {
>  	&dev_attr_kbd_rgb_state.attr,
> -	&dev_attr_kbd_rgb_state_index.attr,
> +	&dev_attr_kbd_rgb_state_index.attr.attr,
>  	NULL,
>  };
>  
> @@ -2493,13 +2483,6 @@ static ssize_t pwm1_enable_store(struct device *dev,
>  	return count;
>  }
>  
> -static ssize_t fan1_label_show(struct device *dev,
> -					  struct device_attribute *attr,
> -					  char *buf)
> -{
> -	return sysfs_emit(buf, "%s\n", ASUS_FAN_DESC);
> -}
> -
>  static ssize_t asus_hwmon_temp1(struct device *dev,
>  				struct device_attribute *attr,
>  				char *buf)
> @@ -2534,13 +2517,6 @@ static ssize_t fan2_input_show(struct device *dev,
>  	return sysfs_emit(buf, "%d\n", value * 100);
>  }
>  
> -static ssize_t fan2_label_show(struct device *dev,
> -					  struct device_attribute *attr,
> -					  char *buf)
> -{
> -	return sysfs_emit(buf, "%s\n", ASUS_GPU_FAN_DESC);
> -}
> -
>  /* Middle/Center fan on modern ROG laptops */
>  static ssize_t fan3_input_show(struct device *dev,
>  					struct device_attribute *attr,
> @@ -2559,13 +2535,6 @@ static ssize_t fan3_input_show(struct device *dev,
>  	return sysfs_emit(buf, "%d\n", value * 100);
>  }
>  
> -static ssize_t fan3_label_show(struct device *dev,
> -					  struct device_attribute *attr,
> -					  char *buf)
> -{
> -	return sysfs_emit(buf, "%s\n", ASUS_MID_FAN_DESC);
> -}
> -
>  static ssize_t pwm2_enable_show(struct device *dev,
>  				struct device_attribute *attr,
>  				char *buf)
> @@ -2662,15 +2631,16 @@ static ssize_t pwm3_enable_store(struct device *dev,
>  static DEVICE_ATTR_RW(pwm1);
>  static DEVICE_ATTR_RW(pwm1_enable);
>  static DEVICE_ATTR_RO(fan1_input);
> -static DEVICE_ATTR_RO(fan1_label);
> +static DEVICE_STRING_ATTR_RO(fan1_label, 0444, ASUS_FAN_DESC);
> +
>  /* Fan2 - GPU fan */
>  static DEVICE_ATTR_RW(pwm2_enable);
>  static DEVICE_ATTR_RO(fan2_input);
> -static DEVICE_ATTR_RO(fan2_label);
> +static DEVICE_STRING_ATTR_RO(fan2_label, 0444, ASUS_GPU_FAN_DESC);
>  /* Fan3 - Middle/center fan */
>  static DEVICE_ATTR_RW(pwm3_enable);
>  static DEVICE_ATTR_RO(fan3_input);
> -static DEVICE_ATTR_RO(fan3_label);
> +static DEVICE_STRING_ATTR_RO(fan3_label, 0444, ASUS_MID_FAN_DESC);
>  
>  /* Temperature */
>  static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL);
> @@ -2681,11 +2651,11 @@ static struct attribute *hwmon_attributes[] = {
>  	&dev_attr_pwm2_enable.attr,
>  	&dev_attr_pwm3_enable.attr,
>  	&dev_attr_fan1_input.attr,
> -	&dev_attr_fan1_label.attr,
> +	&dev_attr_fan1_label.attr.attr,
>  	&dev_attr_fan2_input.attr,
> -	&dev_attr_fan2_label.attr,
> +	&dev_attr_fan2_label.attr.attr,
>  	&dev_attr_fan3_input.attr,
> -	&dev_attr_fan3_label.attr,
> +	&dev_attr_fan3_label.attr.attr,
>  
>  	&dev_attr_temp1_input.attr,
>  	NULL
> @@ -2702,17 +2672,17 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
>  		if (asus->fan_type != FAN_TYPE_AGFN)
>  			return 0;
>  	} else if (attr == &dev_attr_fan1_input.attr
> -	    || attr == &dev_attr_fan1_label.attr
> +	    || attr == &dev_attr_fan1_label.attr.attr
>  	    || attr == &dev_attr_pwm1_enable.attr) {
>  		if (asus->fan_type == FAN_TYPE_NONE)
>  			return 0;
>  	} else if (attr == &dev_attr_fan2_input.attr
> -	    || attr == &dev_attr_fan2_label.attr
> +	    || attr == &dev_attr_fan2_label.attr.attr
>  	    || attr == &dev_attr_pwm2_enable.attr) {
>  		if (asus->gpu_fan_type == FAN_TYPE_NONE)
>  			return 0;
>  	} else if (attr == &dev_attr_fan3_input.attr
> -	    || attr == &dev_attr_fan3_label.attr
> +	    || attr == &dev_attr_fan3_label.attr.attr
>  	    || attr == &dev_attr_pwm3_enable.attr) {
>  		if (asus->mid_fan_type == FAN_TYPE_NONE)
>  			return 0;
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 82429e59999d..47a64a213d14 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10991,13 +10991,7 @@ static struct ibm_struct auxmac_data = {
>  	.name = "auxmac",
>  };
>  
> -static ssize_t auxmac_show(struct device *dev,
> -			   struct device_attribute *attr,
> -			   char *buf)
> -{
> -	return sysfs_emit(buf, "%s\n", auxmac);
> -}
> -static DEVICE_ATTR_RO(auxmac);
> +static DEVICE_STRING_ATTR_RO(auxmac, 0444, auxmac);
>  
>  static umode_t auxmac_attr_is_visible(struct kobject *kobj,
>  				      struct attribute *attr, int n)
> @@ -11006,7 +11000,7 @@ static umode_t auxmac_attr_is_visible(struct kobject *kobj,
>  }
>  
>  static struct attribute *auxmac_attributes[] = {
> -	&dev_attr_auxmac.attr,
> +	&dev_attr_auxmac.attr.attr,
>  	NULL
>  };
>  
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index 291f14ef6702..01cf60a015bf 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -1814,12 +1814,7 @@ static DECLARE_WORK(kbd_bl_work, toshiba_acpi_kbd_bl_work);
>  /*
>   * Sysfs files
>   */
> -static ssize_t version_show(struct device *dev,
> -			    struct device_attribute *attr, char *buf)
> -{
> -	return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION);
> -}
> -static DEVICE_ATTR_RO(version);
> +static DEVICE_STRING_ATTR_RO(version, 0444, TOSHIBA_ACPI_VERSION);
>  
>  static ssize_t fan_store(struct device *dev,
>  			 struct device_attribute *attr,
> @@ -2428,7 +2423,7 @@ static ssize_t cooling_method_store(struct device *dev,
>  static DEVICE_ATTR_RW(cooling_method);
>  
>  static struct attribute *toshiba_attributes[] = {
> -	&dev_attr_version.attr,
> +	&dev_attr_version.attr.attr,
>  	&dev_attr_fan.attr,
>  	&dev_attr_kbd_backlight_mode.attr,
>  	&dev_attr_kbd_type.attr,


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

* Re: [PATCH 0/6] Deduplicate string exposure in sysfs
  2024-04-20 20:00 [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
  2024-04-20 20:00 ` [PATCH 5/6] platform/x86: Use device_show_string() helper for sysfs attributes Lukas Wunner
@ 2024-05-04 14:31 ` Lukas Wunner
  2024-05-04 15:36   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 5+ messages in thread
From: Lukas Wunner @ 2024-05-04 14:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
  Cc: Michael Ellerman, linuxppc-dev, Jean Delvare, Guenter Roeck,
	linux-hwmon, Dennis Dalessandro, linux-rdma, Shuai Xue,
	Will Deacon, Mark Rutland, Jonathan Cameron, Yicong Yang,
	Jijie Shao, Bjorn Andersson, Konrad Dybcio, Khuong Dinh,
	linux-arm-kernel, Corentin Chary, Luke D. Jones,
	Henrique de Moraes Holschuh, ibm-acpi-devel, Azael Avalos,
	Hans de Goede, Ilpo Jaervinen, platform-driver-x86,
	Anil Gurumur thy, Sudarsana Kalluru, Tyrel Datwyler,
	Nilesh Javali, GR-QLogic-Storage-Upstream, Don Brace, storagedev,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

Dear Greg,

On Sat, Apr 20, 2024 at 10:00:00PM +0200, Lukas Wunner wrote:
> Introduce a generic ->show() callback to expose a string as a device
> attribute in sysfs.  Deduplicate various identical callbacks across
> the tree.
> 
> Result:  Minus 216 LoC, minus 1576 bytes vmlinux size (x86_64 allyesconfig).
> 
> This is a byproduct of my upcoming PCI device authentication v2 patches.
> 
> 
> Lukas Wunner (6):
>   driver core: Add device_show_string() helper for sysfs attributes
>   hwmon: Use device_show_string() helper for sysfs attributes
>   IB/qib: Use device_show_string() helper for sysfs attributes
>   perf: Use device_show_string() helper for sysfs attributes
>   platform/x86: Use device_show_string() helper for sysfs attributes
>   scsi: Use device_show_string() helper for sysfs attributes

This series hasn't been applied to driver-core-next AFAICS and the
merge window is drawing closer.

So far only patches 1, 2 and 5 have been ack'ed by the respective
subsystem maintainers.  If the missing acks are the reason it hasn't
been applied, would it be possibe to apply only 1, 2 and 5?

I would then resubmit the other ones individually to the subsystem
maintainers in the next cycle.

Thanks!

Lukas

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

* Re: [PATCH 0/6] Deduplicate string exposure in sysfs
  2024-05-04 14:31 ` [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
@ 2024-05-04 15:36   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2024-05-04 15:36 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Rafael J. Wysocki, linux-kernel, Michael Ellerman, linuxppc-dev,
	Jean Delvare, Guenter Roeck, linux-hwmon, Dennis Dalessandro,
	linux-rdma, Shuai Xue, Will Deacon, Mark Rutland,
	Jonathan Cameron, Yicong Yang, Jijie Shao, Bjorn Andersson,
	Konrad Dybcio, Khuong Dinh, linux-arm-kernel, Corentin Chary,
	Luke D. Jones, Henrique de Moraes Holschuh, ibm-acpi-devel,
	Azael Avalos, Hans de Goede, Ilpo Jaervinen, platform-driver-x86,
	Anil Gurumur thy, Sudarsana Kalluru, Tyrel Datwyler,
	Nilesh Javali, GR-QLogic-Storage-Upstream, Don Brace, storagedev,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

On Sat, May 04, 2024 at 04:31:42PM +0200, Lukas Wunner wrote:
> Dear Greg,
> 
> On Sat, Apr 20, 2024 at 10:00:00PM +0200, Lukas Wunner wrote:
> > Introduce a generic ->show() callback to expose a string as a device
> > attribute in sysfs.  Deduplicate various identical callbacks across
> > the tree.
> > 
> > Result:  Minus 216 LoC, minus 1576 bytes vmlinux size (x86_64 allyesconfig).
> > 
> > This is a byproduct of my upcoming PCI device authentication v2 patches.
> > 
> > 
> > Lukas Wunner (6):
> >   driver core: Add device_show_string() helper for sysfs attributes
> >   hwmon: Use device_show_string() helper for sysfs attributes
> >   IB/qib: Use device_show_string() helper for sysfs attributes
> >   perf: Use device_show_string() helper for sysfs attributes
> >   platform/x86: Use device_show_string() helper for sysfs attributes
> >   scsi: Use device_show_string() helper for sysfs attributes
> 
> This series hasn't been applied to driver-core-next AFAICS and the
> merge window is drawing closer.
> 
> So far only patches 1, 2 and 5 have been ack'ed by the respective
> subsystem maintainers.  If the missing acks are the reason it hasn't
> been applied, would it be possibe to apply only 1, 2 and 5?
> 
> I would then resubmit the other ones individually to the subsystem
> maintainers in the next cycle.

I'll just pick it up now, thanks!

greg k-h

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

end of thread, other threads:[~2024-05-04 15:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-20 20:00 [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
2024-04-20 20:00 ` [PATCH 5/6] platform/x86: Use device_show_string() helper for sysfs attributes Lukas Wunner
2024-04-22 13:52   ` Hans de Goede
2024-05-04 14:31 ` [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
2024-05-04 15:36   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox