Merge tag 'driver-core-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
"Here is the small set of driver core and kernfs changes for 6.10-rc1.

Nothing major here at all, just a small set of changes for some driver
core apis, and minor fixups. Included in here are:

- sysfs_bin_attr_simple_read() helper added and used

- device_show_string() helper added and used

All usages of these were acked by the various maintainers. Also in
here are:

- kernfs minor cleanup

- removed unused functions

- typo fix in documentation

- pay attention to sysfs_create_link() failures in module.c finally

All of these have been in linux-next for a very long time with no
reported problems"

* tag 'driver-core-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
device property: Fix a typo in the description of device_get_child_node_count()
kernfs: mount: Remove unnecessary ‘NULL’ values from knparent
scsi: Use device_show_string() helper for sysfs attributes
platform/x86: Use device_show_string() helper for sysfs attributes
perf: Use device_show_string() helper for sysfs attributes
IB/qib: Use device_show_string() helper for sysfs attributes
hwmon: Use device_show_string() helper for sysfs attributes
driver core: Add device_show_string() helper for sysfs attributes
treewide: Use sysfs_bin_attr_simple_read() helper
sysfs: Add sysfs_bin_attr_simple_read() helper
module: don't ignore sysfs_create_link() failures
driver core: Remove unused platform_notify, platform_notify_remove

