Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Pull driver core updates from Greg KH:
"Here is a small set of driver core changes for 6.13-rc1.

Nothing major for this merge cycle, except for the two simple merge
conflicts are here just to make life interesting.

Included in here are:

- sysfs core changes and preparations for more sysfs api cleanups
that can come through all driver trees after -rc1 is out

- fw_devlink fixes based on many reports and debugging sessions

- list_for_each_reverse() removal, no one was using it!

- last-minute seq_printf() format string bug found and fixed in many
drivers all at once.

- minor bugfixes and changes full details in the shortlog"

* tag 'driver-core-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (35 commits)
Fix a potential abuse of seq_printf() format string in drivers
cpu: Remove spurious NULL in attribute_group definition
s390/con3215: Remove spurious NULL in attribute_group definition
perf: arm-ni: Remove spurious NULL in attribute_group definition
driver core: Constify bin_attribute definitions
sysfs: attribute_group: allow registration of const bin_attribute
firmware_loader: Fix possible resource leak in fw_log_firmware_info()
drivers: core: fw_devlink: Fix excess parameter description in docstring
driver core: class: Correct WARN() message in APIs class_(for_each|find)_device()
cacheinfo: Use of_property_present() for non-boolean properties
cdx: Fix cdx_mmap_resource() after constifying attr in ->mmap()
drivers: core: fw_devlink: Make the error message a bit more useful
phy: tegra: xusb: Set fwnode for xusb port devices
drm: display: Set fwnode for aux bus devices
driver core: fw_devlink: Stop trying to optimize cycle detection logic
driver core: Constify attribute arguments of binary attributes
sysfs: bin_attribute: add const read/write callback variants
sysfs: implement all BIN_ATTR_* macros in terms of __BIN_ATTR()
sysfs: treewide: constify attribute callback of bin_attribute::llseek()
sysfs: treewide: constify attribute callback of bin_attribute::mmap()
...

