* [PATCH 0/6] Deduplicate string exposure in sysfs @ 2024-04-20 20:00 Lukas Wunner 2024-04-20 20:00 ` [PATCH 2/6] hwmon: 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 2/6] hwmon: 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-20 21:46 ` Guenter Roeck 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: Jean Delvare, Guenter Roeck, linux-hwmon 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/hwmon/i5k_amb.c | 15 ++++----------- drivers/hwmon/ibmpex.c | 14 ++++---------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index ff48913fe6bf..02f5d35dd319 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c @@ -101,14 +101,7 @@ struct i5k_amb_data { unsigned int num_attrs; }; -static ssize_t name_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - return sprintf(buf, "%s\n", DRVNAME); -} - - -static DEVICE_ATTR_RO(name); +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); static struct platform_device *amb_pdev; @@ -373,7 +366,7 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) } } - res = device_create_file(&pdev->dev, &dev_attr_name); + res = device_create_file(&pdev->dev, &dev_attr_name.attr); if (res) goto exit_remove; @@ -386,7 +379,7 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) return res; exit_remove: - device_remove_file(&pdev->dev, &dev_attr_name); + device_remove_file(&pdev->dev, &dev_attr_name.attr); for (i = 0; i < data->num_attrs; i++) device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); kfree(data->attrs); @@ -561,7 +554,7 @@ static void i5k_amb_remove(struct platform_device *pdev) struct i5k_amb_data *data = platform_get_drvdata(pdev); hwmon_device_unregister(data->hwmon_dev); - device_remove_file(&pdev->dev, &dev_attr_name); + device_remove_file(&pdev->dev, &dev_attr_name.attr); for (i = 0; i < data->num_attrs; i++) device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); kfree(data->attrs); diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c index db066b368918..228c5f6c6f38 100644 --- a/drivers/hwmon/ibmpex.c +++ b/drivers/hwmon/ibmpex.c @@ -256,12 +256,7 @@ static struct ibmpex_bmc_data *get_bmc_data(int iface) return NULL; } -static ssize_t name_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - return sprintf(buf, "%s\n", DRVNAME); -} -static SENSOR_DEVICE_ATTR_RO(name, name, 0); +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); static ssize_t ibmpex_show_sensor(struct device *dev, struct device_attribute *devattr, @@ -415,8 +410,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) if (err) goto exit_remove; - err = device_create_file(data->bmc_device, - &sensor_dev_attr_name.dev_attr); + err = device_create_file(data->bmc_device, &dev_attr_name.attr); if (err) goto exit_remove; @@ -425,7 +419,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) exit_remove: device_remove_file(data->bmc_device, &sensor_dev_attr_reset_high_low.dev_attr); - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); + device_remove_file(data->bmc_device, &dev_attr_name.attr); for (i = 0; i < data->num_sensors; i++) for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { if (!data->sensors[i].attr[j].dev_attr.attr.name) @@ -516,7 +510,7 @@ static void ibmpex_bmc_delete(struct ibmpex_bmc_data *data) device_remove_file(data->bmc_device, &sensor_dev_attr_reset_high_low.dev_attr); - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); + device_remove_file(data->bmc_device, &dev_attr_name.attr); for (i = 0; i < data->num_sensors; i++) for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { if (!data->sensors[i].attr[j].dev_attr.attr.name) -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/6] hwmon: Use device_show_string() helper for sysfs attributes 2024-04-20 20:00 ` [PATCH 2/6] hwmon: Use device_show_string() helper for sysfs attributes Lukas Wunner @ 2024-04-20 21:46 ` Guenter Roeck 0 siblings, 0 replies; 5+ messages in thread From: Guenter Roeck @ 2024-04-20 21:46 UTC (permalink / raw) To: Lukas Wunner Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, Jean Delvare, linux-hwmon On Sat, Apr 20, 2024 at 10:00:02PM +0200, 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> Acked-by: Guenter Roeck <linux@roeck-us.net> Guenter ^ 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 2/6] hwmon: 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 2/6] hwmon: Use device_show_string() helper for sysfs attributes Lukas Wunner 2024-04-20 21:46 ` Guenter Roeck 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