* [PATCH 0/6] Deduplicate string exposure in sysfs
@ 2024-04-20 20:00 Lukas Wunner
2024-04-20 20:00 ` [PATCH 6/6] scsi: 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; 4+ 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] 4+ messages in thread
* [PATCH 6/6] scsi: 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-05-04 14:31 ` [PATCH 0/6] Deduplicate string exposure in sysfs Lukas Wunner
1 sibling, 0 replies; 4+ messages in thread
From: Lukas Wunner @ 2024-04-20 20:00 UTC (permalink / raw
To: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
Cc: Anil Gurumurthy, Sudarsana Kalluru, Tyrel Datwyler, Nilesh Javali,
GR-QLogic-Storage-Upstream, Don Brace, storagedev,
James E.J. Bottomley, Martin K. Petersen, linux-scsi
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/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 +++-------
5 files changed, 16 insertions(+), 55 deletions(-)
diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
index e96e4b6df265..54bc1539e1e9 100644
--- a/drivers/scsi/bfa/bfad_attr.c
+++ b/drivers/scsi/bfa/bfad_attr.c
@@ -853,13 +853,6 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
return sysfs_emit(buf, "%s\n", hw_ver);
}
-static ssize_t
-bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- return sysfs_emit(buf, "%s\n", BFAD_DRIVER_VERSION);
-}
-
static ssize_t
bfad_im_optionrom_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -901,13 +894,6 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
bfa_get_nports(&bfad->bfa));
}
-static ssize_t
-bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME);
-}
-
static ssize_t
bfad_im_num_of_discovered_ports_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -944,15 +930,15 @@ static DEVICE_ATTR(symbolic_name, S_IRUGO,
bfad_im_symbolic_name_show, NULL);
static DEVICE_ATTR(hardware_version, S_IRUGO,
bfad_im_hw_version_show, NULL);
-static DEVICE_ATTR(driver_version, S_IRUGO,
- bfad_im_drv_version_show, NULL);
+static DEVICE_STRING_ATTR_RO(driver_version, S_IRUGO,
+ BFAD_DRIVER_VERSION);
static DEVICE_ATTR(option_rom_version, S_IRUGO,
bfad_im_optionrom_version_show, NULL);
static DEVICE_ATTR(firmware_version, S_IRUGO,
bfad_im_fw_version_show, NULL);
static DEVICE_ATTR(number_of_ports, S_IRUGO,
bfad_im_num_of_ports_show, NULL);
-static DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL);
+static DEVICE_STRING_ATTR_RO(driver_name, S_IRUGO, BFAD_DRIVER_NAME);
static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO,
bfad_im_num_of_discovered_ports_show, NULL);
@@ -963,11 +949,11 @@ static struct attribute *bfad_im_host_attrs[] = {
&dev_attr_node_name.attr,
&dev_attr_symbolic_name.attr,
&dev_attr_hardware_version.attr,
- &dev_attr_driver_version.attr,
+ &dev_attr_driver_version.attr.attr,
&dev_attr_option_rom_version.attr,
&dev_attr_firmware_version.attr,
&dev_attr_number_of_ports.attr,
- &dev_attr_driver_name.attr,
+ &dev_attr_driver_name.attr.attr,
&dev_attr_number_of_discovered_ports.attr,
NULL,
};
@@ -988,11 +974,11 @@ static struct attribute *bfad_im_vport_attrs[] = {
&dev_attr_node_name.attr,
&dev_attr_symbolic_name.attr,
&dev_attr_hardware_version.attr,
- &dev_attr_driver_version.attr,
+ &dev_attr_driver_version.attr.attr,
&dev_attr_option_rom_version.attr,
&dev_attr_firmware_version.attr,
&dev_attr_number_of_ports.attr,
- &dev_attr_driver_name.attr,
+ &dev_attr_driver_name.attr.attr,
&dev_attr_number_of_discovered_ports.attr,
NULL,
};
diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index 68b99924ee4f..2fca17cf8b51 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -3613,12 +3613,6 @@ static void ibmvscsis_remove(struct vio_dev *vdev)
kfree(vscsi);
}
-static ssize_t system_id_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sysfs_emit(buf, "%s\n", system_id);
-}
-
static ssize_t partition_number_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -3982,8 +3976,7 @@ static const struct target_core_fabric_ops ibmvscsis_ops = {
static void ibmvscsis_dev_release(struct device *dev) {};
-static struct device_attribute dev_attr_system_id =
- __ATTR(system_id, S_IRUGO, system_id_show, NULL);
+static DEVICE_STRING_ATTR_RO(system_id, S_IRUGO, system_id);
static struct device_attribute dev_attr_partition_number =
__ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
@@ -3992,7 +3985,7 @@ static struct device_attribute dev_attr_unit_address =
__ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
static struct attribute *ibmvscsis_dev_attrs[] = {
- &dev_attr_system_id.attr,
+ &dev_attr_system_id.attr.attr,
&dev_attr_partition_number.attr,
&dev_attr_unit_address.attr,
};
diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 43ebb331e216..2a25d574feb9 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -691,13 +691,7 @@ static struct pci_driver mvs_pci_driver = {
.remove = mvs_pci_remove,
};
-static ssize_t driver_version_show(struct device *cdev,
- struct device_attribute *attr, char *buffer)
-{
- return sysfs_emit(buffer, "%s\n", DRV_VERSION);
-}
-
-static DEVICE_ATTR_RO(driver_version);
+static DEVICE_STRING_ATTR_RO(driver_version, 0444, DRV_VERSION);
static ssize_t interrupt_coalescing_store(struct device *cdev,
struct device_attribute *attr,
@@ -772,7 +766,7 @@ static void __exit mvs_exit(void)
}
static struct attribute *mvst_host_attrs[] = {
- &dev_attr_driver_version.attr,
+ &dev_attr_driver_version.attr.attr,
&dev_attr_interrupt_coalescing.attr,
NULL,
};
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 44449c70a375..d4b420aef4a8 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1067,13 +1067,6 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon)
/* Scsi_Host attributes. */
-static ssize_t
-qla2x00_driver_version_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return scnprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
-}
-
static ssize_t
qla2x00_fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -2412,7 +2405,7 @@ qla2x00_dport_diagnostics_show(struct device *dev,
static DEVICE_ATTR(dport_diagnostics, 0444,
qla2x00_dport_diagnostics_show, NULL);
-static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_driver_version_show, NULL);
+static DEVICE_STRING_ATTR_RO(driver_version, S_IRUGO, qla2x00_version_str);
static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
@@ -2478,7 +2471,7 @@ static DEVICE_ATTR(port_no, 0444, qla2x00_port_no_show, NULL);
static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL);
static struct attribute *qla2x00_host_attrs[] = {
- &dev_attr_driver_version.attr,
+ &dev_attr_driver_version.attr.attr,
&dev_attr_fw_version.attr,
&dev_attr_serial_num.attr,
&dev_attr_isp_name.attr,
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 385180c98be4..f11cf590b2a9 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6892,12 +6892,6 @@ static ssize_t pqi_firmware_version_show(struct device *dev,
return scnprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->firmware_version);
}
-static ssize_t pqi_driver_version_show(struct device *dev,
- struct device_attribute *attr, char *buffer)
-{
- return scnprintf(buffer, PAGE_SIZE, "%s\n", DRIVER_VERSION BUILD_TIMESTAMP);
-}
-
static ssize_t pqi_serial_number_show(struct device *dev,
struct device_attribute *attr, char *buffer)
{
@@ -7066,7 +7060,8 @@ static ssize_t pqi_host_enable_r6_writes_store(struct device *dev,
return count;
}
-static DEVICE_ATTR(driver_version, 0444, pqi_driver_version_show, NULL);
+static DEVICE_STRING_ATTR_RO(driver_version, 0444,
+ DRIVER_VERSION BUILD_TIMESTAMP);
static DEVICE_ATTR(firmware_version, 0444, pqi_firmware_version_show, NULL);
static DEVICE_ATTR(model, 0444, pqi_model_show, NULL);
static DEVICE_ATTR(serial_number, 0444, pqi_serial_number_show, NULL);
@@ -7083,7 +7078,7 @@ static DEVICE_ATTR(enable_r6_writes, 0644,
pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store);
static struct attribute *pqi_shost_attrs[] = {
- &dev_attr_driver_version.attr,
+ &dev_attr_driver_version.attr.attr,
&dev_attr_firmware_version.attr,
&dev_attr_model.attr,
&dev_attr_serial_number.attr,
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ 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 6/6] scsi: 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; 4+ 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] 4+ 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; 4+ 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] 4+ messages in thread
end of thread, other threads:[~2024-05-04 15:36 UTC | newest]
Thread overview: 4+ 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 6/6] scsi: 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
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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).