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
Unified · Split
| @@ -425,16 +425,6 @@ static char *memdup_to_str(char *maybe_str, int max_len, gfp_t gfp) · 424 unmodified lines | ||
| 425 | 425 | return kasprintf(gfp, "%.*s", max_len, maybe_str); |
| 426 | 426 | } |
| 427 | 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 | 428 | static ssize_t cpumask_show(struct device *dev, |
| 439 | 429 | struct device_attribute *attr, char *buf) |
| 440 | 430 | { |
| @@ -792,14 +792,6 @@ static int __init opal_sysfs_init(void) · 791 unmodified lines | ||
| 792 | 792 | return 0; |
| 793 | 793 | } |
| 794 | 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 | 795 | static int opal_add_one_export(struct kobject *parent, const char *export_name, |
| 804 | 796 | struct device_node *np, const char *prop_name) |
| 805 | 797 | { |
| @@ -826,7 +818,7 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name, · 20 unmodified lines | ||
| 826 | 818 | sysfs_bin_attr_init(attr); |
| 827 | 819 | attr->attr.name = name; |
| 828 | 820 | attr->attr.mode = 0400; |
| 829 | − attr->read = export_attr_read; | |
| 821 | + attr->read = sysfs_bin_attr_simple_read; | |
| 830 | 822 | attr->private = __va(vals[0]); |
| 831 | 823 | attr->size = vals[1]; |
| 832 | 824 | |
| @@ -5645,18 +5645,11 @@ lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i) · 5644 unmodified lines | ||
| 5645 | 5645 | |
| 5646 | 5646 | static char pmu_name_str[30]; |
| 5647 | 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); | |
| 5648 | +static DEVICE_STRING_ATTR_RO(pmu_name, 0444, pmu_name_str); | |
| 5656 | 5649 | |
| 5657 | 5650 | static struct attribute *intel_pmu_caps_attrs[] = { |
| 5658 | − &dev_attr_pmu_name.attr, | |
| 5659 | − NULL | |
| 5651 | + &dev_attr_pmu_name.attr.attr, | |
| 5652 | + NULL | |
| 5660 | 5653 | }; |
| 5661 | 5654 | |
| 5662 | 5655 | static DEVICE_ATTR(allow_tsx_force_abort, 0644, |
| @@ -29,14 +29,7 @@ BGRT_SHOW(type, image_type); · 28 unmodified lines | ||
| 29 | 29 | BGRT_SHOW(xoffset, image_offset_x); |
| 30 | 30 | BGRT_SHOW(yoffset, image_offset_y); |
| 31 | 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 */ | |
| 32 | +static BIN_ATTR_SIMPLE_RO(image); | |
| 40 | 33 | |
| 41 | 34 | static struct attribute *bgrt_attributes[] = { |
| 42 | 35 | &bgrt_attr_version.attr, |
| @@ -192,11 +192,14 @@ extern struct kset *devices_kset; · 191 unmodified lines | ||
| 192 | 192 | void devices_kset_move_last(struct device *dev); |
| 193 | 193 | |
| 194 | 194 | #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) |
| 195 | −void module_add_driver(struct module *mod, struct device_driver *drv); | |
| 195 | +int module_add_driver(struct module *mod, struct device_driver *drv); | |
| 196 | 196 | void module_remove_driver(struct device_driver *drv); |
| 197 | 197 | #else |
| 198 | −static inline void module_add_driver(struct module *mod, | |
| 199 | − struct device_driver *drv) { } | |
| 198 | +static inline int module_add_driver(struct module *mod, | |
| 199 | + struct device_driver *drv) | |
| 200 | +{ | |
| 201 | + return 0; | |
| 202 | +} | |
| 200 | 203 | static inline void module_remove_driver(struct device_driver *drv) { } |
| 201 | 204 | #endif |
| 202 | 205 | |
| @@ -674,7 +674,12 @@ int bus_add_driver(struct device_driver *drv) · 673 unmodified lines | ||
| 674 | 674 | if (error) |
| 675 | 675 | goto out_del_list; |
| 676 | 676 | } |
| 677 | − module_add_driver(drv->owner, drv); | |
| 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 | + } | |
| 678 | 683 | |
| 679 | 684 | error = driver_create_file(drv, &driver_attr_uevent); |
| 680 | 685 | if (error) { |
| @@ -699,6 +704,8 @@ int bus_add_driver(struct device_driver *drv) · 18 unmodified lines | ||
| 699 | 704 | |
| 700 | 705 | return 0; |
| 701 | 706 | |
| 707 | +out_detach: | |
| 708 | + driver_detach(drv); | |
| 702 | 709 | out_del_list: |
| 703 | 710 | klist_del(&priv->knode_bus); |
| 704 | 711 | out_unregister: |
| @@ -2346,8 +2346,6 @@ static void fw_devlink_link_device(struct device *dev) · 2345 unmodified lines | ||
| 2346 | 2346 | |
| 2347 | 2347 | /* Device links support end. */ |
| 2348 | 2348 | |
| 2349 | −int (*platform_notify)(struct device *dev) = NULL; | |
| 2350 | −int (*platform_notify_remove)(struct device *dev) = NULL; | |
| 2351 | 2349 | static struct kobject *dev_kobj; |
| 2352 | 2350 | |
| 2353 | 2351 | /* /sys/dev/char */ |
| @@ -2395,16 +2393,10 @@ static void device_platform_notify(struct device *dev) · 41 unmodified lines | ||
| 2395 | 2393 | acpi_device_notify(dev); |
| 2396 | 2394 | |
| 2397 | 2395 | software_node_notify(dev); |
| 2398 | − | |
| 2399 | − if (platform_notify) | |
| 2400 | − platform_notify(dev); | |
| 2401 | 2396 | } |
| 2402 | 2397 | |
| 2403 | 2398 | static void device_platform_notify_remove(struct device *dev) |
| 2404 | 2399 | { |
| 2405 | − if (platform_notify_remove) | |
| 2406 | − platform_notify_remove(dev); | |
| 2407 | − | |
| 2408 | 2400 | software_node_notify_remove(dev); |
| 2409 | 2401 | |
| 2410 | 2402 | acpi_device_notify_remove(dev); |
| @@ -2546,6 +2538,15 @@ ssize_t device_show_bool(struct device *dev, struct device_attribute *attr, · 135 unmodified lines | ||
| 2546 | 2538 | } |
| 2547 | 2539 | EXPORT_SYMBOL_GPL(device_show_bool); |
| 2548 | 2540 | |
| 2541 | +ssize_t device_show_string(struct device *dev, | |
| 2542 | + struct device_attribute *attr, char *buf) | |
| 2543 | +{ | |
| 2544 | + struct dev_ext_attribute *ea = to_ext_attr(attr); | |
| 2545 | + | |
| 2546 | + return sysfs_emit(buf, "%s\n", (char *)ea->var); | |
| 2547 | +} | |
| 2548 | +EXPORT_SYMBOL_GPL(device_show_string); | |
| 2549 | + | |
| 2549 | 2550 | /** |
| 2550 | 2551 | * device_release - free device structure. |
| 2551 | 2552 | * @kobj: device's kobject. |
| @@ -30,14 +30,14 @@ static void module_create_drivers_dir(struct module_kobject *mk) · 29 unmodified lines | ||
| 30 | 30 | mutex_unlock(&drivers_dir_mutex); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | −void module_add_driver(struct module *mod, struct device_driver *drv) | |
| 33 | +int module_add_driver(struct module *mod, struct device_driver *drv) | |
| 34 | 34 | { |
| 35 | 35 | char *driver_name; |
| 36 | − int no_warn; | |
| 37 | 36 | struct module_kobject *mk = NULL; |
| 37 | + int ret; | |
| 38 | 38 | |
| 39 | 39 | if (!drv) |
| 40 | − return; | |
| 40 | + return 0; | |
| 41 | 41 | |
| 42 | 42 | if (mod) |
| 43 | 43 | mk = &mod->mkobj; |
| @@ -56,17 +56,37 @@ void module_add_driver(struct module *mod, struct device_driver *drv) · 12 unmodified lines | ||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if (!mk) |
| 59 | − return; | |
| 59 | + return 0; | |
| 60 | + | |
| 61 | + ret = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module"); | |
| 62 | + if (ret) | |
| 63 | + return ret; | |
| 60 | 64 | |
| 61 | − /* Don't check return codes; these calls are idempotent */ | |
| 62 | − no_warn = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module"); | |
| 63 | 65 | 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); | |
| 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; | |
| 69 | 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; | |
| 70 | 90 | } |
| 71 | 91 | |
| 72 | 92 | void module_remove_driver(struct device_driver *drv) |
| @@ -905,7 +905,7 @@ EXPORT_SYMBOL_GPL(fwnode_device_is_available); · 904 unmodified lines | ||
| 905 | 905 | |
| 906 | 906 | /** |
| 907 | 907 | * device_get_child_node_count - return the number of child nodes for device |
| 908 | − * @dev: Device to cound the child nodes for | |
| 908 | + * @dev: Device to count the child nodes for | |
| 909 | 909 | * |
| 910 | 910 | * Return: the number of child nodes for a given device. |
| 911 | 911 | */ |
| @@ -761,16 +761,8 @@ static void __init dmi_scan_machine(void) · 760 unmodified lines | ||
| 761 | 761 | pr_info("DMI not present or invalid.\n"); |
| 762 | 762 | } |
| 763 | 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); | |
| 764 | +static BIN_ATTR_SIMPLE_ADMIN_RO(smbios_entry_point); | |
| 765 | +static BIN_ATTR_SIMPLE_ADMIN_RO(DMI); | |
| 774 | 766 | |
| 775 | 767 | static int __init dmi_init(void) |
| 776 | 768 | { |
| @@ -40,15 +40,7 @@ static u8 *rci2_base; · 39 unmodified lines | ||
| 40 | 40 | static u32 rci2_table_len; |
| 41 | 41 | unsigned long rci2_table_phys __ro_after_init = EFI_INVALID_TABLE_ADDR; |
| 42 | 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); | |
| 43 | +static BIN_ATTR_SIMPLE_ADMIN_RO(rci2); | |
| 52 | 44 | |
| 53 | 45 | static u16 checksum(void) |
| 54 | 46 | { |
| @@ -51,21 +51,7 @@ struct gvt_firmware_header { · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | #define dev_to_drm_minor(d) dev_get_drvdata((d)) |
| 53 | 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 | −}; | |
| 54 | +static BIN_ATTR_SIMPLE_ADMIN_RO(gvt_firmware); | |
| 69 | 55 | |
| 70 | 56 | static int expose_firmware_sysfs(struct intel_gvt *gvt) |
| 71 | 57 | { |
| @@ -108,10 +94,10 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) · 36 unmodified lines | ||
| 108 | 94 | crc32_start = offsetof(struct gvt_firmware_header, version); |
| 109 | 95 | h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); |
| 110 | 96 | |
| 111 | − firmware_attr.size = size; | |
| 112 | − firmware_attr.private = firmware; | |
| 97 | + bin_attr_gvt_firmware.size = size; | |
| 98 | + bin_attr_gvt_firmware.private = firmware; | |
| 113 | 99 | |
| 114 | − ret = device_create_bin_file(&pdev->dev, &firmware_attr); | |
| 100 | + ret = device_create_bin_file(&pdev->dev, &bin_attr_gvt_firmware); | |
| 115 | 101 | if (ret) { |
| 116 | 102 | vfree(firmware); |
| 117 | 103 | return ret; |
| @@ -123,8 +109,8 @@ static void clean_firmware_sysfs(struct intel_gvt *gvt) · 5 unmodified lines | ||
| 123 | 109 | { |
| 124 | 110 | struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); |
| 125 | 111 | |
| 126 | − device_remove_bin_file(&pdev->dev, &firmware_attr); | |
| 127 | − vfree(firmware_attr.private); | |
| 112 | + device_remove_bin_file(&pdev->dev, &bin_attr_gvt_firmware); | |
| 113 | + vfree(bin_attr_gvt_firmware.private); | |
| 128 | 114 | } |
| 129 | 115 | |
| 130 | 116 | /** |
| @@ -101,14 +101,7 @@ struct i5k_amb_data { · 100 unmodified lines | ||
| 101 | 101 | unsigned int num_attrs; |
| 102 | 102 | }; |
| 103 | 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); | |
| 104 | +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); | |
| 112 | 105 | |
| 113 | 106 | static struct platform_device *amb_pdev; |
| 114 | 107 | |
| @@ -373,7 +366,7 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) · 258 unmodified lines | ||
| 373 | 366 | } |
| 374 | 367 | } |
| 375 | 368 | |
| 376 | − res = device_create_file(&pdev->dev, &dev_attr_name); | |
| 369 | + res = device_create_file(&pdev->dev, &dev_attr_name.attr); | |
| 377 | 370 | if (res) |
| 378 | 371 | goto exit_remove; |
| 379 | 372 | |
| @@ -386,7 +379,7 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) · 6 unmodified lines | ||
| 386 | 379 | return res; |
| 387 | 380 | |
| 388 | 381 | exit_remove: |
| 389 | − device_remove_file(&pdev->dev, &dev_attr_name); | |
| 382 | + device_remove_file(&pdev->dev, &dev_attr_name.attr); | |
| 390 | 383 | for (i = 0; i < data->num_attrs; i++) |
| 391 | 384 | device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); |
| 392 | 385 | kfree(data->attrs); |
| @@ -561,7 +554,7 @@ static void i5k_amb_remove(struct platform_device *pdev) · 168 unmodified lines | ||
| 561 | 554 | struct i5k_amb_data *data = platform_get_drvdata(pdev); |
| 562 | 555 | |
| 563 | 556 | hwmon_device_unregister(data->hwmon_dev); |
| 564 | − device_remove_file(&pdev->dev, &dev_attr_name); | |
| 557 | + device_remove_file(&pdev->dev, &dev_attr_name.attr); | |
| 565 | 558 | for (i = 0; i < data->num_attrs; i++) |
| 566 | 559 | device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr); |
| 567 | 560 | kfree(data->attrs); |
| @@ -256,12 +256,7 @@ static struct ibmpex_bmc_data *get_bmc_data(int iface) · 255 unmodified lines | ||
| 256 | 256 | return NULL; |
| 257 | 257 | } |
| 258 | 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); | |
| 259 | +static DEVICE_STRING_ATTR_RO(name, 0444, DRVNAME); | |
| 265 | 260 | |
| 266 | 261 | static ssize_t ibmpex_show_sensor(struct device *dev, |
| 267 | 262 | struct device_attribute *devattr, |
| @@ -415,8 +410,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) · 147 unmodified lines | ||
| 415 | 410 | if (err) |
| 416 | 411 | goto exit_remove; |
| 417 | 412 | |
| 418 | − err = device_create_file(data->bmc_device, | |
| 419 | − &sensor_dev_attr_name.dev_attr); | |
| 413 | + err = device_create_file(data->bmc_device, &dev_attr_name.attr); | |
| 420 | 414 | if (err) |
| 421 | 415 | goto exit_remove; |
| 422 | 416 | |
| @@ -425,7 +419,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) · 2 unmodified lines | ||
| 425 | 419 | exit_remove: |
| 426 | 420 | device_remove_file(data->bmc_device, |
| 427 | 421 | &sensor_dev_attr_reset_high_low.dev_attr); |
| 428 | − device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); | |
| 422 | + device_remove_file(data->bmc_device, &dev_attr_name.attr); | |
| 429 | 423 | for (i = 0; i < data->num_sensors; i++) |
| 430 | 424 | for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { |
| 431 | 425 | if (!data->sensors[i].attr[j].dev_attr.attr.name) |
| @@ -516,7 +510,7 @@ static void ibmpex_bmc_delete(struct ibmpex_bmc_data *data) · 84 unmodified lines | ||
| 516 | 510 | |
| 517 | 511 | device_remove_file(data->bmc_device, |
| 518 | 512 | &sensor_dev_attr_reset_high_low.dev_attr); |
| 519 | − device_remove_file(data->bmc_device, &sensor_dev_attr_name.dev_attr); | |
| 513 | + device_remove_file(data->bmc_device, &dev_attr_name.attr); | |
| 520 | 514 | for (i = 0; i < data->num_sensors; i++) |
| 521 | 515 | for (j = 0; j < PEX_NUM_SENSOR_FUNCS; j++) { |
| 522 | 516 | if (!data->sensors[i].attr[j].dev_attr.attr.name) |
| @@ -1359,7 +1359,6 @@ static inline u32 qib_get_rcvhdrtail(const struct qib_ctxtdata *rcd) · 1358 unmodified lines | ||
| 1359 | 1359 | * sysfs interface. |
| 1360 | 1360 | */ |
| 1361 | 1361 | |
| 1362 | −extern const char ib_qib_version[]; | |
| 1363 | 1362 | extern const struct attribute_group qib_attr_group; |
| 1364 | 1363 | extern const struct attribute_group *qib_attr_port_groups[]; |
| 1365 | 1364 | |
| @@ -44,12 +44,6 @@ · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | #include "qib.h" |
| 46 | 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 | 47 | DEFINE_MUTEX(qib_mutex); /* general driver use */ |
| 54 | 48 | |
| 55 | 49 | unsigned qib_ibmtu; |
| @@ -585,13 +585,7 @@ static ssize_t hca_type_show(struct device *device, · 584 unmodified lines | ||
| 585 | 585 | static DEVICE_ATTR_RO(hca_type); |
| 586 | 586 | static DEVICE_ATTR(board_id, 0444, hca_type_show, NULL); |
| 587 | 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); | |
| 588 | +static DEVICE_STRING_ATTR_RO(version, 0444, QIB_DRIVER_VERSION); | |
| 595 | 589 | |
| 596 | 590 | static ssize_t boardversion_show(struct device *device, |
| 597 | 591 | struct device_attribute *attr, char *buf) |
| @@ -721,7 +715,7 @@ static struct attribute *qib_attributes[] = { · 123 unmodified lines | ||
| 721 | 715 | &dev_attr_hw_rev.attr, |
| 722 | 716 | &dev_attr_hca_type.attr, |
| 723 | 717 | &dev_attr_board_id.attr, |
| 724 | − &dev_attr_version.attr, | |
| 718 | + &dev_attr_version.attr.attr, | |
| 725 | 719 | &dev_attr_nctxts.attr, |
| 726 | 720 | &dev_attr_nfreectxts.attr, |
| 727 | 721 | &dev_attr_serial.attr, |
| @@ -236,24 +236,16 @@ static const struct attribute_group ali_drw_pmu_cpumask_attr_group = { · 235 unmodified lines | ||
| 236 | 236 | .attrs = ali_drw_pmu_cpumask_attrs, |
| 237 | 237 | }; |
| 238 | 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 | 239 | static umode_t ali_drw_pmu_identifier_attr_visible(struct kobject *kobj, |
| 247 | 240 | struct attribute *attr, int n) |
| 248 | 241 | { |
| 249 | 242 | return attr->mode; |
| 250 | 243 | } |
| 251 | 244 | |
| 252 | −static struct device_attribute ali_drw_pmu_identifier_attr = | |
| 253 | − __ATTR(identifier, 0444, ali_drw_pmu_identifier_show, NULL); | |
| 245 | +static DEVICE_STRING_ATTR_RO(ali_drw_pmu_identifier, 0444, "ali_drw_pmu"); | |
| 254 | 246 | |
| 255 | 247 | static struct attribute *ali_drw_pmu_identifier_attrs[] = { |
| 256 | − &ali_drw_pmu_identifier_attr.attr, | |
| 248 | + &dev_attr_ali_drw_pmu_identifier.attr.attr, | |
| 257 | 249 | NULL |
| 258 | 250 | }; |
| 259 | 251 | |
| @@ -127,8 +127,6 @@ enum cci_models { · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | static void pmu_write_counters(struct cci_pmu *cci_pmu, |
| 129 | 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 | 130 | static ssize_t __maybe_unused cci_pmu_event_show(struct device *dev, |
| 133 | 131 | struct device_attribute *attr, char *buf); |
| 134 | 132 | |
| @@ -138,7 +136,7 @@ static ssize_t __maybe_unused cci_pmu_event_show(struct device *dev, · 3 unmodified lines | ||
| 138 | 136 | })[0].attr.attr |
| 139 | 137 | |
| 140 | 138 | #define CCI_FORMAT_EXT_ATTR_ENTRY(_name, _config) \ |
| 141 | − CCI_EXT_ATTR_ENTRY(_name, cci_pmu_format_show, (char *)_config) | |
| 139 | + CCI_EXT_ATTR_ENTRY(_name, device_show_string, _config) | |
| 142 | 140 | #define CCI_EVENT_EXT_ATTR_ENTRY(_name, _config) \ |
| 143 | 141 | CCI_EXT_ATTR_ENTRY(_name, cci_pmu_event_show, (unsigned long)_config) |
| 144 | 142 | |
| @@ -688,14 +686,6 @@ static void __cci_pmu_disable(struct cci_pmu *cci_pmu) · 543 unmodified lines | ||
| 688 | 686 | writel(val, cci_pmu->ctrl_base + CCI_PMCR); |
| 689 | 687 | } |
| 690 | 688 | |
| 691 | −static ssize_t cci_pmu_format_show(struct device *dev, | |
| 692 | − struct device_attribute *attr, char *buf) | |
| 693 | −{ | |
| 694 | − struct dev_ext_attribute *eattr = container_of(attr, | |
| 695 | − struct dev_ext_attribute, attr); | |
| 696 | − return sysfs_emit(buf, "%s\n", (char *)eattr->var); | |
| 697 | −} | |
| 698 | − | |
| 699 | 689 | static ssize_t cci_pmu_event_show(struct device *dev, |
| 700 | 690 | struct device_attribute *attr, char *buf) |
| 701 | 691 | { |
| @@ -215,18 +215,9 @@ static void arm_ccn_pmu_config_set(u64 *config, u32 node_xp, u32 type, u32 port) · 214 unmodified lines | ||
| 215 | 215 | *config |= (node_xp << 0) | (type << 8) | (port << 24); |
| 216 | 216 | } |
| 217 | 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 | 218 | #define CCN_FORMAT_ATTR(_name, _config) \ |
| 228 | 219 | struct dev_ext_attribute arm_ccn_pmu_format_attr_##_name = \ |
| 229 | − { __ATTR(_name, S_IRUGO, arm_ccn_pmu_format_show, \ | |
| 220 | + { __ATTR(_name, S_IRUGO, device_show_string, \ | |
| 230 | 221 | NULL), _config } |
| 231 | 222 | |
| 232 | 223 | static CCN_FORMAT_ATTR(node, "config:0-7"); |
| @@ -223,16 +223,6 @@ arm_cspmu_event_attr_is_visible(struct kobject *kobj, · 222 unmodified lines | ||
| 223 | 223 | return attr->mode; |
| 224 | 224 | } |
| 225 | 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 | 226 | static struct attribute *arm_cspmu_format_attrs[] = { |
| 237 | 227 | ARM_CSPMU_FORMAT_EVENT_ATTR, |
| 238 | 228 | ARM_CSPMU_FORMAT_FILTER_ATTR, |
| @@ -28,7 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | })[0].attr.attr) |
| 29 | 29 | |
| 30 | 30 | #define ARM_CSPMU_FORMAT_ATTR(_name, _config) \ |
| 31 | − ARM_CSPMU_EXT_ATTR(_name, arm_cspmu_sysfs_format_show, (char *)_config) | |
| 31 | + ARM_CSPMU_EXT_ATTR(_name, device_show_string, _config) | |
| 32 | 32 | |
| 33 | 33 | #define ARM_CSPMU_EVENT_ATTR(_name, _config) \ |
| 34 | 34 | PMU_EVENT_ATTR_ID(_name, arm_cspmu_sysfs_event_show, _config) |
| @@ -167,11 +167,6 @@ ssize_t arm_cspmu_sysfs_event_show(struct device *dev, · 132 unmodified lines | ||
| 167 | 167 | struct device_attribute *attr, |
| 168 | 168 | char *buf); |
| 169 | 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 | 170 | /* Register vendor backend. */ |
| 176 | 171 | int arm_cspmu_impl_register(const struct arm_cspmu_impl_match *impl_match); |
| 177 | 172 | |
| @@ -85,7 +85,7 @@ · 84 unmodified lines | ||
| 85 | 85 | DSU_EXT_ATTR(_name, dsu_pmu_sysfs_event_show, (unsigned long)_config) |
| 86 | 86 | |
| 87 | 87 | #define DSU_FORMAT_ATTR(_name, _config) \ |
| 88 | − DSU_EXT_ATTR(_name, dsu_pmu_sysfs_format_show, (char *)_config) | |
| 88 | + DSU_EXT_ATTR(_name, device_show_string, _config) | |
| 89 | 89 | |
| 90 | 90 | #define DSU_CPUMASK_ATTR(_name, _config) \ |
| 91 | 91 | DSU_EXT_ATTR(_name, dsu_pmu_cpumask_show, (unsigned long)_config) |
| @@ -139,15 +139,6 @@ static ssize_t dsu_pmu_sysfs_event_show(struct device *dev, · 47 unmodified lines | ||
| 139 | 139 | return sysfs_emit(buf, "event=0x%lx\n", (unsigned long)eattr->var); |
| 140 | 140 | } |
| 141 | 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 | 142 | static ssize_t dsu_pmu_cpumask_show(struct device *dev, |
| 152 | 143 | struct device_attribute *attr, |
| 153 | 144 | char *buf) |
| @@ -208,21 +208,10 @@ static int cxl_pmu_parse_caps(struct device *dev, struct cxl_pmu_info *info) · 207 unmodified lines | ||
| 208 | 208 | return 0; |
| 209 | 209 | } |
| 210 | 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 | 211 | #define CXL_PMU_FORMAT_ATTR(_name, _format)\ |
| 222 | 212 | (&((struct dev_ext_attribute[]) { \ |
| 223 | 213 | { \ |
| 224 | − .attr = __ATTR(_name, 0444, \ | |
| 225 | − cxl_pmu_format_sysfs_show, NULL), \ | |
| 214 | + .attr = __ATTR(_name, 0444, device_show_string, NULL), \ | |
| 226 | 215 | .var = (void *)_format \ |
| 227 | 216 | } \ |
| 228 | 217 | })[0].attr.attr) |
| @@ -99,16 +99,6 @@ HISI_PCIE_PMU_FILTER_ATTR(len_mode, config1, 11, 10); · 98 unmodified lines | ||
| 99 | 99 | HISI_PCIE_PMU_FILTER_ATTR(port, config2, 15, 0); |
| 100 | 100 | HISI_PCIE_PMU_FILTER_ATTR(bdf, config2, 31, 16); |
| 101 | 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 | 102 | static ssize_t hisi_pcie_event_sysfs_show(struct device *dev, struct device_attribute *attr, |
| 113 | 103 | char *buf) |
| 114 | 104 | { |
| @@ -120,8 +110,7 @@ static ssize_t hisi_pcie_event_sysfs_show(struct device *dev, struct device_attr · 5 unmodified lines | ||
| 120 | 110 | |
| 121 | 111 | #define HISI_PCIE_PMU_FORMAT_ATTR(_name, _format) \ |
| 122 | 112 | (&((struct dev_ext_attribute[]){ \ |
| 123 | − { .attr = __ATTR(_name, 0444, hisi_pcie_format_sysfs_show, \ | |
| 124 | − NULL), \ | |
| 113 | + { .attr = __ATTR(_name, 0444, device_show_string, NULL), \ | |
| 125 | 114 | .var = (void *)_format } \ |
| 126 | 115 | })[0].attr.attr) |
| 127 | 116 | |
| @@ -22,20 +22,6 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #define HISI_MAX_PERIOD(nr) (GENMASK_ULL((nr) - 1, 0)) |
| 24 | 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 | 25 | /* |
| 40 | 26 | * PMU event attributes |
| 41 | 27 | */ |
| @@ -33,7 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | })[0].attr.attr) |
| 34 | 34 | |
| 35 | 35 | #define HISI_PMU_FORMAT_ATTR(_name, _config) \ |
| 36 | − HISI_PMU_ATTR(_name, hisi_format_sysfs_show, (void *)_config) | |
| 36 | + HISI_PMU_ATTR(_name, device_show_string, _config) | |
| 37 | 37 | #define HISI_PMU_EVENT_ATTR(_name, _config) \ |
| 38 | 38 | HISI_PMU_ATTR(_name, hisi_event_sysfs_show, (unsigned long)_config) |
| 39 | 39 | |
| @@ -122,8 +122,6 @@ void hisi_uncore_pmu_enable(struct pmu *pmu); · 82 unmodified lines | ||
| 122 | 122 | void hisi_uncore_pmu_disable(struct pmu *pmu); |
| 123 | 123 | ssize_t hisi_event_sysfs_show(struct device *dev, |
| 124 | 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 | 125 | ssize_t hisi_cpumask_sysfs_show(struct device *dev, |
| 128 | 126 | struct device_attribute *attr, char *buf); |
| 129 | 127 | int hisi_uncore_pmu_online_cpu(unsigned int cpu, struct hlist_node *node); |
| @@ -363,16 +363,6 @@ HNS3_PMU_FILTER_ATTR(global, config1, 52, 52); · 362 unmodified lines | ||
| 363 | 363 | HNS3_PMU_EVT_PPS_##_name##_TIME, \ |
| 364 | 364 | HNS3_PMU_FILTER_INTR_##_name}) |
| 365 | 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 | 366 | static ssize_t hns3_pmu_event_show(struct device *dev, |
| 377 | 367 | struct device_attribute *attr, char *buf) |
| 378 | 368 | { |
| @@ -421,7 +411,7 @@ static ssize_t hns3_pmu_filter_mode_show(struct device *dev, · 42 unmodified lines | ||
| 421 | 411 | })[0].attr.attr) |
| 422 | 412 | |
| 423 | 413 | #define HNS3_PMU_FORMAT_ATTR(_name, _format) \ |
| 424 | − HNS3_PMU_ATTR(_name, hns3_pmu_format_show, (void *)_format) | |
| 414 | + HNS3_PMU_ATTR(_name, device_show_string, _format) | |
| 425 | 415 | #define HNS3_PMU_EVENT_ATTR(_name, _event) \ |
| 426 | 416 | HNS3_PMU_ATTR(_name, hns3_pmu_event_show, (void *)_event) |
| 427 | 417 | #define HNS3_PMU_FLT_MODE_ATTR(_name, _event) \ |
| @@ -609,18 +609,9 @@ static void qcom_l3_cache__event_read(struct perf_event *event) · 608 unmodified lines | ||
| 609 | 609 | |
| 610 | 610 | /* formats */ |
| 611 | 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 | 612 | #define L3CACHE_PMU_FORMAT_ATTR(_name, _config) \ |
| 622 | 613 | (&((struct dev_ext_attribute[]) { \ |
| 623 | − { .attr = __ATTR(_name, 0444, l3cache_pmu_format_show, NULL), \ | |
| 614 | + { .attr = __ATTR(_name, 0444, device_show_string, NULL), \ | |
| 624 | 615 | .var = (void *) _config, } \ |
| 625 | 616 | })[0].attr.attr) |
| 626 | 617 | |
| @@ -162,18 +162,9 @@ enum xgene_pmu_dev_type { · 161 unmodified lines | ||
| 162 | 162 | /* |
| 163 | 163 | * sysfs format attributes |
| 164 | 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 | 165 | #define XGENE_PMU_FORMAT_ATTR(_name, _config) \ |
| 175 | 166 | (&((struct dev_ext_attribute[]) { \ |
| 176 | − { .attr = __ATTR(_name, S_IRUGO, xgene_pmu_format_show, NULL), \ | |
| 167 | + { .attr = __ATTR(_name, S_IRUGO, device_show_string, NULL), \ | |
| 177 | 168 | .var = (void *) _config, } \ |
| 178 | 169 | })[0].attr.attr) |
| 179 | 170 | |
| @@ -925,17 +925,12 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, · 924 unmodified lines | ||
| 925 | 925 | } |
| 926 | 926 | static DEVICE_ATTR_WO(kbd_rgb_mode); |
| 927 | 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); | |
| 928 | +static DEVICE_STRING_ATTR_RO(kbd_rgb_mode_index, 0444, | |
| 929 | + "cmd mode red green blue speed"); | |
| 935 | 930 | |
| 936 | 931 | static struct attribute *kbd_rgb_mode_attrs[] = { |
| 937 | 932 | &dev_attr_kbd_rgb_mode.attr, |
| 938 | − &dev_attr_kbd_rgb_mode_index.attr, | |
| 933 | + &dev_attr_kbd_rgb_mode_index.attr.attr, | |
| 939 | 934 | NULL, |
| 940 | 935 | }; |
| 941 | 936 | |
| @@ -977,17 +972,12 @@ static ssize_t kbd_rgb_state_store(struct device *dev, · 35 unmodified lines | ||
| 977 | 972 | } |
| 978 | 973 | static DEVICE_ATTR_WO(kbd_rgb_state); |
| 979 | 974 | |
| 980 | −static ssize_t kbd_rgb_state_index_show(struct device *device, | |
| 981 | − struct device_attribute *attr, | |
| 982 | − char *buf) | |
| 983 | −{ | |
| 984 | − return sysfs_emit(buf, "%s\n", "cmd boot awake sleep keyboard"); | |
| 985 | −} | |
| 986 | −static DEVICE_ATTR_RO(kbd_rgb_state_index); | |
| 975 | +static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444, | |
| 976 | + "cmd boot awake sleep keyboard"); | |
| 987 | 977 | |
| 988 | 978 | static struct attribute *kbd_rgb_state_attrs[] = { |
| 989 | 979 | &dev_attr_kbd_rgb_state.attr, |
| 990 | − &dev_attr_kbd_rgb_state_index.attr, | |
| 980 | + &dev_attr_kbd_rgb_state_index.attr.attr, | |
| 991 | 981 | NULL, |
| 992 | 982 | }; |
| 993 | 983 | |
| @@ -2718,13 +2708,6 @@ static ssize_t pwm1_enable_store(struct device *dev, · 1724 unmodified lines | ||
| 2718 | 2708 | return count; |
| 2719 | 2709 | } |
| 2720 | 2710 | |
| 2721 | −static ssize_t fan1_label_show(struct device *dev, | |
| 2722 | − struct device_attribute *attr, | |
| 2723 | − char *buf) | |
| 2724 | −{ | |
| 2725 | − return sysfs_emit(buf, "%s\n", ASUS_FAN_DESC); | |
| 2726 | −} | |
| 2727 | − | |
| 2728 | 2711 | static ssize_t asus_hwmon_temp1(struct device *dev, |
| 2729 | 2712 | struct device_attribute *attr, |
| 2730 | 2713 | char *buf) |
| @@ -2759,13 +2742,6 @@ static ssize_t fan2_input_show(struct device *dev, · 28 unmodified lines | ||
| 2759 | 2742 | return sysfs_emit(buf, "%d\n", value * 100); |
| 2760 | 2743 | } |
| 2761 | 2744 | |
| 2762 | −static ssize_t fan2_label_show(struct device *dev, | |
| 2763 | − struct device_attribute *attr, | |
| 2764 | − char *buf) | |
| 2765 | −{ | |
| 2766 | − return sysfs_emit(buf, "%s\n", ASUS_GPU_FAN_DESC); | |
| 2767 | −} | |
| 2768 | − | |
| 2769 | 2745 | /* Middle/Center fan on modern ROG laptops */ |
| 2770 | 2746 | static ssize_t fan3_input_show(struct device *dev, |
| 2771 | 2747 | struct device_attribute *attr, |
| @@ -2784,13 +2760,6 @@ static ssize_t fan3_input_show(struct device *dev, · 12 unmodified lines | ||
| 2784 | 2760 | return sysfs_emit(buf, "%d\n", value * 100); |
| 2785 | 2761 | } |
| 2786 | 2762 | |
| 2787 | −static ssize_t fan3_label_show(struct device *dev, | |
| 2788 | − struct device_attribute *attr, | |
| 2789 | − char *buf) | |
| 2790 | −{ | |
| 2791 | − return sysfs_emit(buf, "%s\n", ASUS_MID_FAN_DESC); | |
| 2792 | −} | |
| 2793 | − | |
| 2794 | 2763 | static ssize_t pwm2_enable_show(struct device *dev, |
| 2795 | 2764 | struct device_attribute *attr, |
| 2796 | 2765 | char *buf) |
| @@ -2887,15 +2856,16 @@ static ssize_t pwm3_enable_store(struct device *dev, · 90 unmodified lines | ||
| 2887 | 2856 | static DEVICE_ATTR_RW(pwm1); |
| 2888 | 2857 | static DEVICE_ATTR_RW(pwm1_enable); |
| 2889 | 2858 | static DEVICE_ATTR_RO(fan1_input); |
| 2890 | −static DEVICE_ATTR_RO(fan1_label); | |
| 2859 | +static DEVICE_STRING_ATTR_RO(fan1_label, 0444, ASUS_FAN_DESC); | |
| 2860 | + | |
| 2891 | 2861 | /* Fan2 - GPU fan */ |
| 2892 | 2862 | static DEVICE_ATTR_RW(pwm2_enable); |
| 2893 | 2863 | static DEVICE_ATTR_RO(fan2_input); |
| 2894 | −static DEVICE_ATTR_RO(fan2_label); | |
| 2864 | +static DEVICE_STRING_ATTR_RO(fan2_label, 0444, ASUS_GPU_FAN_DESC); | |
| 2895 | 2865 | /* Fan3 - Middle/center fan */ |
| 2896 | 2866 | static DEVICE_ATTR_RW(pwm3_enable); |
| 2897 | 2867 | static DEVICE_ATTR_RO(fan3_input); |
| 2898 | −static DEVICE_ATTR_RO(fan3_label); | |
| 2868 | +static DEVICE_STRING_ATTR_RO(fan3_label, 0444, ASUS_MID_FAN_DESC); | |
| 2899 | 2869 | |
| 2900 | 2870 | /* Temperature */ |
| 2901 | 2871 | static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL); |
| @@ -2906,11 +2876,11 @@ static struct attribute *hwmon_attributes[] = { · 4 unmodified lines | ||
| 2906 | 2876 | &dev_attr_pwm2_enable.attr, |
| 2907 | 2877 | &dev_attr_pwm3_enable.attr, |
| 2908 | 2878 | &dev_attr_fan1_input.attr, |
| 2909 | − &dev_attr_fan1_label.attr, | |
| 2879 | + &dev_attr_fan1_label.attr.attr, | |
| 2910 | 2880 | &dev_attr_fan2_input.attr, |
| 2911 | − &dev_attr_fan2_label.attr, | |
| 2881 | + &dev_attr_fan2_label.attr.attr, | |
| 2912 | 2882 | &dev_attr_fan3_input.attr, |
| 2913 | − &dev_attr_fan3_label.attr, | |
| 2883 | + &dev_attr_fan3_label.attr.attr, | |
| 2914 | 2884 | |
| 2915 | 2885 | &dev_attr_temp1_input.attr, |
| 2916 | 2886 | NULL |
| @@ -2927,17 +2897,17 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, · 10 unmodified lines | ||
| 2927 | 2897 | if (asus->fan_type != FAN_TYPE_AGFN) |
| 2928 | 2898 | return 0; |
| 2929 | 2899 | } else if (attr == &dev_attr_fan1_input.attr |
| 2930 | − || attr == &dev_attr_fan1_label.attr | |
| 2900 | + || attr == &dev_attr_fan1_label.attr.attr | |
| 2931 | 2901 | || attr == &dev_attr_pwm1_enable.attr) { |
| 2932 | 2902 | if (asus->fan_type == FAN_TYPE_NONE) |
| 2933 | 2903 | return 0; |
| 2934 | 2904 | } else if (attr == &dev_attr_fan2_input.attr |
| 2935 | − || attr == &dev_attr_fan2_label.attr | |
| 2905 | + || attr == &dev_attr_fan2_label.attr.attr | |
| 2936 | 2906 | || attr == &dev_attr_pwm2_enable.attr) { |
| 2937 | 2907 | if (asus->gpu_fan_type == FAN_TYPE_NONE) |
| 2938 | 2908 | return 0; |
| 2939 | 2909 | } else if (attr == &dev_attr_fan3_input.attr |
| 2940 | − || attr == &dev_attr_fan3_label.attr | |
| 2910 | + || attr == &dev_attr_fan3_label.attr.attr | |
| 2941 | 2911 | || attr == &dev_attr_pwm3_enable.attr) { |
| 2942 | 2912 | if (asus->mid_fan_type == FAN_TYPE_NONE) |
| 2943 | 2913 | return 0; |
| @@ -10828,13 +10828,7 @@ static struct ibm_struct auxmac_data = { · 10827 unmodified lines | ||
| 10828 | 10828 | .name = "auxmac", |
| 10829 | 10829 | }; |
| 10830 | 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); | |
| 10831 | +static DEVICE_STRING_ATTR_RO(auxmac, 0444, auxmac); | |
| 10838 | 10832 | |
| 10839 | 10833 | static umode_t auxmac_attr_is_visible(struct kobject *kobj, |
| 10840 | 10834 | struct attribute *attr, int n) |
| @@ -10843,7 +10837,7 @@ static umode_t auxmac_attr_is_visible(struct kobject *kobj, · 2 unmodified lines | ||
| 10843 | 10837 | } |
| 10844 | 10838 | |
| 10845 | 10839 | static struct attribute *auxmac_attributes[] = { |
| 10846 | − &dev_attr_auxmac.attr, | |
| 10840 | + &dev_attr_auxmac.attr.attr, | |
| 10847 | 10841 | NULL |
| 10848 | 10842 | }; |
| 10849 | 10843 | |
| @@ -1821,12 +1821,7 @@ static DECLARE_WORK(kbd_bl_work, toshiba_acpi_kbd_bl_work); · 1820 unmodified lines | ||
| 1821 | 1821 | /* |
| 1822 | 1822 | * Sysfs files |
| 1823 | 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); | |
| 1824 | +static DEVICE_STRING_ATTR_RO(version, 0444, TOSHIBA_ACPI_VERSION); | |
| 1830 | 1825 | |
| 1831 | 1826 | static ssize_t fan_store(struct device *dev, |
| 1832 | 1827 | struct device_attribute *attr, |
| @@ -2435,7 +2430,7 @@ static ssize_t cooling_method_store(struct device *dev, · 602 unmodified lines | ||
| 2435 | 2430 | static DEVICE_ATTR_RW(cooling_method); |
| 2436 | 2431 | |
| 2437 | 2432 | static struct attribute *toshiba_attributes[] = { |
| 2438 | − &dev_attr_version.attr, | |
| 2433 | + &dev_attr_version.attr.attr, | |
| 2439 | 2434 | &dev_attr_fan.attr, |
| 2440 | 2435 | &dev_attr_kbd_backlight_mode.attr, |
| 2441 | 2436 | &dev_attr_kbd_type.attr, |
| @@ -853,13 +853,6 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr, · 852 unmodified lines | ||
| 853 | 853 | return sysfs_emit(buf, "%s\n", hw_ver); |
| 854 | 854 | } |
| 855 | 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 | 856 | static ssize_t |
| 864 | 857 | bfad_im_optionrom_version_show(struct device *dev, |
| 865 | 858 | struct device_attribute *attr, char *buf) |
| @@ -901,13 +894,6 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr, · 35 unmodified lines | ||
| 901 | 894 | bfa_get_nports(&bfad->bfa)); |
| 902 | 895 | } |
| 903 | 896 | |
| 904 | −static ssize_t | |
| 905 | −bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr, | |
| 906 | − char *buf) | |
| 907 | −{ | |
| 908 | − return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME); | |
| 909 | −} | |
| 910 | − | |
| 911 | 897 | static ssize_t |
| 912 | 898 | bfad_im_num_of_discovered_ports_show(struct device *dev, |
| 913 | 899 | struct device_attribute *attr, char *buf) |
| @@ -944,15 +930,15 @@ static DEVICE_ATTR(symbolic_name, S_IRUGO, · 30 unmodified lines | ||
| 944 | 930 | bfad_im_symbolic_name_show, NULL); |
| 945 | 931 | static DEVICE_ATTR(hardware_version, S_IRUGO, |
| 946 | 932 | bfad_im_hw_version_show, NULL); |
| 947 | −static DEVICE_ATTR(driver_version, S_IRUGO, | |
| 948 | − bfad_im_drv_version_show, NULL); | |
| 933 | +static DEVICE_STRING_ATTR_RO(driver_version, S_IRUGO, | |
| 934 | + BFAD_DRIVER_VERSION); | |
| 949 | 935 | static DEVICE_ATTR(option_rom_version, S_IRUGO, |
| 950 | 936 | bfad_im_optionrom_version_show, NULL); |
| 951 | 937 | static DEVICE_ATTR(firmware_version, S_IRUGO, |
| 952 | 938 | bfad_im_fw_version_show, NULL); |
| 953 | 939 | static DEVICE_ATTR(number_of_ports, S_IRUGO, |
| 954 | 940 | bfad_im_num_of_ports_show, NULL); |
| 955 | −static DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL); | |
| 941 | +static DEVICE_STRING_ATTR_RO(driver_name, S_IRUGO, BFAD_DRIVER_NAME); | |
| 956 | 942 | static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO, |
| 957 | 943 | bfad_im_num_of_discovered_ports_show, NULL); |
| 958 | 944 | |
| @@ -963,11 +949,11 @@ static struct attribute *bfad_im_host_attrs[] = { · 4 unmodified lines | ||
| 963 | 949 | &dev_attr_node_name.attr, |
| 964 | 950 | &dev_attr_symbolic_name.attr, |
| 965 | 951 | &dev_attr_hardware_version.attr, |
| 966 | − &dev_attr_driver_version.attr, | |
| 952 | + &dev_attr_driver_version.attr.attr, | |
| 967 | 953 | &dev_attr_option_rom_version.attr, |
| 968 | 954 | &dev_attr_firmware_version.attr, |
| 969 | 955 | &dev_attr_number_of_ports.attr, |
| 970 | − &dev_attr_driver_name.attr, | |
| 956 | + &dev_attr_driver_name.attr.attr, | |
| 971 | 957 | &dev_attr_number_of_discovered_ports.attr, |
| 972 | 958 | NULL, |
| 973 | 959 | }; |
| @@ -988,11 +974,11 @@ static struct attribute *bfad_im_vport_attrs[] = { · 14 unmodified lines | ||
| 988 | 974 | &dev_attr_node_name.attr, |
| 989 | 975 | &dev_attr_symbolic_name.attr, |
| 990 | 976 | &dev_attr_hardware_version.attr, |
| 991 | − &dev_attr_driver_version.attr, | |
| 977 | + &dev_attr_driver_version.attr.attr, | |
| 992 | 978 | &dev_attr_option_rom_version.attr, |
| 993 | 979 | &dev_attr_firmware_version.attr, |
| 994 | 980 | &dev_attr_number_of_ports.attr, |
| 995 | − &dev_attr_driver_name.attr, | |
| 981 | + &dev_attr_driver_name.attr.attr, | |
| 996 | 982 | &dev_attr_number_of_discovered_ports.attr, |
| 997 | 983 | NULL, |
| 998 | 984 | }; |
| @@ -3613,12 +3613,6 @@ static void ibmvscsis_remove(struct vio_dev *vdev) · 3612 unmodified lines | ||
| 3613 | 3613 | kfree(vscsi); |
| 3614 | 3614 | } |
| 3615 | 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 | 3616 | static ssize_t partition_number_show(struct device *dev, |
| 3623 | 3617 | struct device_attribute *attr, char *buf) |
| 3624 | 3618 | { |
| @@ -3982,8 +3976,7 @@ static const struct target_core_fabric_ops ibmvscsis_ops = { · 357 unmodified lines | ||
| 3982 | 3976 | |
| 3983 | 3977 | static void ibmvscsis_dev_release(struct device *dev) {}; |
| 3984 | 3978 | |
| 3985 | −static struct device_attribute dev_attr_system_id = | |
| 3986 | − __ATTR(system_id, S_IRUGO, system_id_show, NULL); | |
| 3979 | +static DEVICE_STRING_ATTR_RO(system_id, S_IRUGO, system_id); | |
| 3987 | 3980 | |
| 3988 | 3981 | static struct device_attribute dev_attr_partition_number = |
| 3989 | 3982 | __ATTR(partition_number, S_IRUGO, partition_number_show, NULL); |
| @@ -3992,7 +3985,7 @@ static struct device_attribute dev_attr_unit_address = · 2 unmodified lines | ||
| 3992 | 3985 | __ATTR(unit_address, S_IRUGO, unit_address_show, NULL); |
| 3993 | 3986 | |
| 3994 | 3987 | static struct attribute *ibmvscsis_dev_attrs[] = { |
| 3995 | − &dev_attr_system_id.attr, | |
| 3988 | + &dev_attr_system_id.attr.attr, | |
| 3996 | 3989 | &dev_attr_partition_number.attr, |
| 3997 | 3990 | &dev_attr_unit_address.attr, |
| 3998 | 3991 | }; |
| @@ -676,13 +676,7 @@ static struct pci_driver mvs_pci_driver = { · 675 unmodified lines | ||
| 676 | 676 | .remove = mvs_pci_remove, |
| 677 | 677 | }; |
| 678 | 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); | |
| 679 | +static DEVICE_STRING_ATTR_RO(driver_version, 0444, DRV_VERSION); | |
| 686 | 680 | |
| 687 | 681 | static ssize_t interrupt_coalescing_store(struct device *cdev, |
| 688 | 682 | struct device_attribute *attr, |
| @@ -757,7 +751,7 @@ static void __exit mvs_exit(void) · 68 unmodified lines | ||
| 757 | 751 | } |
| 758 | 752 | |
| 759 | 753 | static struct attribute *mvst_host_attrs[] = { |
| 760 | − &dev_attr_driver_version.attr, | |
| 754 | + &dev_attr_driver_version.attr.attr, | |
| 761 | 755 | &dev_attr_interrupt_coalescing.attr, |
| 762 | 756 | NULL, |
| 763 | 757 | }; |
| @@ -1067,13 +1067,6 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *vha, bool stop_beacon) · 1066 unmodified lines | ||
| 1067 | 1067 | |
| 1068 | 1068 | /* Scsi_Host attributes. */ |
| 1069 | 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 | 1070 | static ssize_t |
| 1078 | 1071 | qla2x00_fw_version_show(struct device *dev, |
| 1079 | 1072 | struct device_attribute *attr, char *buf) |
| @@ -2412,7 +2405,7 @@ qla2x00_dport_diagnostics_show(struct device *dev, · 1332 unmodified lines | ||
| 2412 | 2405 | static DEVICE_ATTR(dport_diagnostics, 0444, |
| 2413 | 2406 | qla2x00_dport_diagnostics_show, NULL); |
| 2414 | 2407 | |
| 2415 | −static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_driver_version_show, NULL); | |
| 2408 | +static DEVICE_STRING_ATTR_RO(driver_version, S_IRUGO, qla2x00_version_str); | |
| 2416 | 2409 | static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); |
| 2417 | 2410 | static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); |
| 2418 | 2411 | 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); · 59 unmodified lines | ||
| 2478 | 2471 | static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL); |
| 2479 | 2472 | |
| 2480 | 2473 | static struct attribute *qla2x00_host_attrs[] = { |
| 2481 | − &dev_attr_driver_version.attr, | |
| 2474 | + &dev_attr_driver_version.attr.attr, | |
| 2482 | 2475 | &dev_attr_fw_version.attr, |
| 2483 | 2476 | &dev_attr_serial_num.attr, |
| 2484 | 2477 | &dev_attr_isp_name.attr, |
| @@ -6891,12 +6891,6 @@ static ssize_t pqi_firmware_version_show(struct device *dev, · 6890 unmodified lines | ||
| 6891 | 6891 | return scnprintf(buffer, PAGE_SIZE, "%s\n", ctrl_info->firmware_version); |
| 6892 | 6892 | } |
| 6893 | 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 | 6894 | static ssize_t pqi_serial_number_show(struct device *dev, |
| 6901 | 6895 | struct device_attribute *attr, char *buffer) |
| 6902 | 6896 | { |
| @@ -7065,7 +7059,8 @@ static ssize_t pqi_host_enable_r6_writes_store(struct device *dev, · 162 unmodified lines | ||
| 7065 | 7059 | return count; |
| 7066 | 7060 | } |
| 7067 | 7061 | |
| 7068 | −static DEVICE_ATTR(driver_version, 0444, pqi_driver_version_show, NULL); | |
| 7062 | +static DEVICE_STRING_ATTR_RO(driver_version, 0444, | |
| 7063 | + DRIVER_VERSION BUILD_TIMESTAMP); | |
| 7069 | 7064 | static DEVICE_ATTR(firmware_version, 0444, pqi_firmware_version_show, NULL); |
| 7070 | 7065 | static DEVICE_ATTR(model, 0444, pqi_model_show, NULL); |
| 7071 | 7066 | static DEVICE_ATTR(serial_number, 0444, pqi_serial_number_show, NULL); |
| @@ -7082,7 +7077,7 @@ static DEVICE_ATTR(enable_r6_writes, 0644, · 10 unmodified lines | ||
| 7082 | 7077 | pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store); |
| 7083 | 7078 | |
| 7084 | 7079 | static struct attribute *pqi_shost_attrs[] = { |
| 7085 | − &dev_attr_driver_version.attr, | |
| 7080 | + &dev_attr_driver_version.attr.attr, | |
| 7086 | 7081 | &dev_attr_firmware_version.attr, |
| 7087 | 7082 | &dev_attr_model.attr, |
| 7088 | 7083 | &dev_attr_serial_number.attr, |
| @@ -73,14 +73,7 @@ struct odvp_attr { · 72 unmodified lines | ||
| 73 | 73 | struct device_attribute attr; |
| 74 | 74 | }; |
| 75 | 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); | |
| 76 | +static BIN_ATTR_SIMPLE_RO(data_vault); | |
| 84 | 77 | |
| 85 | 78 | static struct bin_attribute *data_attributes[] = { |
| 86 | 79 | &bin_attr_data_vault, |
| @@ -206,7 +206,7 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn, · 205 unmodified lines | ||
| 206 | 206 | struct super_block *sb) |
| 207 | 207 | { |
| 208 | 208 | struct dentry *dentry; |
| 209 | − struct kernfs_node *knparent = NULL; | |
| 209 | + struct kernfs_node *knparent; | |
| 210 | 210 | |
| 211 | 211 | BUG_ON(sb->s_op != &kernfs_sops); |
| 212 | 212 | |
| @@ -785,3 +785,30 @@ int sysfs_emit_at(char *buf, int at, const char *fmt, ...) · 784 unmodified lines | ||
| 785 | 785 | return len; |
| 786 | 786 | } |
| 787 | 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); | |
| @@ -132,6 +132,8 @@ ssize_t device_show_bool(struct device *dev, struct device_attribute *attr, · 131 unmodified lines | ||
| 132 | 132 | char *buf); |
| 133 | 133 | ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, |
| 134 | 134 | const char *buf, size_t count); |
| 135 | +ssize_t device_show_string(struct device *dev, struct device_attribute *attr, | |
| 136 | + char *buf); | |
| 135 | 137 | |
| 136 | 138 | /** |
| 137 | 139 | * DEVICE_ATTR - Define a device attribute. |
| @@ -251,6 +253,19 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, · 113 unmodified lines | ||
| 251 | 253 | struct dev_ext_attribute dev_attr_##_name = \ |
| 252 | 254 | { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } |
| 253 | 255 | |
| 256 | +/** | |
| 257 | + * DEVICE_STRING_ATTR_RO - Define a device attribute backed by a r/o string. | |
| 258 | + * @_name: Attribute name. | |
| 259 | + * @_mode: File mode. | |
| 260 | + * @_var: Identifier of string. | |
| 261 | + * | |
| 262 | + * Like DEVICE_ULONG_ATTR(), but @_var is a string. Because the length of the | |
| 263 | + * string allocation is unknown, the attribute must be read-only. | |
| 264 | + */ | |
| 265 | +#define DEVICE_STRING_ATTR_RO(_name, _mode, _var) \ | |
| 266 | + struct dev_ext_attribute dev_attr_##_name = \ | |
| 267 | + { __ATTR(_name, (_mode) & ~0222, device_show_string, NULL), (_var) } | |
| 268 | + | |
| 254 | 269 | #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ |
| 255 | 270 | struct device_attribute dev_attr_##_name = \ |
| 256 | 271 | __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) |
| @@ -1210,17 +1225,6 @@ int __must_check devm_device_add_groups(struct device *dev, · 953 unmodified lines | ||
| 1210 | 1225 | int __must_check devm_device_add_group(struct device *dev, |
| 1211 | 1226 | const struct attribute_group *grp); |
| 1212 | 1227 | |
| 1213 | −/* | |
| 1214 | − * Platform "fixup" functions - allow the platform to have their say | |
| 1215 | − * about devices and actions that the general device layer doesn't | |
| 1216 | − * know about. | |
| 1217 | − */ | |
| 1218 | −/* Notify platform of device discovery */ | |
| 1219 | −extern int (*platform_notify)(struct device *dev); | |
| 1220 | − | |
| 1221 | −extern int (*platform_notify_remove)(struct device *dev); | |
| 1222 | − | |
| 1223 | − | |
| 1224 | 1228 | /* |
| 1225 | 1229 | * get_device - atomically increment the reference count for the device. |
| 1226 | 1230 | * |
| @@ -371,6 +371,17 @@ struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size) · 370 unmodified lines | ||
| 371 | 371 | #define BIN_ATTR_ADMIN_RW(_name, _size) \ |
| 372 | 372 | struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) |
| 373 | 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 | + | |
| 374 | 385 | struct sysfs_ops { |
| 375 | 386 | ssize_t (*show)(struct kobject *, struct attribute *, char *); |
| 376 | 387 | ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); |
| @@ -478,6 +489,10 @@ int sysfs_emit(char *buf, const char *fmt, ...); · 101 unmodified lines | ||
| 478 | 489 | __printf(3, 4) |
| 479 | 490 | int sysfs_emit_at(char *buf, int at, const char *fmt, ...); |
| 480 | 491 | |
| 492 | +ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj, | |
| 493 | + struct bin_attribute *attr, char *buf, | |
| 494 | + loff_t off, size_t count); | |
| 495 | + | |
| 481 | 496 | #else /* CONFIG_SYSFS */ |
| 482 | 497 | |
| 483 | 498 | static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) |
| @@ -575,15 +575,7 @@ extern unsigned long __initramfs_size; · 574 unmodified lines | ||
| 575 | 575 | #include <linux/initrd.h> |
| 576 | 576 | #include <linux/kexec.h> |
| 577 | 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); | |
| 578 | +static BIN_ATTR(initrd, 0440, sysfs_bin_attr_simple_read, NULL, 0); | |
| 587 | 579 | |
| 588 | 580 | void __init reserve_initrd_mem(void) |
| 589 | 581 | { |
| @@ -146,17 +146,6 @@ struct module_notes_attrs { · 145 unmodified lines | ||
| 146 | 146 | struct bin_attribute attrs[] __counted_by(notes); |
| 147 | 147 | }; |
| 148 | 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 | 149 | static void free_notes_attrs(struct module_notes_attrs *notes_attrs, |
| 161 | 150 | unsigned int i) |
| 162 | 151 | { |
| @@ -205,7 +194,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info) · 42 unmodified lines | ||
| 205 | 194 | nattr->attr.mode = 0444; |
| 206 | 195 | nattr->size = info->sechdrs[i].sh_size; |
| 207 | 196 | nattr->private = (void *)info->sechdrs[i].sh_addr; |
| 208 | − nattr->read = module_notes_read; | |
| 197 | + nattr->read = sysfs_bin_attr_simple_read; | |
| 209 | 198 | ++nattr; |
| 210 | 199 | } |
| 211 | 200 | ++loaded; |