+243 -254
-1
Documentation/driver-api/auxiliary_bus.rst
··· 24 24 25 25 .. kernel-doc:: drivers/base/auxiliary.c 26 26 :identifiers: auxiliary_device_init __auxiliary_device_add 27 - auxiliary_find_device 28 27 29 28 Auxiliary Device Memory Model and Lifespan 30 29 ------------------------------------------
+3 -3
arch/alpha/kernel/pci-sysfs.c
··· 64 64 * Return: %0 on success, negative error code otherwise 65 65 */ 66 66 static int pci_mmap_resource(struct kobject *kobj, 67 - struct bin_attribute *attr, 67 + const struct bin_attribute *attr, 68 68 struct vm_area_struct *vma, int sparse) 69 69 { 70 70 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); ··· 93 93 } 94 94 95 95 static int pci_mmap_resource_sparse(struct file *filp, struct kobject *kobj, 96 - struct bin_attribute *attr, 96 + const struct bin_attribute *attr, 97 97 struct vm_area_struct *vma) 98 98 { 99 99 return pci_mmap_resource(kobj, attr, vma, 1); 100 100 } 101 101 102 102 static int pci_mmap_resource_dense(struct file *filp, struct kobject *kobj, 103 - struct bin_attribute *attr, 103 + const struct bin_attribute *attr, 104 104 struct vm_area_struct *vma) 105 105 { 106 106 return pci_mmap_resource(kobj, attr, vma, 0);
+1 -30
drivers/base/auxiliary.c
··· 92 92 * Auxiliary devices are created and registered by a subsystem-level core 93 93 * device that needs to break up its functionality into smaller fragments. One 94 94 * way to extend the scope of an auxiliary_device is to encapsulate it within a 95 - * domain- pecific structure defined by the parent device. This structure 95 + * domain-specific structure defined by the parent device. This structure 96 96 * contains the auxiliary_device and any associated shared data/callbacks 97 97 * needed to establish the connection with the parent. 98 98 * ··· 334 334 return ret; 335 335 } 336 336 EXPORT_SYMBOL_GPL(__auxiliary_device_add); 337 - 338 - /** 339 - * auxiliary_find_device - auxiliary device iterator for locating a particular device. 340 - * @start: Device to begin with 341 - * @data: Data to pass to match function 342 - * @match: Callback function to check device 343 - * 344 - * This function returns a reference to a device that is 'found' 345 - * for later use, as determined by the @match callback. 346 - * 347 - * The reference returned should be released with put_device(). 348 - * 349 - * The callback should return 0 if the device doesn't match and non-zero 350 - * if it does. If the callback returns non-zero, this function will 351 - * return to the caller and not iterate over any more devices. 352 - */ 353 - struct auxiliary_device *auxiliary_find_device(struct device *start, 354 - const void *data, 355 - device_match_t match) 356 - { 357 - struct device *dev; 358 - 359 - dev = bus_find_device(&auxiliary_bus_type, start, data, match); 360 - if (!dev) 361 - return NULL; 362 - 363 - return to_auxiliary_dev(dev); 364 - } 365 - EXPORT_SYMBOL_GPL(auxiliary_find_device); 366 337 367 338 /** 368 339 * __auxiliary_driver_register - register a driver for auxiliary bus devices
+5 -10
drivers/base/cacheinfo.c
··· 254 254 { 255 255 unsigned int leaves = 0; 256 256 257 - if (of_property_read_bool(np, "cache-size")) 257 + if (of_property_present(np, "cache-size")) 258 258 ++leaves; 259 - if (of_property_read_bool(np, "i-cache-size")) 259 + if (of_property_present(np, "i-cache-size")) 260 260 ++leaves; 261 - if (of_property_read_bool(np, "d-cache-size")) 261 + if (of_property_present(np, "d-cache-size")) 262 262 ++leaves; 263 263 264 264 if (!leaves) { ··· 367 367 368 368 cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map); 369 369 for_each_online_cpu(i) { 370 - struct cpu_cacheinfo *sib_cpu_ci = get_cpu_cacheinfo(i); 371 - 372 - if (i == cpu || !sib_cpu_ci->info_list) 370 + if (i == cpu || !per_cpu_cacheinfo(i)) 373 371 continue;/* skip if itself or no cacheinfo */ 374 372 for (sib_index = 0; sib_index < cache_leaves(i); sib_index++) { 375 373 sib_leaf = per_cpu_cacheinfo_idx(i, sib_index); ··· 407 409 for (index = 0; index < cache_leaves(cpu); index++) { 408 410 this_leaf = per_cpu_cacheinfo_idx(cpu, index); 409 411 for_each_cpu(sibling, &this_leaf->shared_cpu_map) { 410 - struct cpu_cacheinfo *sib_cpu_ci = 411 - get_cpu_cacheinfo(sibling); 412 - 413 - if (sibling == cpu || !sib_cpu_ci->info_list) 412 + if (sibling == cpu || !per_cpu_cacheinfo(sibling)) 414 413 continue;/* skip if itself or no cacheinfo */ 415 414 416 415 for (sib_index = 0; sib_index < cache_leaves(sibling); sib_index++) {
+2 -2
drivers/base/class.c
··· 405 405 if (!class) 406 406 return -EINVAL; 407 407 if (!sp) { 408 - WARN(1, "%s called for class '%s' before it was initialized", 408 + WARN(1, "%s called for class '%s' before it was registered", 409 409 __func__, class->name); 410 410 return -EINVAL; 411 411 } ··· 453 453 if (!class) 454 454 return NULL; 455 455 if (!sp) { 456 - WARN(1, "%s called for class '%s' before it was initialized", 456 + WARN(1, "%s called for class '%s' before it was registered", 457 457 __func__, class->name); 458 458 return NULL; 459 459 }
+28 -35
drivers/base/core.c
··· 552 552 } 553 553 EXPORT_SYMBOL_GPL(device_link_wait_removal); 554 554 555 - static struct class devlink_class = { 555 + static const struct class devlink_class = { 556 556 .name = "devlink", 557 557 .dev_groups = devlink_groups, 558 558 .dev_release = devlink_dev_release, ··· 1971 1971 1972 1972 /** 1973 1973 * __fw_devlink_relax_cycles - Relax and mark dependency cycles. 1974 - * @con: Potential consumer device. 1974 + * @con_handle: Potential consumer device fwnode. 1975 1975 * @sup_handle: Potential supplier's fwnode. 1976 1976 * 1977 1977 * Needs to be called with fwnode_lock and device link lock held. ··· 1989 1989 * 1990 1990 * Return true if one or more cycles were found. Otherwise, return false. 1991 1991 */ 1992 - static bool __fw_devlink_relax_cycles(struct device *con, 1992 + static bool __fw_devlink_relax_cycles(struct fwnode_handle *con_handle, 1993 1993 struct fwnode_handle *sup_handle) 1994 1994 { 1995 - struct device *sup_dev = NULL, *par_dev = NULL; 1995 + struct device *sup_dev = NULL, *par_dev = NULL, *con_dev = NULL; 1996 1996 struct fwnode_link *link; 1997 1997 struct device_link *dev_link; 1998 1998 bool ret = false; ··· 2009 2009 2010 2010 sup_handle->flags |= FWNODE_FLAG_VISITED; 2011 2011 2012 - sup_dev = get_dev_from_fwnode(sup_handle); 2013 - 2014 2012 /* Termination condition. */ 2015 - if (sup_dev == con) { 2013 + if (sup_handle == con_handle) { 2016 2014 pr_debug("----- cycle: start -----\n"); 2017 2015 ret = true; 2018 2016 goto out; 2019 2017 } 2020 2018 2019 + sup_dev = get_dev_from_fwnode(sup_handle); 2020 + con_dev = get_dev_from_fwnode(con_handle); 2021 2021 /* 2022 2022 * If sup_dev is bound to a driver and @con hasn't started binding to a 2023 2023 * driver, sup_dev can't be a consumer of @con. So, no need to check 2024 2024 * further. 2025 2025 */ 2026 2026 if (sup_dev && sup_dev->links.status == DL_DEV_DRIVER_BOUND && 2027 - con->links.status == DL_DEV_NO_DRIVER) { 2027 + con_dev && con_dev->links.status == DL_DEV_NO_DRIVER) { 2028 2028 ret = false; 2029 2029 goto out; 2030 2030 } ··· 2033 2033 if (link->flags & FWLINK_FLAG_IGNORE) 2034 2034 continue; 2035 2035 2036 - if (__fw_devlink_relax_cycles(con, link->supplier)) { 2036 + if (__fw_devlink_relax_cycles(con_handle, link->supplier)) { 2037 2037 __fwnode_link_cycle(link); 2038 2038 ret = true; 2039 2039 } ··· 2048 2048 else 2049 2049 par_dev = fwnode_get_next_parent_dev(sup_handle); 2050 2050 2051 - if (par_dev && __fw_devlink_relax_cycles(con, par_dev->fwnode)) { 2051 + if (par_dev && __fw_devlink_relax_cycles(con_handle, par_dev->fwnode)) { 2052 2052 pr_debug("%pfwf: cycle: child of %pfwf\n", sup_handle, 2053 2053 par_dev->fwnode); 2054 2054 ret = true; ··· 2066 2066 !(dev_link->flags & DL_FLAG_CYCLE)) 2067 2067 continue; 2068 2068 2069 - if (__fw_devlink_relax_cycles(con, 2069 + if (__fw_devlink_relax_cycles(con_handle, 2070 2070 dev_link->supplier->fwnode)) { 2071 2071 pr_debug("%pfwf: cycle: depends on %pfwf\n", sup_handle, 2072 2072 dev_link->supplier->fwnode); ··· 2114 2114 if (link->flags & FWLINK_FLAG_IGNORE) 2115 2115 return 0; 2116 2116 2117 - if (con->fwnode == link->consumer) 2118 - flags = fw_devlink_get_flags(link->flags); 2119 - else 2120 - flags = FW_DEVLINK_FLAGS_PERMISSIVE; 2121 - 2122 2117 /* 2123 2118 * In some cases, a device P might also be a supplier to its child node 2124 2119 * C. However, this would defer the probe of C until the probe of P ··· 2134 2139 return -EINVAL; 2135 2140 2136 2141 /* 2137 - * SYNC_STATE_ONLY device links don't block probing and supports cycles. 2138 - * So, one might expect that cycle detection isn't necessary for them. 2139 - * However, if the device link was marked as SYNC_STATE_ONLY because 2140 - * it's part of a cycle, then we still need to do cycle detection. This 2141 - * is because the consumer and supplier might be part of multiple cycles 2142 - * and we need to detect all those cycles. 2142 + * Don't try to optimize by not calling the cycle detection logic under 2143 + * certain conditions. There's always some corner case that won't get 2144 + * detected. 2143 2145 */ 2144 - if (!device_link_flag_is_sync_state_only(flags) || 2145 - flags & DL_FLAG_CYCLE) { 2146 - device_links_write_lock(); 2147 - if (__fw_devlink_relax_cycles(con, sup_handle)) { 2148 - __fwnode_link_cycle(link); 2149 - flags = fw_devlink_get_flags(link->flags); 2150 - pr_debug("----- cycle: end -----\n"); 2151 - dev_info(con, "Fixed dependency cycle(s) with %pfwf\n", 2152 - sup_handle); 2153 - } 2154 - device_links_write_unlock(); 2146 + device_links_write_lock(); 2147 + if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) { 2148 + __fwnode_link_cycle(link); 2149 + pr_debug("----- cycle: end -----\n"); 2150 + pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n", 2151 + link->consumer, sup_handle); 2155 2152 } 2153 + device_links_write_unlock(); 2154 + 2155 + if (con->fwnode == link->consumer) 2156 + flags = fw_devlink_get_flags(link->flags); 2157 + else 2158 + flags = FW_DEVLINK_FLAGS_PERMISSIVE; 2156 2159 2157 2160 if (sup_handle->flags & FWNODE_FLAG_NOT_DEVICE) 2158 2161 sup_dev = fwnode_get_next_parent_dev(sup_handle); ··· 2173 2180 } 2174 2181 2175 2182 if (con != sup_dev && !device_link_add(con, sup_dev, flags)) { 2176 - dev_err(con, "Failed to create device link (0x%x) with %s\n", 2177 - flags, dev_name(sup_dev)); 2183 + dev_err(con, "Failed to create device link (0x%x) with supplier %s for %pfwf\n", 2184 + flags, dev_name(sup_dev), link->consumer); 2178 2185 ret = -EINVAL; 2179 2186 } 2180 2187
+3 -4
drivers/base/firmware_loader/main.c
··· 829 829 shash->tfm = alg; 830 830 831 831 if (crypto_shash_digest(shash, fw->data, fw->size, sha256buf) < 0) 832 - goto out_shash; 832 + goto out_free; 833 833 834 834 for (int i = 0; i < SHA256_DIGEST_SIZE; i++) 835 835 sprintf(&outbuf[i * 2], "%02x", sha256buf[i]); 836 836 outbuf[SHA256_BLOCK_SIZE] = 0; 837 837 dev_dbg(device, "Loaded FW: %s, sha256: %s\n", name, outbuf); 838 838 839 - out_shash: 840 - crypto_free_shash(alg); 841 839 out_free: 842 840 kfree(shash); 843 841 kfree(outbuf); 844 842 kfree(sha256buf); 843 + crypto_free_shash(alg); 845 844 } 846 845 #else 847 846 static void fw_log_firmware_info(const struct firmware *fw, const char *name, ··· 1074 1075 1075 1076 /** 1076 1077 * firmware_request_cache() - cache firmware for suspend so resume can use it 1077 - * @name: name of firmware file 1078 1078 * @device: device for which firmware should be cached for 1079 + * @name: name of firmware file 1079 1080 * 1080 1081 * There are some devices with an optimization that enables the device to not 1081 1082 * require loading firmware on system reboot. This optimization may still
+6 -6
drivers/base/node.c
··· 27 27 }; 28 28 29 29 static inline ssize_t cpumap_read(struct file *file, struct kobject *kobj, 30 - struct bin_attribute *attr, char *buf, 30 + const struct bin_attribute *attr, char *buf, 31 31 loff_t off, size_t count) 32 32 { 33 33 struct device *dev = kobj_to_dev(kobj); ··· 45 45 return n; 46 46 } 47 47 48 - static BIN_ATTR_RO(cpumap, CPUMAP_FILE_MAX_BYTES); 48 + static const BIN_ATTR_RO(cpumap, CPUMAP_FILE_MAX_BYTES); 49 49 50 50 static inline ssize_t cpulist_read(struct file *file, struct kobject *kobj, 51 - struct bin_attribute *attr, char *buf, 51 + const struct bin_attribute *attr, char *buf, 52 52 loff_t off, size_t count) 53 53 { 54 54 struct device *dev = kobj_to_dev(kobj); ··· 66 66 return n; 67 67 } 68 68 69 - static BIN_ATTR_RO(cpulist, CPULIST_FILE_MAX_BYTES); 69 + static const BIN_ATTR_RO(cpulist, CPULIST_FILE_MAX_BYTES); 70 70 71 71 /** 72 72 * struct node_access_nodes - Access class device to hold user visible ··· 578 578 NULL 579 579 }; 580 580 581 - static struct bin_attribute *node_dev_bin_attrs[] = { 581 + static const struct bin_attribute *node_dev_bin_attrs[] = { 582 582 &bin_attr_cpumap, 583 583 &bin_attr_cpulist, 584 584 NULL ··· 586 586 587 587 static const struct attribute_group node_dev_group = { 588 588 .attrs = node_dev_attrs, 589 - .bin_attrs = node_dev_bin_attrs 589 + .bin_attrs_new = node_dev_bin_attrs, 590 590 }; 591 591 592 592 static const struct attribute_group *node_dev_groups[] = {
+9 -8
drivers/base/power/sysfs.c
··· 509 509 return sysfs_emit(buf, "%lld\n", msec); 510 510 } 511 511 512 - static inline int dpm_sysfs_wakeup_change_owner(struct device *dev, kuid_t kuid, 513 - kgid_t kgid) 514 - { 515 - if (dev->power.wakeup && dev->power.wakeup->dev) 516 - return device_change_owner(dev->power.wakeup->dev, kuid, kgid); 517 - return 0; 518 - } 519 - 520 512 static DEVICE_ATTR_RO(wakeup_last_time_ms); 521 513 522 514 #ifdef CONFIG_PM_AUTOSLEEP ··· 533 541 534 542 static DEVICE_ATTR_RO(wakeup_prevent_sleep_time_ms); 535 543 #endif /* CONFIG_PM_AUTOSLEEP */ 544 + 545 + static inline int dpm_sysfs_wakeup_change_owner(struct device *dev, kuid_t kuid, 546 + kgid_t kgid) 547 + { 548 + if (dev->power.wakeup && dev->power.wakeup->dev) 549 + return device_change_owner(dev->power.wakeup->dev, kuid, kgid); 550 + return 0; 551 + } 552 + 536 553 #else /* CONFIG_PM_SLEEP */ 537 554 static inline int dpm_sysfs_wakeup_change_owner(struct device *dev, kuid_t kuid, 538 555 kgid_t kgid)
+20 -20
drivers/base/topology.c
··· 23 23 24 24 #define define_siblings_read_func(name, mask) \ 25 25 static ssize_t name##_read(struct file *file, struct kobject *kobj, \ 26 - struct bin_attribute *attr, char *buf, \ 26 + const struct bin_attribute *attr, char *buf, \ 27 27 loff_t off, size_t count) \ 28 28 { \ 29 29 struct device *dev = kobj_to_dev(kobj); \ ··· 33 33 } \ 34 34 \ 35 35 static ssize_t name##_list_read(struct file *file, struct kobject *kobj, \ 36 - struct bin_attribute *attr, char *buf, \ 36 + const struct bin_attribute *attr, char *buf, \ 37 37 loff_t off, size_t count) \ 38 38 { \ 39 39 struct device *dev = kobj_to_dev(kobj); \ ··· 62 62 static DEVICE_ATTR_ADMIN_RO(ppin); 63 63 64 64 define_siblings_read_func(thread_siblings, sibling_cpumask); 65 - static BIN_ATTR_RO(thread_siblings, CPUMAP_FILE_MAX_BYTES); 66 - static BIN_ATTR_RO(thread_siblings_list, CPULIST_FILE_MAX_BYTES); 65 + static const BIN_ATTR_RO(thread_siblings, CPUMAP_FILE_MAX_BYTES); 66 + static const BIN_ATTR_RO(thread_siblings_list, CPULIST_FILE_MAX_BYTES); 67 67 68 68 define_siblings_read_func(core_cpus, sibling_cpumask); 69 - static BIN_ATTR_RO(core_cpus, CPUMAP_FILE_MAX_BYTES); 70 - static BIN_ATTR_RO(core_cpus_list, CPULIST_FILE_MAX_BYTES); 69 + static const BIN_ATTR_RO(core_cpus, CPUMAP_FILE_MAX_BYTES); 70 + static const BIN_ATTR_RO(core_cpus_list, CPULIST_FILE_MAX_BYTES); 71 71 72 72 define_siblings_read_func(core_siblings, core_cpumask); 73 - static BIN_ATTR_RO(core_siblings, CPUMAP_FILE_MAX_BYTES); 74 - static BIN_ATTR_RO(core_siblings_list, CPULIST_FILE_MAX_BYTES); 73 + static const BIN_ATTR_RO(core_siblings, CPUMAP_FILE_MAX_BYTES); 74 + static const BIN_ATTR_RO(core_siblings_list, CPULIST_FILE_MAX_BYTES); 75 75 76 76 #ifdef TOPOLOGY_CLUSTER_SYSFS 77 77 define_siblings_read_func(cluster_cpus, cluster_cpumask); 78 - static BIN_ATTR_RO(cluster_cpus, CPUMAP_FILE_MAX_BYTES); 79 - static BIN_ATTR_RO(cluster_cpus_list, CPULIST_FILE_MAX_BYTES); 78 + static const BIN_ATTR_RO(cluster_cpus, CPUMAP_FILE_MAX_BYTES); 79 + static const BIN_ATTR_RO(cluster_cpus_list, CPULIST_FILE_MAX_BYTES); 80 80 #endif 81 81 82 82 #ifdef TOPOLOGY_DIE_SYSFS 83 83 define_siblings_read_func(die_cpus, die_cpumask); 84 - static BIN_ATTR_RO(die_cpus, CPUMAP_FILE_MAX_BYTES); 85 - static BIN_ATTR_RO(die_cpus_list, CPULIST_FILE_MAX_BYTES); 84 + static const BIN_ATTR_RO(die_cpus, CPUMAP_FILE_MAX_BYTES); 85 + static const BIN_ATTR_RO(die_cpus_list, CPULIST_FILE_MAX_BYTES); 86 86 #endif 87 87 88 88 define_siblings_read_func(package_cpus, core_cpumask); 89 - static BIN_ATTR_RO(package_cpus, CPUMAP_FILE_MAX_BYTES); 90 - static BIN_ATTR_RO(package_cpus_list, CPULIST_FILE_MAX_BYTES); 89 + static const BIN_ATTR_RO(package_cpus, CPUMAP_FILE_MAX_BYTES); 90 + static const BIN_ATTR_RO(package_cpus_list, CPULIST_FILE_MAX_BYTES); 91 91 92 92 #ifdef TOPOLOGY_BOOK_SYSFS 93 93 define_id_show_func(book_id, "%d"); 94 94 static DEVICE_ATTR_RO(book_id); 95 95 define_siblings_read_func(book_siblings, book_cpumask); 96 - static BIN_ATTR_RO(book_siblings, CPUMAP_FILE_MAX_BYTES); 97 - static BIN_ATTR_RO(book_siblings_list, CPULIST_FILE_MAX_BYTES); 96 + static const BIN_ATTR_RO(book_siblings, CPUMAP_FILE_MAX_BYTES); 97 + static const BIN_ATTR_RO(book_siblings_list, CPULIST_FILE_MAX_BYTES); 98 98 #endif 99 99 100 100 #ifdef TOPOLOGY_DRAWER_SYSFS 101 101 define_id_show_func(drawer_id, "%d"); 102 102 static DEVICE_ATTR_RO(drawer_id); 103 103 define_siblings_read_func(drawer_siblings, drawer_cpumask); 104 - static BIN_ATTR_RO(drawer_siblings, CPUMAP_FILE_MAX_BYTES); 105 - static BIN_ATTR_RO(drawer_siblings_list, CPULIST_FILE_MAX_BYTES); 104 + static const BIN_ATTR_RO(drawer_siblings, CPUMAP_FILE_MAX_BYTES); 105 + static const BIN_ATTR_RO(drawer_siblings_list, CPULIST_FILE_MAX_BYTES); 106 106 #endif 107 107 108 - static struct bin_attribute *bin_attrs[] = { 108 + static const struct bin_attribute *const bin_attrs[] = { 109 109 &bin_attr_core_cpus, 110 110 &bin_attr_core_cpus_list, 111 111 &bin_attr_thread_siblings, ··· 163 163 164 164 static const struct attribute_group topology_attr_group = { 165 165 .attrs = default_attrs, 166 - .bin_attrs = bin_attrs, 166 + .bin_attrs_new = bin_attrs, 167 167 .is_visible = topology_is_visible, 168 168 .name = "topology" 169 169 };
+3 -3
drivers/base/trace.h
··· 24 24 __field(struct device *, dev) 25 25 __field(const char *, op) 26 26 __field(void *, node) 27 - __field(const char *, name) 27 + __string(name, name) 28 28 __field(size_t, size) 29 29 ), 30 30 TP_fast_assign( 31 31 __assign_str(devname); 32 32 __entry->op = op; 33 33 __entry->node = node; 34 - __entry->name = name; 34 + __assign_str(name); 35 35 __entry->size = size; 36 36 ), 37 37 TP_printk("%s %3s %p %s (%zu bytes)", __get_str(devname), 38 - __entry->op, __entry->node, __entry->name, __entry->size) 38 + __entry->op, __entry->node, __get_str(name), __entry->size) 39 39 ); 40 40 41 41 DEFINE_EVENT(devres, devres_log,
+1 -1
drivers/cdx/cdx.c
··· 707 707 * Return: true on success, false otherwise. 708 708 */ 709 709 static int cdx_mmap_resource(struct file *fp, struct kobject *kobj, 710 - struct bin_attribute *attr, 710 + const struct bin_attribute *attr, 711 711 struct vm_area_struct *vma) 712 712 { 713 713 struct cdx_device *cdx_dev = to_cdx_device(kobj_to_dev(kobj));
+1 -1
drivers/cxl/port.c
··· 173 173 static BIN_ATTR_ADMIN_RO(CDAT, 0); 174 174 175 175 static umode_t cxl_port_bin_attr_is_visible(struct kobject *kobj, 176 - struct bin_attribute *attr, int i) 176 + const struct bin_attribute *attr, int i) 177 177 { 178 178 struct device *dev = kobj_to_dev(kobj); 179 179 struct cxl_port *port = to_cxl_port(dev);
+1 -1
drivers/gpio/gpio-aspeed-sgpio.c
··· 420 420 int offset; 421 421 422 422 irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset); 423 - seq_printf(p, dev_name(gpio->dev)); 423 + seq_puts(p, dev_name(gpio->dev)); 424 424 } 425 425 426 426 static const struct irq_chip aspeed_sgpio_irq_chip = {
+1 -1
drivers/gpio/gpio-aspeed.c
··· 1049 1049 if (rc) 1050 1050 return; 1051 1051 1052 - seq_printf(p, dev_name(gpio->dev)); 1052 + seq_puts(p, dev_name(gpio->dev)); 1053 1053 } 1054 1054 1055 1055 static const struct irq_chip aspeed_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-ep93xx.c
··· 249 249 { 250 250 struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 251 251 252 - seq_printf(p, dev_name(gc->parent)); 252 + seq_puts(p, dev_name(gc->parent)); 253 253 } 254 254 255 255 static const struct irq_chip gpio_eic_irq_chip = {
+1 -1
drivers/gpio/gpio-hlwd.c
··· 210 210 struct hlwd_gpio *hlwd = 211 211 gpiochip_get_data(irq_data_get_irq_chip_data(data)); 212 212 213 - seq_printf(p, dev_name(hlwd->dev)); 213 + seq_puts(p, dev_name(hlwd->dev)); 214 214 } 215 215 216 216 static const struct irq_chip hlwd_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-mlxbf2.c
··· 331 331 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); 332 332 struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); 333 333 334 - seq_printf(p, dev_name(gs->dev)); 334 + seq_puts(p, dev_name(gs->dev)); 335 335 } 336 336 337 337 static const struct irq_chip mlxbf2_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-omap.c
··· 715 715 { 716 716 struct gpio_bank *bank = omap_irq_data_get_bank(d); 717 717 718 - seq_printf(p, dev_name(bank->dev)); 718 + seq_puts(p, dev_name(bank->dev)); 719 719 } 720 720 721 721 static const struct irq_chip omap_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-pca953x.c
··· 815 815 { 816 816 struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 817 817 818 - seq_printf(p, dev_name(gc->parent)); 818 + seq_puts(p, dev_name(gc->parent)); 819 819 } 820 820 821 821 static const struct irq_chip pca953x_irq_chip = {
+1 -1
drivers/gpio/gpio-pl061.c
··· 291 291 { 292 292 struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 293 293 294 - seq_printf(p, dev_name(gc->parent)); 294 + seq_puts(p, dev_name(gc->parent)); 295 295 } 296 296 297 297 static const struct irq_chip pl061_irq_chip = {
+1 -1
drivers/gpio/gpio-tegra.c
··· 600 600 { 601 601 struct gpio_chip *chip = irq_data_get_irq_chip_data(d); 602 602 603 - seq_printf(s, dev_name(chip->parent)); 603 + seq_puts(s, dev_name(chip->parent)); 604 604 } 605 605 606 606 static const struct irq_chip tegra_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-tegra186.c
··· 610 610 { 611 611 struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 612 612 613 - seq_printf(p, dev_name(gc->parent)); 613 + seq_puts(p, dev_name(gc->parent)); 614 614 } 615 615 616 616 static const struct irq_chip tegra186_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-tqmx86.c
··· 275 275 { 276 276 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 277 277 278 - seq_printf(p, gc->label); 278 + seq_puts(p, gc->label); 279 279 } 280 280 281 281 static const struct irq_chip tqmx86_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-visconti.c
··· 142 142 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 143 143 struct visconti_gpio *priv = gpiochip_get_data(gc); 144 144 145 - seq_printf(p, dev_name(priv->dev)); 145 + seq_puts(p, dev_name(priv->dev)); 146 146 } 147 147 148 148 static const struct irq_chip visconti_gpio_irq_chip = {
+1 -1
drivers/gpio/gpio-xgs-iproc.c
··· 198 198 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 199 199 struct iproc_gpio_chip *chip = to_iproc_gpio(gc); 200 200 201 - seq_printf(p, dev_name(chip->dev)); 201 + seq_puts(p, dev_name(chip->dev)); 202 202 } 203 203 204 204 static const struct irq_chip iproc_gpio_irq_chip = {
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 4112 4112 } 4113 4113 4114 4114 static umode_t amdgpu_bin_flash_attr_is_visible(struct kobject *kobj, 4115 - struct bin_attribute *attr, 4115 + const struct bin_attribute *attr, 4116 4116 int idx) 4117 4117 { 4118 4118 struct device *dev = kobj_to_dev(kobj);
+1 -1
drivers/gpu/drm/display/drm_dp_aux_bus.c
··· 292 292 aux_ep->dev.parent = aux->dev; 293 293 aux_ep->dev.bus = &dp_aux_bus_type; 294 294 aux_ep->dev.type = &dp_aux_device_type_type; 295 - aux_ep->dev.of_node = of_node_get(np); 295 + device_set_node(&aux_ep->dev, of_fwnode_handle(of_node_get(np))); 296 296 dev_set_name(&aux_ep->dev, "aux-%s", dev_name(aux->dev)); 297 297 298 298 ret = device_register(&aux_ep->dev);
+1 -1
drivers/infiniband/hw/qib/qib_sysfs.c
··· 283 283 }; 284 284 285 285 static umode_t qib_ccmgta_is_bin_visible(struct kobject *kobj, 286 - struct bin_attribute *attr, int n) 286 + const struct bin_attribute *attr, int n) 287 287 { 288 288 struct qib_pportdata *ppd = qib_get_pportdata_kobj(kobj); 289 289
+1 -1
drivers/irqchip/irq-gic.c
··· 400 400 struct gic_chip_data *gic = irq_data_get_irq_chip_data(d); 401 401 402 402 if (gic->domain->pm_dev) 403 - seq_printf(p, gic->domain->pm_dev->of_node->name); 403 + seq_puts(p, gic->domain->pm_dev->of_node->name); 404 404 else 405 405 seq_printf(p, "GIC-%d", (int)(gic - &gic_data[0])); 406 406 }
+1 -1
drivers/irqchip/irq-mvebu-pic.c
··· 71 71 { 72 72 struct mvebu_pic *pic = irq_data_get_irq_chip_data(d); 73 73 74 - seq_printf(p, dev_name(&pic->pdev->dev)); 74 + seq_puts(p, dev_name(&pic->pdev->dev)); 75 75 } 76 76 77 77 static const struct irq_chip mvebu_pic_chip = {
+1 -1
drivers/irqchip/irq-versatile-fpga.c
··· 69 69 { 70 70 struct fpga_irq_data *f = irq_data_get_irq_chip_data(d); 71 71 72 - seq_printf(p, irq_domain_get_of_node(f->domain)->name); 72 + seq_puts(p, irq_domain_get_of_node(f->domain)->name); 73 73 } 74 74 75 75 static const struct irq_chip fpga_chip = {
+1 -1
drivers/misc/ocxl/sysfs.c
··· 125 125 }; 126 126 127 127 static int global_mmio_mmap(struct file *filp, struct kobject *kobj, 128 - struct bin_attribute *bin_attr, 128 + const struct bin_attribute *bin_attr, 129 129 struct vm_area_struct *vma) 130 130 { 131 131 struct ocxl_afu *afu = to_afu(kobj_to_dev(kobj));
+1 -1
drivers/mtd/spi-nor/sysfs.c
··· 87 87 } 88 88 89 89 static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj, 90 - struct bin_attribute *attr, int n) 90 + const struct bin_attribute *attr, int n) 91 91 { 92 92 struct spi_device *spi = to_spi_device(kobj_to_dev(kobj)); 93 93 struct spi_mem *spimem = spi_get_drvdata(spi);
+13 -3
drivers/nvmem/core.c
··· 298 298 } 299 299 300 300 static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj, 301 - struct bin_attribute *attr, int i) 301 + const struct bin_attribute *attr, 302 + int i) 302 303 { 303 304 struct device *dev = kobj_to_dev(kobj); 304 305 struct nvmem_device *nvmem = to_nvmem_device(dev); 305 306 306 - attr->size = nvmem->size; 307 - 308 307 return nvmem_bin_attr_get_umode(nvmem); 308 + } 309 + 310 + static size_t nvmem_bin_attr_size(struct kobject *kobj, 311 + const struct bin_attribute *attr, 312 + int i) 313 + { 314 + struct device *dev = kobj_to_dev(kobj); 315 + struct nvmem_device *nvmem = to_nvmem_device(dev); 316 + 317 + return nvmem->size; 309 318 } 310 319 311 320 static umode_t nvmem_attr_is_visible(struct kobject *kobj, ··· 392 383 .bin_attrs = nvmem_bin_attributes, 393 384 .attrs = nvmem_attrs, 394 385 .is_bin_visible = nvmem_bin_attr_is_visible, 386 + .bin_size = nvmem_bin_attr_size, 395 387 .is_visible = nvmem_attr_is_visible, 396 388 }; 397 389
+1 -1
drivers/pci/p2pdma.c
··· 90 90 static DEVICE_ATTR_RO(published); 91 91 92 92 static int p2pmem_alloc_mmap(struct file *filp, struct kobject *kobj, 93 - struct bin_attribute *attr, struct vm_area_struct *vma) 93 + const struct bin_attribute *attr, struct vm_area_struct *vma) 94 94 { 95 95 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); 96 96 size_t len = vma->vm_end - vma->vm_start;
+23 -19
drivers/pci/pci-sysfs.c
··· 844 844 NULL, 845 845 }; 846 846 847 - static umode_t pci_dev_config_attr_is_visible(struct kobject *kobj, 848 - struct bin_attribute *a, int n) 847 + static size_t pci_dev_config_attr_bin_size(struct kobject *kobj, 848 + const struct bin_attribute *a, 849 + int n) 849 850 { 850 851 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); 851 852 852 - a->size = PCI_CFG_SPACE_SIZE; 853 853 if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) 854 - a->size = PCI_CFG_SPACE_EXP_SIZE; 855 - 856 - return a->attr.mode; 854 + return PCI_CFG_SPACE_EXP_SIZE; 855 + return PCI_CFG_SPACE_SIZE; 857 856 } 858 857 859 858 static const struct attribute_group pci_dev_config_attr_group = { 860 859 .bin_attrs = pci_dev_config_attrs, 861 - .is_bin_visible = pci_dev_config_attr_is_visible, 860 + .bin_size = pci_dev_config_attr_bin_size, 862 861 }; 863 862 864 863 /* ··· 867 868 static __maybe_unused loff_t 868 869 pci_llseek_resource(struct file *filep, 869 870 struct kobject *kobj __always_unused, 870 - struct bin_attribute *attr, 871 + const struct bin_attribute *attr, 871 872 loff_t offset, int whence) 872 873 { 873 874 return fixed_size_llseek(filep, offset, whence, attr->size); ··· 936 937 * memory space. 937 938 */ 938 939 static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj, 939 - struct bin_attribute *attr, 940 + const struct bin_attribute *attr, 940 941 struct vm_area_struct *vma) 941 942 { 942 943 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); ··· 956 957 * memory space. Returns -ENOSYS if the operation isn't supported 957 958 */ 958 959 static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, 959 - struct bin_attribute *attr, 960 + const struct bin_attribute *attr, 960 961 struct vm_area_struct *vma) 961 962 { 962 963 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); ··· 1060 1061 * 1061 1062 * Use the regular PCI mapping routines to map a PCI resource into userspace. 1062 1063 */ 1063 - static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, 1064 + static int pci_mmap_resource(struct kobject *kobj, const struct bin_attribute *attr, 1064 1065 struct vm_area_struct *vma, int write_combine) 1065 1066 { 1066 1067 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); ··· 1085 1086 } 1086 1087 1087 1088 static int pci_mmap_resource_uc(struct file *filp, struct kobject *kobj, 1088 - struct bin_attribute *attr, 1089 + const struct bin_attribute *attr, 1089 1090 struct vm_area_struct *vma) 1090 1091 { 1091 1092 return pci_mmap_resource(kobj, attr, vma, 0); 1092 1093 } 1093 1094 1094 1095 static int pci_mmap_resource_wc(struct file *filp, struct kobject *kobj, 1095 - struct bin_attribute *attr, 1096 + const struct bin_attribute *attr, 1096 1097 struct vm_area_struct *vma) 1097 1098 { 1098 1099 return pci_mmap_resource(kobj, attr, vma, 1); ··· 1352 1353 }; 1353 1354 1354 1355 static umode_t pci_dev_rom_attr_is_visible(struct kobject *kobj, 1355 - struct bin_attribute *a, int n) 1356 + const struct bin_attribute *a, int n) 1356 1357 { 1357 1358 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); 1358 - size_t rom_size; 1359 1359 1360 1360 /* If the device has a ROM, try to expose it in sysfs. */ 1361 - rom_size = pci_resource_len(pdev, PCI_ROM_RESOURCE); 1362 - if (!rom_size) 1361 + if (!pci_resource_end(pdev, PCI_ROM_RESOURCE)) 1363 1362 return 0; 1364 1363 1365 - a->size = rom_size; 1366 - 1367 1364 return a->attr.mode; 1365 + } 1366 + 1367 + static size_t pci_dev_rom_attr_bin_size(struct kobject *kobj, 1368 + const struct bin_attribute *a, int n) 1369 + { 1370 + struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); 1371 + 1372 + return pci_resource_len(pdev, PCI_ROM_RESOURCE); 1368 1373 } 1369 1374 1370 1375 static const struct attribute_group pci_dev_rom_attr_group = { 1371 1376 .bin_attrs = pci_dev_rom_attrs, 1372 1377 .is_bin_visible = pci_dev_rom_attr_is_visible, 1378 + .bin_size = pci_dev_rom_attr_bin_size, 1373 1379 }; 1374 1380 1375 1381 static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
+1 -1
drivers/pci/vpd.c
··· 325 325 }; 326 326 327 327 static umode_t vpd_attr_is_visible(struct kobject *kobj, 328 - struct bin_attribute *a, int n) 328 + const struct bin_attribute *a, int n) 329 329 { 330 330 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); 331 331
-1
drivers/perf/arm-ni.c
··· 247 247 248 248 static const struct attribute_group arm_ni_other_attr_group = { 249 249 .attrs = arm_ni_other_attrs, 250 - NULL 251 250 }; 252 251 253 252 static const struct attribute_group *arm_ni_attr_groups[] = {
+1 -1
drivers/phy/tegra/xusb.c
··· 543 543 544 544 device_initialize(&port->dev); 545 545 port->dev.type = &tegra_xusb_port_type; 546 - port->dev.of_node = of_node_get(np); 546 + device_set_node(&port->dev, of_fwnode_handle(of_node_get(np))); 547 547 port->dev.parent = padctl->dev; 548 548 549 549 err = dev_set_name(&port->dev, "%s-%u", name, index);
+1 -1
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
··· 309 309 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 310 310 struct iproc_gpio *chip = gpiochip_get_data(gc); 311 311 312 - seq_printf(p, dev_name(chip->dev)); 312 + seq_puts(p, dev_name(chip->dev)); 313 313 } 314 314 315 315 static const struct irq_chip iproc_gpio_irq_chip = {
+1 -1
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
··· 734 734 struct gpio_chip *chip = irq_data_get_irq_chip_data(d); 735 735 struct armada_37xx_pinctrl *info = gpiochip_get_data(chip); 736 736 737 - seq_printf(p, info->data->name); 737 + seq_puts(p, info->data->name); 738 738 } 739 739 740 740 static const struct irq_chip armada_37xx_irqchip = {
+1 -1
drivers/pinctrl/pinctrl-mcp23s08.c
··· 569 569 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 570 570 struct mcp23s08 *mcp = gpiochip_get_data(gc); 571 571 572 - seq_printf(p, dev_name(mcp->dev)); 572 + seq_puts(p, dev_name(mcp->dev)); 573 573 } 574 574 575 575 static const struct irq_chip mcp23s08_irq_chip = {
+1 -1
drivers/pinctrl/pinctrl-stmfx.c
··· 599 599 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(d); 600 600 struct stmfx_pinctrl *pctl = gpiochip_get_data(gpio_chip); 601 601 602 - seq_printf(p, dev_name(pctl->dev)); 602 + seq_puts(p, dev_name(pctl->dev)); 603 603 } 604 604 605 605 static const struct irq_chip stmfx_pinctrl_irq_chip = {
+1 -1
drivers/pinctrl/pinctrl-sx150x.c
··· 584 584 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 585 585 struct sx150x_pinctrl *pctl = gpiochip_get_data(gc); 586 586 587 - seq_printf(p, pctl->client->name); 587 + seq_puts(p, pctl->client->name); 588 588 } 589 589 590 590 static const struct irq_chip sx150x_irq_chip = {
+1 -1
drivers/pinctrl/renesas/pinctrl-rzg2l.c
··· 2332 2332 { 2333 2333 struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 2334 2334 2335 - seq_printf(p, dev_name(gc->parent)); 2335 + seq_puts(p, dev_name(gc->parent)); 2336 2336 } 2337 2337 2338 2338 static int rzg2l_gpio_irq_set_wake(struct irq_data *data, unsigned int on)
+1 -1
drivers/platform/x86/amd/hsmp/acpi.c
··· 236 236 } 237 237 238 238 static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, 239 - struct bin_attribute *battr, int id) 239 + const struct bin_attribute *battr, int id) 240 240 { 241 241 if (hsmp_pdev->proto_ver == HSMP_PROTO_VER6) 242 242 return battr->attr.mode;
+1 -1
drivers/platform/x86/amd/hsmp/plat.c
··· 75 75 } 76 76 77 77 static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj, 78 - struct bin_attribute *battr, int id) 78 + const struct bin_attribute *battr, int id) 79 79 { 80 80 u16 sock_ind; 81 81
+1 -1
drivers/platform/x86/intel/pmt/class.c
··· 105 105 106 106 static int 107 107 intel_pmt_mmap(struct file *filp, struct kobject *kobj, 108 - struct bin_attribute *attr, struct vm_area_struct *vma) 108 + const struct bin_attribute *attr, struct vm_area_struct *vma) 109 109 { 110 110 struct intel_pmt_entry *entry = container_of(attr, 111 111 struct intel_pmt_entry,
+1 -1
drivers/platform/x86/intel/sdsi.c
··· 541 541 }; 542 542 543 543 static umode_t 544 - sdsi_battr_is_visible(struct kobject *kobj, struct bin_attribute *attr, int n) 544 + sdsi_battr_is_visible(struct kobject *kobj, const struct bin_attribute *attr, int n) 545 545 { 546 546 struct device *dev = kobj_to_dev(kobj); 547 547 struct sdsi_priv *priv = dev_get_drvdata(dev);
-1
drivers/s390/char/con3215.c
··· 803 803 804 804 static struct attribute_group con3215_drv_attr_group = { 805 805 .attrs = con3215_drv_attrs, 806 - NULL, 807 806 }; 808 807 809 808 static const struct attribute_group *con3215_drv_attr_groups[] = {
+1 -1
drivers/scsi/scsi_sysfs.c
··· 1274 1274 } 1275 1275 1276 1276 static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj, 1277 - struct bin_attribute *attr, int i) 1277 + const struct bin_attribute *attr, int i) 1278 1278 { 1279 1279 struct device *dev = kobj_to_dev(kobj); 1280 1280 struct scsi_device *sdev = to_scsi_device(dev);
+1 -1
drivers/uio/uio_hv_generic.c
··· 135 135 * The ring buffer is allocated as contiguous memory by vmbus_open 136 136 */ 137 137 static int hv_uio_ring_mmap(struct file *filp, struct kobject *kobj, 138 - struct bin_attribute *attr, 138 + const struct bin_attribute *attr, 139 139 struct vm_area_struct *vma) 140 140 { 141 141 struct vmbus_channel *channel
+1 -1
drivers/usb/core/sysfs.c
··· 925 925 }; 926 926 927 927 static umode_t dev_bin_attrs_are_visible(struct kobject *kobj, 928 - struct bin_attribute *a, int n) 928 + const struct bin_attribute *a, int n) 929 929 { 930 930 struct device *dev = kobj_to_dev(kobj); 931 931 struct usb_device *udev = to_usb_device(dev);
+21 -9
fs/sysfs/file.c
··· 91 91 count = size - pos; 92 92 } 93 93 94 - if (!battr->read) 94 + if (!battr->read && !battr->read_new) 95 95 return -EIO; 96 + 97 + if (battr->read_new) 98 + return battr->read_new(of->file, kobj, battr, buf, pos, count); 96 99 97 100 return battr->read(of->file, kobj, battr, buf, pos, count); 98 101 } ··· 155 152 if (!count) 156 153 return 0; 157 154 158 - if (!battr->write) 155 + if (!battr->write && !battr->write_new) 159 156 return -EIO; 157 + 158 + if (battr->write_new) 159 + return battr->write_new(of->file, kobj, battr, buf, pos, count); 160 160 161 161 return battr->write(of->file, kobj, battr, buf, pos, count); 162 162 } ··· 321 315 } 322 316 323 317 int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent, 324 - const struct bin_attribute *battr, umode_t mode, 318 + const struct bin_attribute *battr, umode_t mode, size_t size, 325 319 kuid_t uid, kgid_t gid, const void *ns) 326 320 { 327 321 const struct attribute *attr = &battr->attr; ··· 329 323 const struct kernfs_ops *ops; 330 324 struct kernfs_node *kn; 331 325 326 + if (battr->read && battr->read_new) 327 + return -EINVAL; 328 + 329 + if (battr->write && battr->write_new) 330 + return -EINVAL; 331 + 332 332 if (battr->mmap) 333 333 ops = &sysfs_bin_kfops_mmap; 334 - else if (battr->read && battr->write) 334 + else if ((battr->read || battr->read_new) && (battr->write || battr->write_new)) 335 335 ops = &sysfs_bin_kfops_rw; 336 - else if (battr->read) 336 + else if (battr->read || battr->read_new) 337 337 ops = &sysfs_bin_kfops_ro; 338 - else if (battr->write) 338 + else if (battr->write || battr->write_new) 339 339 ops = &sysfs_bin_kfops_wo; 340 340 else 341 341 ops = &sysfs_file_kfops_empty; ··· 352 340 #endif 353 341 354 342 kn = __kernfs_create_file(parent, attr->name, mode & 0777, uid, gid, 355 - battr->size, ops, (void *)attr, ns, key); 343 + size, ops, (void *)attr, ns, key); 356 344 if (IS_ERR(kn)) { 357 345 if (PTR_ERR(kn) == -EEXIST) 358 346 sysfs_warn_dup(parent, attr->name); ··· 592 580 return -EINVAL; 593 581 594 582 kobject_get_ownership(kobj, &uid, &gid); 595 - return sysfs_add_bin_file_mode_ns(kobj->sd, attr, attr->attr.mode, uid, 596 - gid, NULL); 583 + return sysfs_add_bin_file_mode_ns(kobj->sd, attr, attr->attr.mode, 584 + attr->size, uid, gid, NULL); 597 585 } 598 586 EXPORT_SYMBOL_GPL(sysfs_create_bin_file); 599 587
+4 -1
fs/sysfs/group.c
··· 87 87 if (grp->bin_attrs) { 88 88 for (i = 0, bin_attr = grp->bin_attrs; *bin_attr; i++, bin_attr++) { 89 89 umode_t mode = (*bin_attr)->attr.mode; 90 + size_t size = (*bin_attr)->size; 90 91 91 92 if (update) 92 93 kernfs_remove_by_name(parent, ··· 98 97 if (!mode) 99 98 continue; 100 99 } 100 + if (grp->bin_size) 101 + size = grp->bin_size(kobj, *bin_attr, i); 101 102 102 103 WARN(mode & ~(SYSFS_PREALLOC | 0664), 103 104 "Attribute %s: Invalid permissions 0%o\n", ··· 107 104 108 105 mode &= SYSFS_PREALLOC | 0664; 109 106 error = sysfs_add_bin_file_mode_ns(parent, *bin_attr, 110 - mode, uid, gid, 107 + mode, size, uid, gid, 111 108 NULL); 112 109 if (error) 113 110 break;
+1 -1
fs/sysfs/sysfs.h
··· 31 31 const struct attribute *attr, umode_t amode, kuid_t uid, 32 32 kgid_t gid, const void *ns); 33 33 int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent, 34 - const struct bin_attribute *battr, umode_t mode, 34 + const struct bin_attribute *battr, umode_t mode, size_t size, 35 35 kuid_t uid, kgid_t gid, const void *ns); 36 36 37 37 /*
-4
include/linux/auxiliary_bus.h
··· 269 269 #define module_auxiliary_driver(__auxiliary_driver) \ 270 270 module_driver(__auxiliary_driver, auxiliary_driver_register, auxiliary_driver_unregister) 271 271 272 - struct auxiliary_device *auxiliary_find_device(struct device *start, 273 - const void *data, 274 - device_match_t match); 275 - 276 272 #endif /* _AUXILIARY_BUS_H_ */
-8
include/linux/list.h
··· 687 687 for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) 688 688 689 689 /** 690 - * list_for_each_reverse - iterate backwards over a list 691 - * @pos: the &struct list_head to use as a loop cursor. 692 - * @head: the head for your list. 693 - */ 694 - #define list_for_each_reverse(pos, head) \ 695 - for (pos = (head)->prev; pos != (head); pos = pos->prev) 696 - 697 - /** 698 690 * list_for_each_rcu - Iterate over a list in an RCU-safe fashion 699 691 * @pos: the &struct list_head to use as a loop cursor. 700 692 * @head: the head for your list.
+60 -39
include/linux/sysfs.h
··· 87 87 * SYSFS_GROUP_VISIBLE() when assigning this callback to 88 88 * specify separate _group_visible() and _attr_visible() 89 89 * handlers. 90 + * @bin_size: 91 + * Optional: Function to return the size of a binary attribute 92 + * of the group. Will be called repeatedly for each binary 93 + * attribute in the group. Overwrites the size field embedded 94 + * inside the attribute itself. 90 95 * @attrs: Pointer to NULL terminated list of attributes. 91 96 * @bin_attrs: Pointer to NULL terminated list of binary attributes. 92 97 * Either attrs or bin_attrs or both must be provided. ··· 101 96 umode_t (*is_visible)(struct kobject *, 102 97 struct attribute *, int); 103 98 umode_t (*is_bin_visible)(struct kobject *, 104 - struct bin_attribute *, int); 99 + const struct bin_attribute *, int); 100 + size_t (*bin_size)(struct kobject *, 101 + const struct bin_attribute *, 102 + int); 105 103 struct attribute **attrs; 106 - struct bin_attribute **bin_attrs; 104 + union { 105 + struct bin_attribute **bin_attrs; 106 + const struct bin_attribute *const *bin_attrs_new; 107 + }; 107 108 }; 108 109 109 110 #define SYSFS_PREALLOC 010000 ··· 202 191 * attributes, the group visibility is determined by the function 203 192 * specified to is_visible() not is_bin_visible() 204 193 */ 205 - #define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \ 206 - static inline umode_t sysfs_group_visible_##name( \ 207 - struct kobject *kobj, struct bin_attribute *attr, int n) \ 208 - { \ 209 - if (n == 0 && !name##_group_visible(kobj)) \ 210 - return SYSFS_GROUP_INVISIBLE; \ 211 - return name##_attr_visible(kobj, attr, n); \ 194 + #define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \ 195 + static inline umode_t sysfs_group_visible_##name( \ 196 + struct kobject *kobj, const struct bin_attribute *attr, int n) \ 197 + { \ 198 + if (n == 0 && !name##_group_visible(kobj)) \ 199 + return SYSFS_GROUP_INVISIBLE; \ 200 + return name##_attr_visible(kobj, attr, n); \ 212 201 } 213 202 214 - #define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \ 215 - static inline umode_t sysfs_group_visible_##name( \ 216 - struct kobject *kobj, struct bin_attribute *a, int n) \ 217 - { \ 218 - if (n == 0 && !name##_group_visible(kobj)) \ 219 - return SYSFS_GROUP_INVISIBLE; \ 220 - return a->mode; \ 203 + #define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \ 204 + static inline umode_t sysfs_group_visible_##name( \ 205 + struct kobject *kobj, const struct bin_attribute *a, int n) \ 206 + { \ 207 + if (n == 0 && !name##_group_visible(kobj)) \ 208 + return SYSFS_GROUP_INVISIBLE; \ 209 + return a->mode; \ 221 210 } 222 211 223 212 #define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn ··· 308 297 struct address_space *(*f_mapping)(void); 309 298 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, 310 299 char *, loff_t, size_t); 300 + ssize_t (*read_new)(struct file *, struct kobject *, const struct bin_attribute *, 301 + char *, loff_t, size_t); 311 302 ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, 312 303 char *, loff_t, size_t); 313 - loff_t (*llseek)(struct file *, struct kobject *, struct bin_attribute *, 304 + ssize_t (*write_new)(struct file *, struct kobject *, 305 + const struct bin_attribute *, char *, loff_t, size_t); 306 + loff_t (*llseek)(struct file *, struct kobject *, const struct bin_attribute *, 314 307 loff_t, int); 315 - int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr, 308 + int (*mmap)(struct file *, struct kobject *, const struct bin_attribute *attr, 316 309 struct vm_area_struct *vma); 317 310 }; 318 311 ··· 332 317 */ 333 318 #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) 334 319 320 + typedef ssize_t __sysfs_bin_rw_handler_new(struct file *, struct kobject *, 321 + const struct bin_attribute *, char *, loff_t, size_t); 322 + 335 323 /* macros to create static binary attributes easier */ 336 324 #define __BIN_ATTR(_name, _mode, _read, _write, _size) { \ 337 325 .attr = { .name = __stringify(_name), .mode = _mode }, \ 338 - .read = _read, \ 339 - .write = _write, \ 326 + .read = _Generic(_read, \ 327 + __sysfs_bin_rw_handler_new * : NULL, \ 328 + default : _read \ 329 + ), \ 330 + .read_new = _Generic(_read, \ 331 + __sysfs_bin_rw_handler_new * : _read, \ 332 + default : NULL \ 333 + ), \ 334 + .write = _Generic(_write, \ 335 + __sysfs_bin_rw_handler_new * : NULL, \ 336 + default : _write \ 337 + ), \ 338 + .write_new = _Generic(_write, \ 339 + __sysfs_bin_rw_handler_new * : _write, \ 340 + default : NULL \ 341 + ), \ 340 342 .size = _size, \ 341 343 } 342 344 343 - #define __BIN_ATTR_RO(_name, _size) { \ 344 - .attr = { .name = __stringify(_name), .mode = 0444 }, \ 345 - .read = _name##_read, \ 346 - .size = _size, \ 347 - } 345 + #define __BIN_ATTR_RO(_name, _size) \ 346 + __BIN_ATTR(_name, 0444, _name##_read, NULL, _size) 348 347 349 - #define __BIN_ATTR_WO(_name, _size) { \ 350 - .attr = { .name = __stringify(_name), .mode = 0200 }, \ 351 - .write = _name##_write, \ 352 - .size = _size, \ 353 - } 348 + #define __BIN_ATTR_WO(_name, _size) \ 349 + __BIN_ATTR(_name, 0200, NULL, _name##_write, _size) 354 350 355 351 #define __BIN_ATTR_RW(_name, _size) \ 356 352 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size) ··· 382 356 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) 383 357 384 358 385 - #define __BIN_ATTR_ADMIN_RO(_name, _size) { \ 386 - .attr = { .name = __stringify(_name), .mode = 0400 }, \ 387 - .read = _name##_read, \ 388 - .size = _size, \ 389 - } 359 + #define __BIN_ATTR_ADMIN_RO(_name, _size) \ 360 + __BIN_ATTR(_name, 0400, _name##_read, NULL, _size) 390 361 391 362 #define __BIN_ATTR_ADMIN_RW(_name, _size) \ 392 363 __BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size) ··· 394 371 #define BIN_ATTR_ADMIN_RW(_name, _size) \ 395 372 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) 396 373 397 - #define __BIN_ATTR_SIMPLE_RO(_name, _mode) { \ 398 - .attr = { .name = __stringify(_name), .mode = _mode }, \ 399 - .read = sysfs_bin_attr_simple_read, \ 400 - } 374 + #define __BIN_ATTR_SIMPLE_RO(_name, _mode) \ 375 + __BIN_ATTR(_name, _mode, sysfs_bin_attr_simple_read, NULL, 0) 401 376 402 377 #define BIN_ATTR_SIMPLE_RO(_name) \ 403 378 struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0444)
-3
kernel/cpu.c
··· 2866 2866 static const struct attribute_group cpuhp_cpu_attr_group = { 2867 2867 .attrs = cpuhp_cpu_attrs, 2868 2868 .name = "hotplug", 2869 - NULL 2870 2869 }; 2871 2870 2872 2871 static ssize_t states_show(struct device *dev, ··· 2897 2898 static const struct attribute_group cpuhp_cpu_root_attr_group = { 2898 2899 .attrs = cpuhp_cpu_root_attrs, 2899 2900 .name = "hotplug", 2900 - NULL 2901 2901 }; 2902 2902 2903 2903 #ifdef CONFIG_HOTPLUG_SMT ··· 3018 3020 static const struct attribute_group cpuhp_smt_attr_group = { 3019 3021 .attrs = cpuhp_smt_attrs, 3020 3022 .name = "smt", 3021 - NULL 3022 3023 }; 3023 3024 3024 3025 static int __init cpu_smt_sysfs_init(void)
+2 -4
lib/devres.c
··· 115 115 */ 116 116 void devm_iounmap(struct device *dev, void __iomem *addr) 117 117 { 118 - WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match, 118 + WARN_ON(devres_release(dev, devm_ioremap_release, devm_ioremap_match, 119 119 (__force void *)addr)); 120 - iounmap(addr); 121 120 } 122 121 EXPORT_SYMBOL(devm_iounmap); 123 122 ··· 307 308 */ 308 309 void devm_ioport_unmap(struct device *dev, void __iomem *addr) 309 310 { 310 - ioport_unmap(addr); 311 - WARN_ON(devres_destroy(dev, devm_ioport_map_release, 311 + WARN_ON(devres_release(dev, devm_ioport_map_release, 312 312 devm_ioport_map_match, (__force void *)addr)); 313 313 } 314 314 EXPORT_SYMBOL(devm_ioport_unmap);