+188 -422
-10
arch/powerpc/perf/hv-24x7.c
··· 425 return kasprintf(gfp, "%.*s", max_len, maybe_str); 426 } 427 428 - static ssize_t device_show_string(struct device *dev, 429 - struct device_attribute *attr, char *buf) 430 - { 431 - struct dev_ext_attribute *d; 432 - 433 - d = container_of(attr, struct dev_ext_attribute, attr); 434 - 435 - return sprintf(buf, "%s\n", (char *)d->var); 436 - } 437 - 438 static ssize_t cpumask_show(struct device *dev, 439 struct device_attribute *attr, char *buf) 440 {
··· 425 return kasprintf(gfp, "%.*s", max_len, maybe_str); 426 } 427 428 static ssize_t cpumask_show(struct device *dev, 429 struct device_attribute *attr, char *buf) 430 {
+1 -9
arch/powerpc/platforms/powernv/opal.c
··· 792 return 0; 793 } 794 795 - static ssize_t export_attr_read(struct file *fp, struct kobject *kobj, 796 - struct bin_attribute *bin_attr, char *buf, 797 - loff_t off, size_t count) 798 - { 799 - return memory_read_from_buffer(buf, count, &off, bin_attr->private, 800 - bin_attr->size); 801 - } 802 - 803 static int opal_add_one_export(struct kobject *parent, const char *export_name, 804 struct device_node *np, const char *prop_name) 805 { ··· 818 sysfs_bin_attr_init(attr); 819 attr->attr.name = name; 820 attr->attr.mode = 0400; 821 - attr->read = export_attr_read; 822 attr->private = __va(vals[0]); 823 attr->size = vals[1]; 824
··· 792 return 0; 793 } 794 795 static int opal_add_one_export(struct kobject *parent, const char *export_name, 796 struct device_node *np, const char *prop_name) 797 { ··· 826 sysfs_bin_attr_init(attr); 827 attr->attr.name = name; 828 attr->attr.mode = 0400; 829 + attr->read = sysfs_bin_attr_simple_read; 830 attr->private = __va(vals[0]); 831 attr->size = vals[1]; 832
+3 -10
arch/x86/events/intel/core.c
··· 5645 5646 static char pmu_name_str[30]; 5647 5648 - static ssize_t pmu_name_show(struct device *cdev, 5649 - struct device_attribute *attr, 5650 - char *buf) 5651 - { 5652 - return snprintf(buf, PAGE_SIZE, "%s\n", pmu_name_str); 5653 - } 5654 - 5655 - static DEVICE_ATTR_RO(pmu_name); 5656 5657 static struct attribute *intel_pmu_caps_attrs[] = { 5658 - &dev_attr_pmu_name.attr, 5659 - NULL 5660 }; 5661 5662 static DEVICE_ATTR(allow_tsx_force_abort, 0644,
··· 5645 5646 static char pmu_name_str[30]; 5647 5648 + static DEVICE_STRING_ATTR_RO(pmu_name, 0444, pmu_name_str); 5649 5650 static struct attribute *intel_pmu_caps_attrs[] = { 5651 + &dev_attr_pmu_name.attr.attr, 5652 + NULL 5653 }; 5654 5655 static DEVICE_ATTR(allow_tsx_force_abort, 0644,
+1 -8
drivers/acpi/bgrt.c
··· 29 BGRT_SHOW(xoffset, image_offset_x); 30 BGRT_SHOW(yoffset, image_offset_y); 31 32 - static ssize_t image_read(struct file *file, struct kobject *kobj, 33 - struct bin_attribute *attr, char *buf, loff_t off, size_t count) 34 - { 35 - memcpy(buf, attr->private + off, count); 36 - return count; 37 - } 38 - 39 - static BIN_ATTR_RO(image, 0); /* size gets filled in later */ 40 41 static struct attribute *bgrt_attributes[] = { 42 &bgrt_attr_version.attr,
··· 29 BGRT_SHOW(xoffset, image_offset_x); 30 BGRT_SHOW(yoffset, image_offset_y); 31 32 + static BIN_ATTR_SIMPLE_RO(image); 33 34 static struct attribute *bgrt_attributes[] = { 35 &bgrt_attr_version.attr,
+6 -3
drivers/base/base.h
··· 192 void devices_kset_move_last(struct device *dev); 193 194 #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) 195 - void module_add_driver(struct module *mod, struct device_driver *drv); 196 void module_remove_driver(struct device_driver *drv); 197 #else 198 - static inline void module_add_driver(struct module *mod, 199 - struct device_driver *drv) { } 200 static inline void module_remove_driver(struct device_driver *drv) { } 201 #endif 202
··· 192 void devices_kset_move_last(struct device *dev); 193 194 #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) 195 + int module_add_driver(struct module *mod, struct device_driver *drv); 196 void module_remove_driver(struct device_driver *drv); 197 #else 198 + static inline int module_add_driver(struct module *mod, 199 + struct device_driver *drv) 200 + { 201 + return 0; 202 + } 203 static inline void module_remove_driver(struct device_driver *drv) { } 204 #endif 205
+8 -1
drivers/base/bus.c
··· 674 if (error) 675 goto out_del_list; 676 } 677 - module_add_driver(drv->owner, drv); 678 679 error = driver_create_file(drv, &driver_attr_uevent); 680 if (error) { ··· 704 705 return 0; 706 707 out_del_list: 708 klist_del(&priv->knode_bus); 709 out_unregister:
··· 674 if (error) 675 goto out_del_list; 676 } 677 + error = module_add_driver(drv->owner, drv); 678 + if (error) { 679 + printk(KERN_ERR "%s: failed to create module links for %s\n", 680 + __func__, drv->name); 681 + goto out_detach; 682 + } 683 684 error = driver_create_file(drv, &driver_attr_uevent); 685 if (error) { ··· 699 700 return 0; 701 702 + out_detach: 703 + driver_detach(drv); 704 out_del_list: 705 klist_del(&priv->knode_bus); 706 out_unregister:
+9 -8
drivers/base/core.c
··· 2346 2347 /* Device links support end. */ 2348 2349 - int (*platform_notify)(struct device *dev) = NULL; 2350 - int (*platform_notify_remove)(struct device *dev) = NULL; 2351 static struct kobject *dev_kobj; 2352 2353 /* /sys/dev/char */ ··· 2393 acpi_device_notify(dev); 2394 2395 software_node_notify(dev); 2396 - 2397 - if (platform_notify) 2398 - platform_notify(dev); 2399 } 2400 2401 static void device_platform_notify_remove(struct device *dev) 2402 { 2403 - if (platform_notify_remove) 2404 - platform_notify_remove(dev); 2405 - 2406 software_node_notify_remove(dev); 2407 2408 acpi_device_notify_remove(dev); ··· 2537 return sysfs_emit(buf, "%d\n", *(bool *)(ea->var)); 2538 } 2539 EXPORT_SYMBOL_GPL(device_show_bool); 2540 2541 /** 2542 * device_release - free device structure.
··· 2346 2347 /* Device links support end. */ 2348 2349 static struct kobject *dev_kobj; 2350 2351 /* /sys/dev/char */ ··· 2395 acpi_device_notify(dev); 2396 2397 software_node_notify(dev); 2398 } 2399 2400 static void device_platform_notify_remove(struct device *dev) 2401 { 2402 software_node_notify_remove(dev); 2403 2404 acpi_device_notify_remove(dev); ··· 2545 return sysfs_emit(buf, "%d\n", *(bool *)(ea->var)); 2546 } 2547 EXPORT_SYMBOL_GPL(device_show_bool); 2548 + 2549 + ssize_t device_show_string(struct device *dev, 2550 + struct device_attribute *attr, char *buf) 2551 + { 2552 + struct dev_ext_attribute *ea = to_ext_attr(attr); 2553 + 2554 + return sysfs_emit(buf, "%s\n", (char *)ea->var); 2555 + } 2556 + EXPORT_SYMBOL_GPL(device_show_string); 2557 2558 /** 2559 * device_release - free device structure.
+31 -11
drivers/base/module.c
··· 30 mutex_unlock(&drivers_dir_mutex); 31 } 32 33 - void module_add_driver(struct module *mod, struct device_driver *drv) 34 { 35 char *driver_name; 36 - int no_warn; 37 struct module_kobject *mk = NULL; 38 39 if (!drv) 40 - return; 41 42 if (mod) 43 mk = &mod->mkobj; ··· 56 } 57 58 if (!mk) 59 - return; 60 61 - /* Don't check return codes; these calls are idempotent */ 62 - no_warn = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module"); 63 driver_name = make_driver_name(drv); 64 - if (driver_name) { 65 - module_create_drivers_dir(mk); 66 - no_warn = sysfs_create_link(mk->drivers_dir, &drv->p->kobj, 67 - driver_name); 68 - kfree(driver_name); 69 } 70 } 71 72 void module_remove_driver(struct device_driver *drv)
··· 30 mutex_unlock(&drivers_dir_mutex); 31 } 32 33 + int module_add_driver(struct module *mod, struct device_driver *drv) 34 { 35 char *driver_name; 36 struct module_kobject *mk = NULL; 37 + int ret; 38 39 if (!drv) 40 + return 0; 41 42 if (mod) 43 mk = &mod->mkobj; ··· 56 } 57 58 if (!mk) 59 + return 0; 60 61 + ret = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module"); 62 + if (ret) 63 + return ret; 64 + 65 driver_name = make_driver_name(drv); 66 + if (!driver_name) { 67 + ret = -ENOMEM; 68 + goto out; 69 } 70 + 71 + module_create_drivers_dir(mk); 72 + if (!mk->drivers_dir) { 73 + ret = -EINVAL; 74 + goto out; 75 + } 76 + 77 + ret = sysfs_create_link(mk->drivers_dir, &drv->p->kobj, driver_name); 78 + if (ret) 79 + goto out; 80 + 81 + kfree(driver_name); 82 + 83 + return 0; 84 + out: 85 + sysfs_remove_link(&drv->p->kobj, "module"); 86 + sysfs_remove_link(mk->drivers_dir, driver_name); 87 + kfree(driver_name); 88 + 89 + return ret; 90 } 91 92 void module_remove_driver(struct device_driver *drv)
+1 -1
drivers/base/property.c
··· 905 906 /** 907 * device_get_child_node_count - return the number of child nodes for device 908 - * @dev: Device to cound the child nodes for 909 * 910 * Return: the number of child nodes for a given device. 911 */
··· 905 906 /** 907 * device_get_child_node_count - return the number of child nodes for device 908 + * @dev: Device to count the child nodes for 909 * 910 * Return: the number of child nodes for a given device. 911 */
+2 -10
drivers/firmware/dmi_scan.c
··· 761 pr_info("DMI not present or invalid.\n"); 762 } 763 764 - static ssize_t raw_table_read(struct file *file, struct kobject *kobj, 765 - struct bin_attribute *attr, char *buf, 766 - loff_t pos, size_t count) 767 - { 768 - memcpy(buf, attr->private + pos, count); 769 - return count; 770 - } 771 - 772 - static BIN_ATTR(smbios_entry_point, S_IRUSR, raw_table_read, NULL, 0); 773 - static BIN_ATTR(DMI, S_IRUSR, raw_table_read, NULL, 0); 774 775 static int __init dmi_init(void) 776 {
··· 761 pr_info("DMI not present or invalid.\n"); 762 } 763 764 + static BIN_ATTR_SIMPLE_ADMIN_RO(smbios_entry_point); 765 + static BIN_ATTR_SIMPLE_ADMIN_RO(DMI); 766 767 static int __init dmi_init(void) 768 {
+1 -9
drivers/firmware/efi/rci2-table.c
··· 40 static u32 rci2_table_len; 41 unsigned long rci2_table_phys __ro_after_init = EFI_INVALID_TABLE_ADDR; 42 43 - static ssize_t raw_table_read(struct file *file, struct kobject *kobj, 44 - struct bin_attribute *attr, char *buf, 45 - loff_t pos, size_t count) 46 - { 47 - memcpy(buf, attr->private + pos, count); 48 - return count; 49 - } 50 - 51 - static BIN_ATTR(rci2, S_IRUSR, raw_table_read, NULL, 0); 52 53 static u16 checksum(void) 54 {
··· 40 static u32 rci2_table_len; 41 unsigned long rci2_table_phys __ro_after_init = EFI_INVALID_TABLE_ADDR; 42 43 + static BIN_ATTR_SIMPLE_ADMIN_RO(rci2); 44 45 static u16 checksum(void) 46 {
+6 -20
drivers/gpu/drm/i915/gvt/firmware.c
··· 51 52 #define dev_to_drm_minor(d) dev_get_drvdata((d)) 53 54 - static ssize_t 55 - gvt_firmware_read(struct file *filp, struct kobject *kobj, 56 - struct bin_attribute *attr, char *buf, 57 - loff_t offset, size_t count) 58 - { 59 - memcpy(buf, attr->private + offset, count); 60 - return count; 61 - } 62 - 63 - static struct bin_attribute firmware_attr = { 64 - .attr = {.name = "gvt_firmware", .mode = (S_IRUSR)}, 65 - .read = gvt_firmware_read, 66 - .write = NULL, 67 - .mmap = NULL, 68 - }; 69 70 static int expose_firmware_sysfs(struct intel_gvt *gvt) 71 { ··· 94 crc32_start = offsetof(struct gvt_firmware_header, version); 95 h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); 96 97 - firmware_attr.size = size; 98 - firmware_attr.private = firmware; 99 100 - ret = device_create_bin_file(&pdev->dev, &firmware_attr); 101 if (ret) { 102 vfree(firmware); 103 return ret; ··· 109 { 110 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); 111 112 - device_remove_bin_file(&pdev->dev, &firmware_attr); 113 - vfree(firmware_attr.private); 114 } 115 116 /**
··· 51 52 #define dev_to_drm_minor(d) dev_get_drvdata((d)) 53 54 + static BIN_ATTR_SIMPLE_ADMIN_RO(gvt_firmware); 55 56 static int expose_firmware_sysfs(struct intel_gvt *gvt) 57 { ··· 108 crc32_start = offsetof(struct gvt_firmware_header, version); 109 h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); 110 111 + bin_attr_gvt_firmware.size = size; 112 + bin_attr_gvt_firmware.private = firmware; 113 114 + ret = device_create_bin_file(&pdev->dev, &bin_attr_gvt_firmware); 115 if (ret) { 116 vfree(firmware); 117 return ret; ··· 123 { 124 struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); 125 126 + device_remove_bin_file(&pdev->dev, &bin_attr_gvt_firmware); 127 + vfree(bin_attr_gvt_firmware.private); 128 } 129 130 /**
+4 -11
drivers/hwmon/i5k_amb.c
··· 101 unsigned int num_attrs; 102 }; 103 104 - static ssize_t name_show(struct device *dev, struct device_attribute *devattr, 105 - char *buf) 106 - { 107 - return sprintf(buf, "%s\n", DRVNAME); 108 - } 109 - 110 - 111 - static DEVICE_ATTR_RO(name); 112 113 static struct platform_device *amb_pdev; 114 ··· 366 } 367 } 368 369 - res = device_create_file(&pdev->dev, &dev_attr_name); 370 if (res) 371 goto exit_remove; 372 ··· 379 return res; 380 381 exit_remove: 382 - device_remove_file(&pdev->dev, &dev_attr_name); 383 for (i = 0; i < data->num_attrs; i++) 384 device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); 385 kfree(data->attrs); ··· 554 struct i5k_amb_data *data = platform_get_drvdata(pdev); 555 556 hwmon_device_unregister(data->hwmon_dev); 557 - device_remove_file(&pdev->dev, &dev_attr_name); 558 for (i = 0; i < data->num_attrs; i++) 559 device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); 560 kfree(data->attrs);
··· 101 unsigned int num_attrs; 102 }; 103 104 + static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); 105 106 static struct platform_device *amb_pdev; 107 ··· 373 } 374 } 375 376 + res = device_create_file(&pdev->dev, &dev_attr_name.attr); 377 if (res) 378 goto exit_remove; 379 ··· 386 return res; 387 388 exit_remove: 389 + device_remove_file(&pdev->dev, &dev_attr_name.attr); 390 for (i = 0; i < data->num_attrs; i++) 391 device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); 392 kfree(data->attrs); ··· 561 struct i5k_amb_data *data = platform_get_drvdata(pdev); 562 563 hwmon_device_unregister(data->hwmon_dev); 564 + device_remove_file(&pdev->dev, &dev_attr_name.attr); 565 for (i = 0; i < data->num_attrs; i++) 566 device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); 567 kfree(data->attrs);
+4 -10
drivers/hwmon/ibmpex.c
··· 256 return NULL; 257 } 258 259 - static ssize_t name_show(struct device *dev, struct device_attribute *devattr, 260 - char *buf) 261 - { 262 - return sprintf(buf, "%s\n", DRVNAME); 263 - } 264 - static SENSOR_DEVICE_ATTR_RO(name, name, 0); 265 266 static ssize_t ibmpex_show_sensor(struct device *dev, 267 struct device_attribute *devattr, ··· 410 if (err) 411 goto exit_remove; 412 413 - err = device_create_file(data->bmc_device, 414 - &sensor_dev_attr_name.dev_attr); 415 if (err) 416 goto exit_remove; 417 ··· 419 exit_remove: 420 device_remove_file(data->bmc_device, 421 &sensor_dev_attr_reset_high_low.dev_attr); 422 - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); 423 for (i = 0; i < data->num_sensors; i++) 424 for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { 425 if (!data->sensors[i].attr[j].dev_attr.attr.name) ··· 510 511 device_remove_file(data->bmc_device, 512 &sensor_dev_attr_reset_high_low.dev_attr); 513 - device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); 514 for (i = 0; i < data->num_sensors; i++) 515 for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { 516 if (!data->sensors[i].attr[j].dev_attr.attr.name)
··· 256 return NULL; 257 } 258 259 + static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); 260 261 static ssize_t ibmpex_show_sensor(struct device *dev, 262 struct device_attribute *devattr, ··· 415 if (err) 416 goto exit_remove; 417 418 + err = device_create_file(data->bmc_device, &dev_attr_name.attr); 419 if (err) 420 goto exit_remove; 421 ··· 425 exit_remove: 426 device_remove_file(data->bmc_device, 427 &sensor_dev_attr_reset_high_low.dev_attr); 428 + device_remove_file(data->bmc_device, &dev_attr_name.attr); 429 for (i = 0; i < data->num_sensors; i++) 430 for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { 431 if (!data->sensors[i].attr[j].dev_attr.attr.name) ··· 516 517 device_remove_file(data->bmc_device, 518 &sensor_dev_attr_reset_high_low.dev_attr); 519 + device_remove_file(data->bmc_device, &dev_attr_name.attr); 520 for (i = 0; i < data->num_sensors; i++) 521 for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { 522 if (!data->sensors[i].attr[j].dev_attr.attr.name)
-1
drivers/infiniband/hw/qib/qib.h
··· 1359 * sysfs interface. 1360 */ 1361 1362 - extern const char ib_qib_version[]; 1363 extern const struct attribute_group qib_attr_group; 1364 extern const struct attribute_group *qib_attr_port_groups[]; 1365
··· 1359 * sysfs interface. 1360 */ 1361 1362 extern const struct attribute_group qib_attr_group; 1363 extern const struct attribute_group *qib_attr_port_groups[]; 1364
-6
drivers/infiniband/hw/qib/qib_driver.c
··· 44 45 #include "qib.h" 46 47 - /* 48 - * The size has to be longer than this string, so we can append 49 - * board/chip information to it in the init code. 50 - */ 51 - const char ib_qib_version[] = QIB_DRIVER_VERSION "\n"; 52 - 53 DEFINE_MUTEX(qib_mutex); /* general driver use */ 54 55 unsigned qib_ibmtu;
··· 44 45 #include "qib.h" 46 47 DEFINE_MUTEX(qib_mutex); /* general driver use */ 48 49 unsigned qib_ibmtu;
+2 -8
drivers/infiniband/hw/qib/qib_sysfs.c
··· 585 static DEVICE_ATTR_RO(hca_type); 586 static DEVICE_ATTR(board_id, 0444, hca_type_show, NULL); 587 588 - static ssize_t version_show(struct device *device, 589 - struct device_attribute *attr, char *buf) 590 - { 591 - /* The string printed here is already newline-terminated. */ 592 - return sysfs_emit(buf, "%s", (char *)ib_qib_version); 593 - } 594 - static DEVICE_ATTR_RO(version); 595 596 static ssize_t boardversion_show(struct device *device, 597 struct device_attribute *attr, char *buf) ··· 715 &dev_attr_hw_rev.attr, 716 &dev_attr_hca_type.attr, 717 &dev_attr_board_id.attr, 718 - &dev_attr_version.attr, 719 &dev_attr_nctxts.attr, 720 &dev_attr_nfreectxts.attr, 721 &dev_attr_serial.attr,
··· 585 static DEVICE_ATTR_RO(hca_type); 586 static DEVICE_ATTR(board_id, 0444, hca_type_show, NULL); 587 588 + static DEVICE_STRING_ATTR_RO(version, 0444, QIB_DRIVER_VERSION); 589 590 static ssize_t boardversion_show(struct device *device, 591 struct device_attribute *attr, char *buf) ··· 721 &dev_attr_hw_rev.attr, 722 &dev_attr_hca_type.attr, 723 &dev_attr_board_id.attr, 724 + &dev_attr_version.attr.attr, 725 &dev_attr_nctxts.attr, 726 &dev_attr_nfreectxts.attr, 727 &dev_attr_serial.attr,
+2 -10
drivers/perf/alibaba_uncore_drw_pmu.c
··· 236 .attrs = ali_drw_pmu_cpumask_attrs, 237 }; 238 239 - static ssize_t ali_drw_pmu_identifier_show(struct device *dev, 240 - struct device_attribute *attr, 241 - char *page) 242 - { 243 - return sysfs_emit(page, "%s\n", "ali_drw_pmu"); 244 - } 245 - 246 static umode_t ali_drw_pmu_identifier_attr_visible(struct kobject *kobj, 247 struct attribute *attr, int n) 248 { 249 return attr->mode; 250 } 251 252 - static struct device_attribute ali_drw_pmu_identifier_attr = 253 - __ATTR(identifier, 0444, ali_drw_pmu_identifier_show, NULL); 254 255 static struct attribute *ali_drw_pmu_identifier_attrs[] = { 256 - &ali_drw_pmu_identifier_attr.attr, 257 NULL 258 }; 259
··· 236 .attrs = ali_drw_pmu_cpumask_attrs, 237 }; 238 239 static umode_t ali_drw_pmu_identifier_attr_visible(struct kobject *kobj, 240 struct attribute *attr, int n) 241 { 242 return attr->mode; 243 } 244 245 + static DEVICE_STRING_ATTR_RO(ali_drw_pmu_identifier, 0444, "ali_drw_pmu"); 246 247 static struct attribute *ali_drw_pmu_identifier_attrs[] = { 248 + &dev_attr_ali_drw_pmu_identifier.attr.attr, 249 NULL 250 }; 251
+1 -11
drivers/perf/arm-cci.c
··· 127 128 static void pmu_write_counters(struct cci_pmu *cci_pmu, 129 unsigned long *mask); 130 - static ssize_t __maybe_unused cci_pmu_format_show(struct device *dev, 131 - struct device_attribute *attr, char *buf); 132 static ssize_t __maybe_unused cci_pmu_event_show(struct device *dev, 133 struct device_attribute *attr, char *buf); 134 ··· 136 })[0].attr.attr 137 138 #define CCI_FORMAT_EXT_ATTR_ENTRY(_name, _config) \ 139 - CCI_EXT_ATTR_ENTRY(_name, cci_pmu_format_show, (char *)_config) 140 #define CCI_EVENT_EXT_ATTR_ENTRY(_name, _config) \ 141 CCI_EXT_ATTR_ENTRY(_name, cci_pmu_event_show, (unsigned long)_config) 142 ··· 684 /* Disable all the PMU counters. */ 685 val = readl_relaxed(cci_pmu->ctrl_base + CCI_PMCR) & ~CCI_PMCR_CEN; 686 writel(val, cci_pmu->ctrl_base + CCI_PMCR); 687 - } 688 - 689 - static ssize_t cci_pmu_format_show(struct device *dev, 690 - struct device_attribute *attr, char *buf) 691 - { 692 - struct dev_ext_attribute *eattr = container_of(attr, 693 - struct dev_ext_attribute, attr); 694 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 695 } 696 697 static ssize_t cci_pmu_event_show(struct device *dev,
··· 127 128 static void pmu_write_counters(struct cci_pmu *cci_pmu, 129 unsigned long *mask); 130 static ssize_t __maybe_unused cci_pmu_event_show(struct device *dev, 131 struct device_attribute *attr, char *buf); 132 ··· 138 })[0].attr.attr 139 140 #define CCI_FORMAT_EXT_ATTR_ENTRY(_name, _config) \ 141 + CCI_EXT_ATTR_ENTRY(_name, device_show_string, _config) 142 #define CCI_EVENT_EXT_ATTR_ENTRY(_name, _config) \ 143 CCI_EXT_ATTR_ENTRY(_name, cci_pmu_event_show, (unsigned long)_config) 144 ··· 686 /* Disable all the PMU counters. */ 687 val = readl_relaxed(cci_pmu->ctrl_base + CCI_PMCR) & ~CCI_PMCR_CEN; 688 writel(val, cci_pmu->ctrl_base + CCI_PMCR); 689 } 690 691 static ssize_t cci_pmu_event_show(struct device *dev,
+1 -10
drivers/perf/arm-ccn.c
··· 215 *config |= (node_xp << 0) | (type << 8) | (port << 24); 216 } 217 218 - static ssize_t arm_ccn_pmu_format_show(struct device *dev, 219 - struct device_attribute *attr, char *buf) 220 - { 221 - struct dev_ext_attribute *ea = container_of(attr, 222 - struct dev_ext_attribute, attr); 223 - 224 - return sysfs_emit(buf, "%s\n", (char *)ea->var); 225 - } 226 - 227 #define CCN_FORMAT_ATTR(_name, _config) \ 228 struct dev_ext_attribute arm_ccn_pmu_format_attr_##_name = \ 229 - { __ATTR(_name, S_IRUGO, arm_ccn_pmu_format_show, \ 230 NULL), _config } 231 232 static CCN_FORMAT_ATTR(node, "config:0-7");
··· 215 *config |= (node_xp << 0) | (type << 8) | (port << 24); 216 } 217 218 #define CCN_FORMAT_ATTR(_name, _config) \ 219 struct dev_ext_attribute arm_ccn_pmu_format_attr_##_name = \ 220 + { __ATTR(_name, S_IRUGO, device_show_string, \ 221 NULL), _config } 222 223 static CCN_FORMAT_ATTR(node, "config:0-7");
-10
drivers/perf/arm_cspmu/arm_cspmu.c
··· 223 return attr->mode; 224 } 225 226 - ssize_t arm_cspmu_sysfs_format_show(struct device *dev, 227 - struct device_attribute *attr, 228 - char *buf) 229 - { 230 - struct dev_ext_attribute *eattr = 231 - container_of(attr, struct dev_ext_attribute, attr); 232 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 233 - } 234 - EXPORT_SYMBOL_GPL(arm_cspmu_sysfs_format_show); 235 - 236 static struct attribute *arm_cspmu_format_attrs[] = { 237 ARM_CSPMU_FORMAT_EVENT_ATTR, 238 ARM_CSPMU_FORMAT_FILTER_ATTR,
··· 223 return attr->mode; 224 } 225 226 static struct attribute *arm_cspmu_format_attrs[] = { 227 ARM_CSPMU_FORMAT_EVENT_ATTR, 228 ARM_CSPMU_FORMAT_FILTER_ATTR,
+1 -6
drivers/perf/arm_cspmu/arm_cspmu.h
··· 28 })[0].attr.attr) 29 30 #define ARM_CSPMU_FORMAT_ATTR(_name, _config) \ 31 - ARM_CSPMU_EXT_ATTR(_name, arm_cspmu_sysfs_format_show, (char *)_config) 32 33 #define ARM_CSPMU_EVENT_ATTR(_name, _config) \ 34 PMU_EVENT_ATTR_ID(_name, arm_cspmu_sysfs_event_show, _config) ··· 166 ssize_t arm_cspmu_sysfs_event_show(struct device *dev, 167 struct device_attribute *attr, 168 char *buf); 169 - 170 - /* Default function to show format attribute in sysfs. */ 171 - ssize_t arm_cspmu_sysfs_format_show(struct device *dev, 172 - struct device_attribute *attr, 173 - char *buf); 174 175 /* Register vendor backend. */ 176 int arm_cspmu_impl_register(const struct arm_cspmu_impl_match *impl_match);
··· 28 })[0].attr.attr) 29 30 #define ARM_CSPMU_FORMAT_ATTR(_name, _config) \ 31 + ARM_CSPMU_EXT_ATTR(_name, device_show_string, _config) 32 33 #define ARM_CSPMU_EVENT_ATTR(_name, _config) \ 34 PMU_EVENT_ATTR_ID(_name, arm_cspmu_sysfs_event_show, _config) ··· 166 ssize_t arm_cspmu_sysfs_event_show(struct device *dev, 167 struct device_attribute *attr, 168 char *buf); 169 170 /* Register vendor backend. */ 171 int arm_cspmu_impl_register(const struct arm_cspmu_impl_match *impl_match);
+1 -10
drivers/perf/arm_dsu_pmu.c
··· 85 DSU_EXT_ATTR(_name, dsu_pmu_sysfs_event_show, (unsigned long)_config) 86 87 #define DSU_FORMAT_ATTR(_name, _config) \ 88 - DSU_EXT_ATTR(_name, dsu_pmu_sysfs_format_show, (char *)_config) 89 90 #define DSU_CPUMASK_ATTR(_name, _config) \ 91 DSU_EXT_ATTR(_name, dsu_pmu_cpumask_show, (unsigned long)_config) ··· 137 struct dev_ext_attribute *eattr = container_of(attr, 138 struct dev_ext_attribute, attr); 139 return sysfs_emit(buf, "event=0x%lx\n", (unsigned long)eattr->var); 140 - } 141 - 142 - static ssize_t dsu_pmu_sysfs_format_show(struct device *dev, 143 - struct device_attribute *attr, 144 - char *buf) 145 - { 146 - struct dev_ext_attribute *eattr = container_of(attr, 147 - struct dev_ext_attribute, attr); 148 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 149 } 150 151 static ssize_t dsu_pmu_cpumask_show(struct device *dev,
··· 85 DSU_EXT_ATTR(_name, dsu_pmu_sysfs_event_show, (unsigned long)_config) 86 87 #define DSU_FORMAT_ATTR(_name, _config) \ 88 + DSU_EXT_ATTR(_name, device_show_string, _config) 89 90 #define DSU_CPUMASK_ATTR(_name, _config) \ 91 DSU_EXT_ATTR(_name, dsu_pmu_cpumask_show, (unsigned long)_config) ··· 137 struct dev_ext_attribute *eattr = container_of(attr, 138 struct dev_ext_attribute, attr); 139 return sysfs_emit(buf, "event=0x%lx\n", (unsigned long)eattr->var); 140 } 141 142 static ssize_t dsu_pmu_cpumask_show(struct device *dev,
+1 -12
drivers/perf/cxl_pmu.c
··· 208 return 0; 209 } 210 211 - static ssize_t cxl_pmu_format_sysfs_show(struct device *dev, 212 - struct device_attribute *attr, char *buf) 213 - { 214 - struct dev_ext_attribute *eattr; 215 - 216 - eattr = container_of(attr, struct dev_ext_attribute, attr); 217 - 218 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 219 - } 220 - 221 #define CXL_PMU_FORMAT_ATTR(_name, _format)\ 222 (&((struct dev_ext_attribute[]) { \ 223 { \ 224 - .attr = __ATTR(_name, 0444, \ 225 - cxl_pmu_format_sysfs_show, NULL), \ 226 .var = (void *)_format \ 227 } \ 228 })[0].attr.attr)
··· 208 return 0; 209 } 210 211 #define CXL_PMU_FORMAT_ATTR(_name, _format)\ 212 (&((struct dev_ext_attribute[]) { \ 213 { \ 214 + .attr = __ATTR(_name, 0444, device_show_string, NULL), \ 215 .var = (void *)_format \ 216 } \ 217 })[0].attr.attr)
+1 -12
drivers/perf/hisilicon/hisi_pcie_pmu.c
··· 99 HISI_PCIE_PMU_FILTER_ATTR(port, config2, 15, 0); 100 HISI_PCIE_PMU_FILTER_ATTR(bdf, config2, 31, 16); 101 102 - static ssize_t hisi_pcie_format_sysfs_show(struct device *dev, struct device_attribute *attr, 103 - char *buf) 104 - { 105 - struct dev_ext_attribute *eattr; 106 - 107 - eattr = container_of(attr, struct dev_ext_attribute, attr); 108 - 109 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 110 - } 111 - 112 static ssize_t hisi_pcie_event_sysfs_show(struct device *dev, struct device_attribute *attr, 113 char *buf) 114 { ··· 110 111 #define HISI_PCIE_PMU_FORMAT_ATTR(_name, _format) \ 112 (&((struct dev_ext_attribute[]){ \ 113 - { .attr = __ATTR(_name, 0444, hisi_pcie_format_sysfs_show, \ 114 - NULL), \ 115 .var = (void *)_format } \ 116 })[0].attr.attr) 117
··· 99 HISI_PCIE_PMU_FILTER_ATTR(port, config2, 15, 0); 100 HISI_PCIE_PMU_FILTER_ATTR(bdf, config2, 31, 16); 101 102 static ssize_t hisi_pcie_event_sysfs_show(struct device *dev, struct device_attribute *attr, 103 char *buf) 104 { ··· 120 121 #define HISI_PCIE_PMU_FORMAT_ATTR(_name, _format) \ 122 (&((struct dev_ext_attribute[]){ \ 123 + { .attr = __ATTR(_name, 0444, device_show_string, NULL), \ 124 .var = (void *)_format } \ 125 })[0].attr.attr) 126
-14
drivers/perf/hisilicon/hisi_uncore_pmu.c
··· 23 #define HISI_MAX_PERIOD(nr) (GENMASK_ULL((nr) - 1, 0)) 24 25 /* 26 - * PMU format attributes 27 - */ 28 - ssize_t hisi_format_sysfs_show(struct device *dev, 29 - struct device_attribute *attr, char *buf) 30 - { 31 - struct dev_ext_attribute *eattr; 32 - 33 - eattr = container_of(attr, struct dev_ext_attribute, attr); 34 - 35 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 36 - } 37 - EXPORT_SYMBOL_GPL(hisi_format_sysfs_show); 38 - 39 - /* 40 * PMU event attributes 41 */ 42 ssize_t hisi_event_sysfs_show(struct device *dev,
··· 23 #define HISI_MAX_PERIOD(nr) (GENMASK_ULL((nr) - 1, 0)) 24 25 /* 26 * PMU event attributes 27 */ 28 ssize_t hisi_event_sysfs_show(struct device *dev,
+1 -3
drivers/perf/hisilicon/hisi_uncore_pmu.h
··· 33 })[0].attr.attr) 34 35 #define HISI_PMU_FORMAT_ATTR(_name, _config) \ 36 - HISI_PMU_ATTR(_name, hisi_format_sysfs_show, (void *)_config) 37 #define HISI_PMU_EVENT_ATTR(_name, _config) \ 38 HISI_PMU_ATTR(_name, hisi_event_sysfs_show, (unsigned long)_config) 39 ··· 122 void hisi_uncore_pmu_disable(struct pmu *pmu); 123 ssize_t hisi_event_sysfs_show(struct device *dev, 124 struct device_attribute *attr, char *buf); 125 - ssize_t hisi_format_sysfs_show(struct device *dev, 126 - struct device_attribute *attr, char *buf); 127 ssize_t hisi_cpumask_sysfs_show(struct device *dev, 128 struct device_attribute *attr, char *buf); 129 int hisi_uncore_pmu_online_cpu(unsigned int cpu, struct hlist_node *node);
··· 33 })[0].attr.attr) 34 35 #define HISI_PMU_FORMAT_ATTR(_name, _config) \ 36 + HISI_PMU_ATTR(_name, device_show_string, _config) 37 #define HISI_PMU_EVENT_ATTR(_name, _config) \ 38 HISI_PMU_ATTR(_name, hisi_event_sysfs_show, (unsigned long)_config) 39 ··· 122 void hisi_uncore_pmu_disable(struct pmu *pmu); 123 ssize_t hisi_event_sysfs_show(struct device *dev, 124 struct device_attribute *attr, char *buf); 125 ssize_t hisi_cpumask_sysfs_show(struct device *dev, 126 struct device_attribute *attr, char *buf); 127 int hisi_uncore_pmu_online_cpu(unsigned int cpu, struct hlist_node *node);
+1 -11
drivers/perf/hisilicon/hns3_pmu.c
··· 363 HNS3_PMU_EVT_PPS_##_name##_TIME, \ 364 HNS3_PMU_FILTER_INTR_##_name}) 365 366 - static ssize_t hns3_pmu_format_show(struct device *dev, 367 - struct device_attribute *attr, char *buf) 368 - { 369 - struct dev_ext_attribute *eattr; 370 - 371 - eattr = container_of(attr, struct dev_ext_attribute, attr); 372 - 373 - return sysfs_emit(buf, "%s\n", (char *)eattr->var); 374 - } 375 - 376 static ssize_t hns3_pmu_event_show(struct device *dev, 377 struct device_attribute *attr, char *buf) 378 { ··· 411 })[0].attr.attr) 412 413 #define HNS3_PMU_FORMAT_ATTR(_name, _format) \ 414 - HNS3_PMU_ATTR(_name, hns3_pmu_format_show, (void *)_format) 415 #define HNS3_PMU_EVENT_ATTR(_name, _event) \ 416 HNS3_PMU_ATTR(_name, hns3_pmu_event_show, (void *)_event) 417 #define HNS3_PMU_FLT_MODE_ATTR(_name, _event) \
··· 363 HNS3_PMU_EVT_PPS_##_name##_TIME, \ 364 HNS3_PMU_FILTER_INTR_##_name}) 365 366 static ssize_t hns3_pmu_event_show(struct device *dev, 367 struct device_attribute *attr, char *buf) 368 { ··· 421 })[0].attr.attr) 422 423 #define HNS3_PMU_FORMAT_ATTR(_name, _format) \ 424 + HNS3_PMU_ATTR(_name, device_show_string, _format) 425 #define HNS3_PMU_EVENT_ATTR(_name, _event) \ 426 HNS3_PMU_ATTR(_name, hns3_pmu_event_show, (void *)_event) 427 #define HNS3_PMU_FLT_MODE_ATTR(_name, _event) \
+1 -10
drivers/perf/qcom_l3_pmu.c
··· 609 610 /* formats */ 611 612 - static ssize_t l3cache_pmu_format_show(struct device *dev, 613 - struct device_attribute *attr, char *buf) 614 - { 615 - struct dev_ext_attribute *eattr; 616 - 617 - eattr = container_of(attr, struct dev_ext_attribute, attr); 618 - return sysfs_emit(buf, "%s\n", (char *) eattr->var); 619 - } 620 - 621 #define L3CACHE_PMU_FORMAT_ATTR(_name, _config) \ 622 (&((struct dev_ext_attribute[]) { \ 623 - { .attr = __ATTR(_name, 0444, l3cache_pmu_format_show, NULL), \ 624 .var = (void *) _config, } \ 625 })[0].attr.attr) 626
··· 609 610 /* formats */ 611 612 #define L3CACHE_PMU_FORMAT_ATTR(_name, _config) \ 613 (&((struct dev_ext_attribute[]) { \ 614 + { .attr = __ATTR(_name, 0444, device_show_string, NULL), \ 615 .var = (void *) _config, } \ 616 })[0].attr.attr) 617
+1 -10
drivers/perf/xgene_pmu.c
··· 162 /* 163 * sysfs format attributes 164 */ 165 - static ssize_t xgene_pmu_format_show(struct device *dev, 166 - struct device_attribute *attr, char *buf) 167 - { 168 - struct dev_ext_attribute *eattr; 169 - 170 - eattr = container_of(attr, struct dev_ext_attribute, attr); 171 - return sysfs_emit(buf, "%s\n", (char *) eattr->var); 172 - } 173 - 174 #define XGENE_PMU_FORMAT_ATTR(_name, _config) \ 175 (&((struct dev_ext_attribute[]) { \ 176 - { .attr = __ATTR(_name, S_IRUGO, xgene_pmu_format_show, NULL), \ 177 .var = (void *) _config, } \ 178 })[0].attr.attr) 179
··· 162 /* 163 * sysfs format attributes 164 */ 165 #define XGENE_PMU_FORMAT_ATTR(_name, _config) \ 166 (&((struct dev_ext_attribute[]) { \ 167 + { .attr = __ATTR(_name, S_IRUGO, device_show_string, NULL), \ 168 .var = (void *) _config, } \ 169 })[0].attr.attr) 170
+16 -46
drivers/platform/x86/asus-wmi.c
··· 925 } 926 static DEVICE_ATTR_WO(kbd_rgb_mode); 927 928 - static ssize_t kbd_rgb_mode_index_show(struct device *device, 929 - struct device_attribute *attr, 930 - char *buf) 931 - { 932 - return sysfs_emit(buf, "%s\n", "cmd mode red green blue speed"); 933 - } 934 - static DEVICE_ATTR_RO(kbd_rgb_mode_index); 935 936 static struct attribute *kbd_rgb_mode_attrs[] = { 937 &dev_attr_kbd_rgb_mode.attr, 938 - &dev_attr_kbd_rgb_mode_index.attr, 939 NULL, 940 }; 941 ··· 972 } 973 static DEVICE_ATTR_WO(kbd_rgb_state); 974 975 - static ssize_t kbd_rgb_state_index_show(struct device *device, 976 - struct device_attribute *attr, 977 - char *buf) 978 - { 979 - return sysfs_emit(buf, "%s\n", "cmd boot awake sleep keyboard"); 980 - } 981 - static DEVICE_ATTR_RO(kbd_rgb_state_index); 982 983 static struct attribute *kbd_rgb_state_attrs[] = { 984 &dev_attr_kbd_rgb_state.attr, 985 - &dev_attr_kbd_rgb_state_index.attr, 986 NULL, 987 }; 988 ··· 2708 return count; 2709 } 2710 2711 - static ssize_t fan1_label_show(struct device *dev, 2712 - struct device_attribute *attr, 2713 - char *buf) 2714 - { 2715 - return sysfs_emit(buf, "%s\n", ASUS_FAN_DESC); 2716 - } 2717 - 2718 static ssize_t asus_hwmon_temp1(struct device *dev, 2719 struct device_attribute *attr, 2720 char *buf) ··· 2742 return sysfs_emit(buf, "%d\n", value * 100); 2743 } 2744 2745 - static ssize_t fan2_label_show(struct device *dev, 2746 - struct device_attribute *attr, 2747 - char *buf) 2748 - { 2749 - return sysfs_emit(buf, "%s\n", ASUS_GPU_FAN_DESC); 2750 - } 2751 - 2752 /* Middle/Center fan on modern ROG laptops */ 2753 static ssize_t fan3_input_show(struct device *dev, 2754 struct device_attribute *attr, ··· 2758 value &= 0xffff; 2759 2760 return sysfs_emit(buf, "%d\n", value * 100); 2761 - } 2762 - 2763 - static ssize_t fan3_label_show(struct device *dev, 2764 - struct device_attribute *attr, 2765 - char *buf) 2766 - { 2767 - return sysfs_emit(buf, "%s\n", ASUS_MID_FAN_DESC); 2768 } 2769 2770 static ssize_t pwm2_enable_show(struct device *dev, ··· 2856 static DEVICE_ATTR_RW(pwm1); 2857 static DEVICE_ATTR_RW(pwm1_enable); 2858 static DEVICE_ATTR_RO(fan1_input); 2859 - static DEVICE_ATTR_RO(fan1_label); 2860 /* Fan2 - GPU fan */ 2861 static DEVICE_ATTR_RW(pwm2_enable); 2862 static DEVICE_ATTR_RO(fan2_input); 2863 - static DEVICE_ATTR_RO(fan2_label); 2864 /* Fan3 - Middle/center fan */ 2865 static DEVICE_ATTR_RW(pwm3_enable); 2866 static DEVICE_ATTR_RO(fan3_input); 2867 - static DEVICE_ATTR_RO(fan3_label); 2868 2869 /* Temperature */ 2870 static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL); ··· 2876 &dev_attr_pwm2_enable.attr, 2877 &dev_attr_pwm3_enable.attr, 2878 &dev_attr_fan1_input.attr, 2879 - &dev_attr_fan1_label.attr, 2880 &dev_attr_fan2_input.attr, 2881 - &dev_attr_fan2_label.attr, 2882 &dev_attr_fan3_input.attr, 2883 - &dev_attr_fan3_label.attr, 2884 2885 &dev_attr_temp1_input.attr, 2886 NULL ··· 2897 if (asus->fan_type != FAN_TYPE_AGFN) 2898 return 0; 2899 } else if (attr == &dev_attr_fan1_input.attr 2900 - || attr == &dev_attr_fan1_label.attr 2901 || attr == &dev_attr_pwm1_enable.attr) { 2902 if (asus->fan_type == FAN_TYPE_NONE) 2903 return 0; 2904 } else if (attr == &dev_attr_fan2_input.attr 2905 - || attr == &dev_attr_fan2_label.attr 2906 || attr == &dev_attr_pwm2_enable.attr) { 2907 if (asus->gpu_fan_type == FAN_TYPE_NONE) 2908 return 0; 2909 } else if (attr == &dev_attr_fan3_input.attr 2910 - || attr == &dev_attr_fan3_label.attr 2911 || attr == &dev_attr_pwm3_enable.attr) { 2912 if (asus->mid_fan_type == FAN_TYPE_NONE) 2913 return 0;
··· 925 } 926 static DEVICE_ATTR_WO(kbd_rgb_mode); 927 928 + static DEVICE_STRING_ATTR_RO(kbd_rgb_mode_index, 0444, 929 + "cmd mode red green blue speed"); 930 931 static struct attribute *kbd_rgb_mode_attrs[] = { 932 &dev_attr_kbd_rgb_mode.attr, 933 + &dev_attr_kbd_rgb_mode_index.attr.attr, 934 NULL, 935 }; 936 ··· 977 } 978 static DEVICE_ATTR_WO(kbd_rgb_state); 979 980 + static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444, 981 + "cmd boot awake sleep keyboard"); 982 983 static struct attribute *kbd_rgb_state_attrs[] = { 984 &dev_attr_kbd_rgb_state.attr, 985 + &dev_attr_kbd_rgb_state_index.attr.attr, 986 NULL, 987 }; 988 ··· 2718 return count; 2719 } 2720 2721 static ssize_t asus_hwmon_temp1(struct device *dev, 2722 struct device_attribute *attr, 2723 char *buf) ··· 2759 return sysfs_emit(buf, "%d\n", value * 100); 2760 } 2761 2762 /* Middle/Center fan on modern ROG laptops */ 2763 static ssize_t fan3_input_show(struct device *dev, 2764 struct device_attribute *attr, ··· 2782 value &= 0xffff; 2783 2784 return sysfs_emit(buf, "%d\n", value * 100); 2785 } 2786 2787 static ssize_t pwm2_enable_show(struct device *dev, ··· 2887 static DEVICE_ATTR_RW(pwm1); 2888 static DEVICE_ATTR_RW(pwm1_enable); 2889 static DEVICE_ATTR_RO(fan1_input); 2890 + static DEVICE_STRING_ATTR_RO(fan1_label, 0444, ASUS_FAN_DESC); 2891 + 2892 /* Fan2 - GPU fan */ 2893 static DEVICE_ATTR_RW(pwm2_enable); 2894 static DEVICE_ATTR_RO(fan2_input); 2895 + static DEVICE_STRING_ATTR_RO(fan2_label, 0444, ASUS_GPU_FAN_DESC); 2896 /* Fan3 - Middle/center fan */ 2897 static DEVICE_ATTR_RW(pwm3_enable); 2898 static DEVICE_ATTR_RO(fan3_input); 2899 + static DEVICE_STRING_ATTR_RO(fan3_label, 0444, ASUS_MID_FAN_DESC); 2900 2901 /* Temperature */ 2902 static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL); ··· 2906 &dev_attr_pwm2_enable.attr, 2907 &dev_attr_pwm3_enable.attr, 2908 &dev_attr_fan1_input.attr, 2909 + &dev_attr_fan1_label.attr.attr, 2910 &dev_attr_fan2_input.attr, 2911 + &dev_attr_fan2_label.attr.attr, 2912 &dev_attr_fan3_input.attr, 2913 + &dev_attr_fan3_label.attr.attr, 2914 2915 &dev_attr_temp1_input.attr, 2916 NULL ··· 2927 if (asus->fan_type != FAN_TYPE_AGFN) 2928 return 0; 2929 } else if (attr == &dev_attr_fan1_input.attr 2930 + || attr == &dev_attr_fan1_label.attr.attr 2931 || attr == &dev_attr_pwm1_enable.attr) { 2932 if (asus->fan_type == FAN_TYPE_NONE) 2933 return 0; 2934 } else if (attr == &dev_attr_fan2_input.attr 2935 + || attr == &dev_attr_fan2_label.attr.attr 2936 || attr == &dev_attr_pwm2_enable.attr) { 2937 if (asus->gpu_fan_type == FAN_TYPE_NONE) 2938 return 0; 2939 } else if (attr == &dev_attr_fan3_input.attr 2940 + || attr == &dev_attr_fan3_label.attr.attr 2941 || attr == &dev_attr_pwm3_enable.attr) { 2942 if (asus->mid_fan_type == FAN_TYPE_NONE) 2943 return 0;
+2 -8
drivers/platform/x86/thinkpad_acpi.c
··· 10828 .name = "auxmac", 10829 }; 10830 10831 - static ssize_t auxmac_show(struct device *dev, 10832 - struct device_attribute *attr, 10833 - char *buf) 10834 - { 10835 - return sysfs_emit(buf, "%s\n", auxmac); 10836 - } 10837 - static DEVICE_ATTR_RO(auxmac); 10838 10839 static umode_t auxmac_attr_is_visible(struct kobject *kobj, 10840 struct attribute *attr, int n) ··· 10837 } 10838 10839 static struct attribute *auxmac_attributes[] = { 10840 - &dev_attr_auxmac.attr, 10841 NULL 10842 }; 10843
··· 10828 .name = "auxmac", 10829 }; 10830 10831 + static DEVICE_STRING_ATTR_RO(auxmac, 0444, auxmac); 10832 10833 static umode_t auxmac_attr_is_visible(struct kobject *kobj, 10834 struct attribute *attr, int n) ··· 10843 } 10844 10845 static struct attribute *auxmac_attributes[] = { 10846 + &dev_attr_auxmac.attr.attr, 10847 NULL 10848 }; 10849
+2 -7
drivers/platform/x86/toshiba_acpi.c
··· 1821 /* 1822 * Sysfs files 1823 */ 1824 - static ssize_t version_show(struct device *dev, 1825 - struct device_attribute *attr, char *buf) 1826 - { 1827 - return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION); 1828 - } 1829 - static DEVICE_ATTR_RO(version); 1830 1831 static ssize_t fan_store(struct device *dev, 1832 struct device_attribute *attr, ··· 2430 static DEVICE_ATTR_RW(cooling_method); 2431 2432 static struct attribute *toshiba_attributes[] = { 2433 - &dev_attr_version.attr, 2434 &dev_attr_fan.attr, 2435 &dev_attr_kbd_backlight_mode.attr, 2436 &dev_attr_kbd_type.attr,
··· 1821 /* 1822 * Sysfs files 1823 */ 1824 + static DEVICE_STRING_ATTR_RO(version, 0444, TOSHIBA_ACPI_VERSION); 1825 1826 static ssize_t fan_store(struct device *dev, 1827 struct device_attribute *attr, ··· 2435 static DEVICE_ATTR_RW(cooling_method); 2436 2437 static struct attribute *toshiba_attributes[] = { 2438 + &dev_attr_version.attr.attr, 2439 &dev_attr_fan.attr, 2440 &dev_attr_kbd_backlight_mode.attr, 2441 &dev_attr_kbd_type.attr,
+7 -21
drivers/scsi/bfa/bfad_attr.c
··· 854 } 855 856 static ssize_t 857 - bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr, 858 - char *buf) 859 - { 860 - return sysfs_emit(buf, "%s\n", BFAD_DRIVER_VERSION); 861 - } 862 - 863 - static ssize_t 864 bfad_im_optionrom_version_show(struct device *dev, 865 struct device_attribute *attr, char *buf) 866 { ··· 895 } 896 897 static ssize_t 898 - bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr, 899 - char *buf) 900 - { 901 - return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME); 902 - } 903 - 904 - static ssize_t 905 bfad_im_num_of_discovered_ports_show(struct device *dev, 906 struct device_attribute *attr, char *buf) 907 { ··· 930 bfad_im_symbolic_name_show, NULL); 931 static DEVICE_ATTR(hardware_version, S_IRUGO, 932 bfad_im_hw_version_show, NULL); 933 - static DEVICE_ATTR(driver_version, S_IRUGO, 934 - bfad_im_drv_version_show, NULL); 935 static DEVICE_ATTR(option_rom_version, S_IRUGO, 936 bfad_im_optionrom_version_show, NULL); 937 static DEVICE_ATTR(firmware_version, S_IRUGO, 938 bfad_im_fw_version_show, NULL); 939 static DEVICE_ATTR(number_of_ports, S_IRUGO, 940 bfad_im_num_of_ports_show, NULL); 941 - static DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL); 942 static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO, 943 bfad_im_num_of_discovered_ports_show, NULL); 944 ··· 949 &dev_attr_node_name.attr, 950 &dev_attr_symbolic_name.attr, 951 &dev_attr_hardware_version.attr, 952 - &dev_attr_driver_version.attr, 953 &dev_attr_option_rom_version.attr, 954 &dev_attr_firmware_version.attr, 955 &dev_attr_number_of_ports.attr, 956 - &dev_attr_driver_name.attr, 957 &dev_attr_number_of_discovered_ports.attr, 958 NULL, 959 }; ··· 974 &dev_attr_node_name.attr, 975 &dev_attr_symbolic_name.attr, 976 &dev_attr_hardware_version.attr, 977 - &dev_attr_driver_version.attr, 978 &dev_attr_option_rom_version.attr, 979 &dev_attr_firmware_version.attr, 980 &dev_attr_number_of_ports.attr, 981 - &dev_attr_driver_name.attr, 982 &dev_attr_number_of_discovered_ports.attr, 983 NULL, 984 };
··· 854 } 855 856 static ssize_t 857 bfad_im_optionrom_version_show(struct device *dev, 858 struct device_attribute *attr, char *buf) 859 { ··· 902 } 903 904 static ssize_t 905 bfad_im_num_of_discovered_ports_show(struct device *dev, 906 struct device_attribute *attr, char *buf) 907 { ··· 944 bfad_im_symbolic_name_show, NULL); 945 static DEVICE_ATTR(hardware_version, S_IRUGO, 946 bfad_im_hw_version_show, NULL); 947 + static DEVICE_STRING_ATTR_RO(driver_version, S_IRUGO, 948 + BFAD_DRIVER_VERSION); 949 static DEVICE_ATTR(option_rom_version, S_IRUGO, 950 bfad_im_optionrom_version_show, NULL); 951 static DEVICE_ATTR(firmware_version, S_IRUGO, 952 bfad_im_fw_version_show, NULL); 953 static DEVICE_ATTR(number_of_ports, S_IRUGO, 954 bfad_im_num_of_ports_show, NULL); 955 + static DEVICE_STRING_ATTR_RO(driver_name, S_IRUGO, BFAD_DRIVER_NAME); 956 static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO, 957 bfad_im_num_of_discovered_ports_show, NULL); 958 ··· 963 &dev_attr_node_name.attr, 964 &dev_attr_symbolic_name.attr, 965 &dev_attr_hardware_version.attr, 966 + &dev_attr_driver_version.attr.attr, 967 &dev_attr_option_rom_version.attr, 968 &dev_attr_firmware_version.attr, 969 &dev_attr_number_of_ports.attr, 970 + &dev_attr_driver_name.attr.attr, 971 &dev_attr_number_of_discovered_ports.attr, 972 NULL, 973 }; ··· 988 &dev_attr_node_name.attr, 989 &dev_attr_symbolic_name.attr, 990 &dev_attr_hardware_version.attr, 991 + &dev_attr_driver_version.attr.attr, 992 &dev_attr_option_rom_version.attr, 993 &dev_attr_firmware_version.attr, 994 &dev_attr_number_of_ports.attr, 995 + &dev_attr_driver_name.attr.attr, 996 &dev_attr_number_of_discovered_ports.attr, 997 NULL, 998 };
+2 -9
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
··· 3613 kfree(vscsi); 3614 } 3615 3616 - static ssize_t system_id_show(struct device *dev, 3617 - struct device_attribute *attr, char *buf) 3618 - { 3619 - return sysfs_emit(buf, "%s\n", system_id); 3620 - } 3621 - 3622 static ssize_t partition_number_show(struct device *dev, 3623 struct device_attribute *attr, char *buf) 3624 { ··· 3976 3977 static void ibmvscsis_dev_release(struct device *dev) {}; 3978 3979 - static struct device_attribute dev_attr_system_id = 3980 - __ATTR(system_id, S_IRUGO, system_id_show, NULL); 3981 3982 static struct device_attribute dev_attr_partition_number = 3983 __ATTR(partition_number, S_IRUGO, partition_number_show, NULL); ··· 3985 __ATTR(unit_address, S_IRUGO, unit_address_show, NULL); 3986 3987 static struct attribute *ibmvscsis_dev_attrs[] = { 3988 - &dev_attr_system_id.attr, 3989 &dev_attr_partition_number.attr, 3990 &dev_attr_unit_address.attr, 3991 };
··· 3613 kfree(vscsi); 3614 } 3615 3616 static ssize_t partition_number_show(struct device *dev, 3617 struct device_attribute *attr, char *buf) 3618 { ··· 3982 3983 static void ibmvscsis_dev_release(struct device *dev) {}; 3984 3985 + static DEVICE_STRING_ATTR_RO(system_id, S_IRUGO, system_id); 3986 3987 static struct device_attribute dev_attr_partition_number = 3988 __ATTR(partition_number, S_IRUGO, partition_number_show, NULL); ··· 3992 __ATTR(unit_address, S_IRUGO, unit_address_show, NULL); 3993 3994 static struct attribute *ibmvscsis_dev_attrs[] = { 3995 + &dev_attr_system_id.attr.attr, 3996 &dev_attr_partition_number.attr, 3997 &dev_attr_unit_address.attr, 3998 };
+2 -8
drivers/scsi/mvsas/mv_init.c
··· 676 .remove = mvs_pci_remove, 677 }; 678 679 - static ssize_t driver_version_show(struct device *cdev, 680 - struct device_attribute *attr, char *buffer) 681 - { 682 - return sysfs_emit(buffer, "%s\n", DRV_VERSION); 683 - } 684 - 685 - static DEVICE_ATTR_RO(driver_version); 686 687 static ssize_t interrupt_coalescing_store(struct device *cdev, 688 struct device_attribute *attr, ··· 751 } 752 753 static struct attribute *mvst_host_attrs[] = { 754 - &dev_attr_driver_version.attr, 755 &dev_attr_interrupt_coalescing.attr, 756 NULL, 757 };
··· 676 .remove = mvs_pci_remove, 677 }; 678 679 + static DEVICE_STRING_ATTR_RO(driver_version, 0444, DRV_VERSION); 680 681 static ssize_t interrupt_coalescing_store(struct device *cdev, 682 struct device_attribute *attr, ··· 757 } 758 759 static struct attribute *mvst_host_attrs[] = { 760 + &dev_attr_driver_version.attr.attr, 761 &dev_attr_interrupt_coalescing.attr, 762 NULL, 763 };
+2 -9
drivers/scsi/qla2xxx/qla_attr.c
··· 1068 /* Scsi_Host attributes. */ 1069 1070 static ssize_t 1071 - qla2x00_driver_version_show(struct device *dev, 1072 - struct device_attribute *attr, char *buf) 1073 - { 1074 - return scnprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str); 1075 - } 1076 - 1077 - static ssize_t 1078 qla2x00_fw_version_show(struct device *dev, 1079 struct device_attribute *attr, char *buf) 1080 { ··· 2405 static DEVICE_ATTR(dport_diagnostics, 0444, 2406 qla2x00_dport_diagnostics_show, NULL); 2407 2408 - static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_driver_version_show, NULL); 2409 static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 2410 static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 2411 static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); ··· 2471 static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL); 2472 2473 static struct attribute *qla2x00_host_attrs[] = { 2474 - &dev_attr_driver_version.attr, 2475 &dev_attr_fw_version.attr, 2476 &dev_attr_serial_num.attr, 2477 &dev_attr_isp_name.attr,
··· 1068 /* Scsi_Host attributes. */ 1069 1070 static ssize_t 1071 qla2x00_fw_version_show(struct device *dev, 1072 struct device_attribute *attr, char *buf) 1073 { ··· 2412 static DEVICE_ATTR(dport_diagnostics, 0444, 2413 qla2x00_dport_diagnostics_show, NULL); 2414 2415 + static DEVICE_STRING_ATTR_RO(driver_version, S_IRUGO, qla2x00_version_str); 2416 static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 2417 static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 2418 static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL); ··· 2478 static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL); 2479 2480 static struct attribute *qla2x00_host_attrs[] = { 2481 + &dev_attr_driver_version.attr.attr, 2482 &dev_attr_fw_version.attr, 2483 &dev_attr_serial_num.attr, 2484 &dev_attr_isp_name.attr,
+3 -8
drivers/scsi/smartpqi/smartpqi_init.c
··· 6891 return scnprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->firmware_version); 6892 } 6893 6894 - static ssize_t pqi_driver_version_show(struct device *dev, 6895 - struct device_attribute *attr, char *buffer) 6896 - { 6897 - return scnprintf(buffer, PAGE_SIZE, "%s\n", DRIVER_VERSION BUILD_TIMESTAMP); 6898 - } 6899 - 6900 static ssize_t pqi_serial_number_show(struct device *dev, 6901 struct device_attribute *attr, char *buffer) 6902 { ··· 7059 return count; 7060 } 7061 7062 - static DEVICE_ATTR(driver_version, 0444, pqi_driver_version_show, NULL); 7063 static DEVICE_ATTR(firmware_version, 0444, pqi_firmware_version_show, NULL); 7064 static DEVICE_ATTR(model, 0444, pqi_model_show, NULL); 7065 static DEVICE_ATTR(serial_number, 0444, pqi_serial_number_show, NULL); ··· 7077 pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store); 7078 7079 static struct attribute *pqi_shost_attrs[] = { 7080 - &dev_attr_driver_version.attr, 7081 &dev_attr_firmware_version.attr, 7082 &dev_attr_model.attr, 7083 &dev_attr_serial_number.attr,
··· 6891 return scnprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->firmware_version); 6892 } 6893 6894 static ssize_t pqi_serial_number_show(struct device *dev, 6895 struct device_attribute *attr, char *buffer) 6896 { ··· 7065 return count; 7066 } 7067 7068 + static DEVICE_STRING_ATTR_RO(driver_version, 0444, 7069 + DRIVER_VERSION BUILD_TIMESTAMP); 7070 static DEVICE_ATTR(firmware_version, 0444, pqi_firmware_version_show, NULL); 7071 static DEVICE_ATTR(model, 0444, pqi_model_show, NULL); 7072 static DEVICE_ATTR(serial_number, 0444, pqi_serial_number_show, NULL); ··· 7082 pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store); 7083 7084 static struct attribute *pqi_shost_attrs[] = { 7085 + &dev_attr_driver_version.attr.attr, 7086 &dev_attr_firmware_version.attr, 7087 &dev_attr_model.attr, 7088 &dev_attr_serial_number.attr,
+1 -8
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
··· 73 struct device_attribute attr; 74 }; 75 76 - static ssize_t data_vault_read(struct file *file, struct kobject *kobj, 77 - struct bin_attribute *attr, char *buf, loff_t off, size_t count) 78 - { 79 - memcpy(buf, attr->private + off, count); 80 - return count; 81 - } 82 - 83 - static BIN_ATTR_RO(data_vault, 0); 84 85 static struct bin_attribute *data_attributes[] = { 86 &bin_attr_data_vault,
··· 73 struct device_attribute attr; 74 }; 75 76 + static BIN_ATTR_SIMPLE_RO(data_vault); 77 78 static struct bin_attribute *data_attributes[] = { 79 &bin_attr_data_vault,
+1 -1
fs/kernfs/mount.c
··· 206 struct super_block *sb) 207 { 208 struct dentry *dentry; 209 - struct kernfs_node *knparent = NULL; 210 211 BUG_ON(sb->s_op != &kernfs_sops); 212
··· 206 struct super_block *sb) 207 { 208 struct dentry *dentry; 209 + struct kernfs_node *knparent; 210 211 BUG_ON(sb->s_op != &kernfs_sops); 212
+27
fs/sysfs/file.c
··· 785 return len; 786 } 787 EXPORT_SYMBOL_GPL(sysfs_emit_at);
··· 785 return len; 786 } 787 EXPORT_SYMBOL_GPL(sysfs_emit_at); 788 + 789 + /** 790 + * sysfs_bin_attr_simple_read - read callback to simply copy from memory. 791 + * @file: attribute file which is being read. 792 + * @kobj: object to which the attribute belongs. 793 + * @attr: attribute descriptor. 794 + * @buf: destination buffer. 795 + * @off: offset in bytes from which to read. 796 + * @count: maximum number of bytes to read. 797 + * 798 + * Simple ->read() callback for bin_attributes backed by a buffer in memory. 799 + * The @private and @size members in struct bin_attribute must be set to the 800 + * buffer's location and size before the bin_attribute is created in sysfs. 801 + * 802 + * Bounds check for @off and @count is done in sysfs_kf_bin_read(). 803 + * Negative value check for @off is done in vfs_setpos() and default_llseek(). 804 + * 805 + * Returns number of bytes written to @buf. 806 + */ 807 + ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj, 808 + struct bin_attribute *attr, char *buf, 809 + loff_t off, size_t count) 810 + { 811 + memcpy(buf, attr->private + off, count); 812 + return count; 813 + } 814 + EXPORT_SYMBOL_GPL(sysfs_bin_attr_simple_read);
+15 -11
include/linux/device.h
··· 132 char *buf); 133 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, 134 const char *buf, size_t count); 135 136 /** 137 * DEVICE_ATTR - Define a device attribute. ··· 252 #define DEVICE_BOOL_ATTR(_name, _mode, _var) \ 253 struct dev_ext_attribute dev_attr_##_name = \ 254 { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } 255 256 #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ 257 struct device_attribute dev_attr_##_name = \ ··· 1224 const struct attribute_group **groups); 1225 int __must_check devm_device_add_group(struct device *dev, 1226 const struct attribute_group *grp); 1227 - 1228 - /* 1229 - * Platform "fixup" functions - allow the platform to have their say 1230 - * about devices and actions that the general device layer doesn't 1231 - * know about. 1232 - */ 1233 - /* Notify platform of device discovery */ 1234 - extern int (*platform_notify)(struct device *dev); 1235 - 1236 - extern int (*platform_notify_remove)(struct device *dev); 1237 - 1238 1239 /* 1240 * get_device - atomically increment the reference count for the device.
··· 132 char *buf); 133 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, 134 const char *buf, size_t count); 135 + ssize_t device_show_string(struct device *dev, struct device_attribute *attr, 136 + char *buf); 137 138 /** 139 * DEVICE_ATTR - Define a device attribute. ··· 250 #define DEVICE_BOOL_ATTR(_name, _mode, _var) \ 251 struct dev_ext_attribute dev_attr_##_name = \ 252 { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } 253 + 254 + /** 255 + * DEVICE_STRING_ATTR_RO - Define a device attribute backed by a r/o string. 256 + * @_name: Attribute name. 257 + * @_mode: File mode. 258 + * @_var: Identifier of string. 259 + * 260 + * Like DEVICE_ULONG_ATTR(), but @_var is a string. Because the length of the 261 + * string allocation is unknown, the attribute must be read-only. 262 + */ 263 + #define DEVICE_STRING_ATTR_RO(_name, _mode, _var) \ 264 + struct dev_ext_attribute dev_attr_##_name = \ 265 + { __ATTR(_name, (_mode) & ~0222, device_show_string, NULL), (_var) } 266 267 #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ 268 struct device_attribute dev_attr_##_name = \ ··· 1209 const struct attribute_group **groups); 1210 int __must_check devm_device_add_group(struct device *dev, 1211 const struct attribute_group *grp); 1212 1213 /* 1214 * get_device - atomically increment the reference count for the device.
+15
include/linux/sysfs.h
··· 371 #define BIN_ATTR_ADMIN_RW(_name, _size) \ 372 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) 373 374 struct sysfs_ops { 375 ssize_t (*show)(struct kobject *, struct attribute *, char *); 376 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); ··· 488 int sysfs_emit(char *buf, const char *fmt, ...); 489 __printf(3, 4) 490 int sysfs_emit_at(char *buf, int at, const char *fmt, ...); 491 492 #else /* CONFIG_SYSFS */ 493
··· 371 #define BIN_ATTR_ADMIN_RW(_name, _size) \ 372 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) 373 374 + #define __BIN_ATTR_SIMPLE_RO(_name, _mode) { \ 375 + .attr = { .name = __stringify(_name), .mode = _mode }, \ 376 + .read = sysfs_bin_attr_simple_read, \ 377 + } 378 + 379 + #define BIN_ATTR_SIMPLE_RO(_name) \ 380 + struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0444) 381 + 382 + #define BIN_ATTR_SIMPLE_ADMIN_RO(_name) \ 383 + struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0400) 384 + 385 struct sysfs_ops { 386 ssize_t (*show)(struct kobject *, struct attribute *, char *); 387 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); ··· 477 int sysfs_emit(char *buf, const char *fmt, ...); 478 __printf(3, 4) 479 int sysfs_emit_at(char *buf, int at, const char *fmt, ...); 480 + 481 + ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj, 482 + struct bin_attribute *attr, char *buf, 483 + loff_t off, size_t count); 484 485 #else /* CONFIG_SYSFS */ 486
+1 -9
init/initramfs.c
··· 575 #include <linux/initrd.h> 576 #include <linux/kexec.h> 577 578 - static ssize_t raw_read(struct file *file, struct kobject *kobj, 579 - struct bin_attribute *attr, char *buf, 580 - loff_t pos, size_t count) 581 - { 582 - memcpy(buf, attr->private + pos, count); 583 - return count; 584 - } 585 - 586 - static BIN_ATTR(initrd, 0440, raw_read, NULL, 0); 587 588 void __init reserve_initrd_mem(void) 589 {
··· 575 #include <linux/initrd.h> 576 #include <linux/kexec.h> 577 578 + static BIN_ATTR(initrd, 0440, sysfs_bin_attr_simple_read, NULL, 0); 579 580 void __init reserve_initrd_mem(void) 581 {
+1 -12
kernel/module/sysfs.c
··· 146 struct bin_attribute attrs[] __counted_by(notes); 147 }; 148 149 - static ssize_t module_notes_read(struct file *filp, struct kobject *kobj, 150 - struct bin_attribute *bin_attr, 151 - char *buf, loff_t pos, size_t count) 152 - { 153 - /* 154 - * The caller checked the pos and count against our size. 155 - */ 156 - memcpy(buf, bin_attr->private + pos, count); 157 - return count; 158 - } 159 - 160 static void free_notes_attrs(struct module_notes_attrs *notes_attrs, 161 unsigned int i) 162 { ··· 194 nattr->attr.mode = 0444; 195 nattr->size = info->sechdrs[i].sh_size; 196 nattr->private = (void *)info->sechdrs[i].sh_addr; 197 - nattr->read = module_notes_read; 198 ++nattr; 199 } 200 ++loaded;
··· 146 struct bin_attribute attrs[] __counted_by(notes); 147 }; 148 149 static void free_notes_attrs(struct module_notes_attrs *notes_attrs, 150 unsigned int i) 151 { ··· 205 nattr->attr.mode = 0444; 206 nattr->size = info->sechdrs[i].sh_size; 207 nattr->private = (void *)info->sechdrs[i].sh_addr; 208 + nattr->read = sysfs_bin_attr_simple_read; 209 ++nattr; 210 } 211 ++loaded;