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

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

Pull driver core updates from Greg KH:
"Here are a small set of changes for 6.5-rc1 for some driver core
changes. Included in here are:

- device property cleanups to make it easier to write "agnostic"
drivers when regards to the firmware layer underneath them (DT vs.
ACPI)

- debugfs documentation updates

- devres additions

- sysfs documentation and changes to handle empty directory creation
logic better

- tiny kernfs optimizations

- other tiny changes

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

* tag 'driver-core-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
sysfs: Skip empty folders creation
sysfs: Improve readability by following the kernel coding style
drivers: fwnode: fix fwnode_irq_get[_byname]()
ata: ahci_platform: Make code agnostic to OF/ACPI
device property: Implement device_is_compatible()
ACPI: Move ACPI_DEVICE_CLASS() to mod_devicetable.h
base/node: Use 'property' to identify an access parameter
driver core: device.h: add some missing kerneldocs
kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
isa: Remove unnecessary checks
MAINTAINERS: add entry for auxiliary bus
debugfs: Correct the 'debugfs_create_str' docs
serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array
iio: adc: Use devm_krealloc_array
hwmon: pmbus: Use devm_krealloc_array

+192 -63
+10
MAINTAINERS
··· 3385 3385 F: kernel/audit* 3386 3386 F: lib/*audit.c 3387 3387 3388 + AUXILIARY BUS DRIVER 3389 + M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 3390 + R: Dave Ertman <david.m.ertman@intel.com> 3391 + R: Ira Weiny <ira.weiny@intel.com> 3392 + S: Supported 3393 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 3394 + F: Documentation/driver-api/auxiliary_bus.rst 3395 + F: drivers/base/auxiliary.c 3396 + F: include/linux/auxiliary_bus.h 3397 + 3388 3398 AUXILIARY DISPLAY DRIVERS 3389 3399 M: Miguel Ojeda <ojeda@kernel.org> 3390 3400 S: Maintained
+4 -4
drivers/ata/ahci_platform.c
··· 9 9 */ 10 10 11 11 #include <linux/kernel.h> 12 + #include <linux/mod_devicetable.h> 12 13 #include <linux/module.h> 13 14 #include <linux/pm.h> 14 15 #include <linux/device.h> 15 - #include <linux/of_device.h> 16 16 #include <linux/platform_device.h> 17 + #include <linux/property.h> 17 18 #include <linux/libata.h> 18 19 #include <linux/ahci_platform.h> 19 - #include <linux/acpi.h> 20 20 #include <linux/pci_ids.h> 21 21 #include "ahci.h" 22 22 ··· 56 56 if (rc) 57 57 return rc; 58 58 59 - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) 59 + if (device_is_compatible(dev, "hisilicon,hisi-ahci")) 60 60 hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; 61 61 62 - port = acpi_device_get_match_data(dev); 62 + port = device_get_match_data(dev); 63 63 if (!port) 64 64 port = &ahci_port_info; 65 65
+2 -5
drivers/base/isa.c
··· 149 149 break; 150 150 } 151 151 152 - if (isa_dev->dev.platform_data) { 153 - isa_dev->next = isa_driver->devices; 154 - isa_driver->devices = &isa_dev->dev; 155 - } else 156 - device_unregister(&isa_dev->dev); 152 + isa_dev->next = isa_driver->devices; 153 + isa_driver->devices = &isa_dev->dev; 157 154 } 158 155 159 156 if (!error && !isa_driver->devices)
+4 -4
drivers/base/node.c
··· 162 162 } 163 163 164 164 #ifdef CONFIG_HMEM_REPORTING 165 - #define ACCESS_ATTR(name) \ 166 - static ssize_t name##_show(struct device *dev, \ 165 + #define ACCESS_ATTR(property) \ 166 + static ssize_t property##_show(struct device *dev, \ 167 167 struct device_attribute *attr, \ 168 168 char *buf) \ 169 169 { \ 170 170 return sysfs_emit(buf, "%u\n", \ 171 - to_access_nodes(dev)->hmem_attrs.name); \ 171 + to_access_nodes(dev)->hmem_attrs.property); \ 172 172 } \ 173 - static DEVICE_ATTR_RO(name) 173 + static DEVICE_ATTR_RO(property) 174 174 175 175 ACCESS_ATTR(read_bandwidth); 176 176 ACCESS_ATTR(read_latency);
+9 -3
drivers/base/property.c
··· 987 987 * @fwnode: Pointer to the firmware node 988 988 * @index: Zero-based index of the IRQ 989 989 * 990 - * Return: Linux IRQ number on success. Other values are determined 991 - * according to acpi_irq_get() or of_irq_get() operation. 990 + * Return: Linux IRQ number on success. Negative errno on failure. 992 991 */ 993 992 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) 994 993 { 995 - return fwnode_call_int_op(fwnode, irq_get, index); 994 + int ret; 995 + 996 + ret = fwnode_call_int_op(fwnode, irq_get, index); 997 + /* We treat mapping errors as invalid case */ 998 + if (ret == 0) 999 + return -EINVAL; 1000 + 1001 + return ret; 996 1002 } 997 1003 EXPORT_SYMBOL(fwnode_irq_get); 998 1004
+3 -3
drivers/hwmon/pmbus/pmbus_core.c
··· 1191 1191 { 1192 1192 if (data->num_attributes >= data->max_attributes - 1) { 1193 1193 int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE; 1194 - void *new_attrs = devm_krealloc(data->dev, data->group.attrs, 1195 - new_max_attrs * sizeof(void *), 1196 - GFP_KERNEL); 1194 + void *new_attrs = devm_krealloc_array(data->dev, data->group.attrs, 1195 + new_max_attrs, sizeof(void *), 1196 + GFP_KERNEL); 1197 1197 if (!new_attrs) 1198 1198 return -ENOMEM; 1199 1199 data->group.attrs = new_attrs;
+3 -6
drivers/iio/adc/xilinx-ams.c
··· 1263 1263 struct device *dev = indio_dev->dev.parent; 1264 1264 struct fwnode_handle *child = NULL; 1265 1265 struct fwnode_handle *fwnode = dev_fwnode(dev); 1266 - size_t ams_size, dev_size; 1266 + size_t ams_size; 1267 1267 int ret, ch_cnt = 0, i, rising_off, falling_off; 1268 1268 unsigned int num_channels = 0; 1269 1269 ··· 1320 1320 } 1321 1321 } 1322 1322 1323 - dev_size = array_size(sizeof(*dev_channels), num_channels); 1324 - if (dev_size == SIZE_MAX) 1325 - return -ENOMEM; 1326 - 1327 - dev_channels = devm_krealloc(dev, ams_channels, dev_size, GFP_KERNEL); 1323 + dev_channels = devm_krealloc_array(dev, ams_channels, num_channels, 1324 + sizeof(*dev_channels), GFP_KERNEL); 1328 1325 if (!dev_channels) 1329 1326 return -ENOMEM; 1330 1327
+7 -10
drivers/iio/adc/xilinx-xadc-core.c
··· 613 613 const unsigned long *mask) 614 614 { 615 615 struct xadc *xadc = iio_priv(indio_dev); 616 - size_t new_size, n; 616 + size_t n; 617 617 void *data; 618 618 619 619 n = bitmap_weight(mask, indio_dev->masklength); 620 620 621 - if (check_mul_overflow(n, sizeof(*xadc->data), &new_size)) 622 - return -ENOMEM; 623 - 624 - data = devm_krealloc(indio_dev->dev.parent, xadc->data, 625 - new_size, GFP_KERNEL); 621 + data = devm_krealloc_array(indio_dev->dev.parent, xadc->data, 622 + n, sizeof(*xadc->data), GFP_KERNEL); 626 623 if (!data) 627 624 return -ENOMEM; 628 625 629 - memset(data, 0, new_size); 626 + memset(data, 0, n * sizeof(*xadc->data)); 630 627 xadc->data = data; 631 628 632 629 return 0; ··· 1278 1281 } 1279 1282 1280 1283 indio_dev->num_channels = num_channels; 1281 - indio_dev->channels = devm_krealloc(dev, channels, 1282 - sizeof(*channels) * num_channels, 1283 - GFP_KERNEL); 1284 + indio_dev->channels = devm_krealloc_array(dev, channels, 1285 + num_channels, sizeof(*channels), 1286 + GFP_KERNEL); 1284 1287 /* If we can't resize the channels array, just use the original */ 1285 1288 if (!indio_dev->channels) 1286 1289 indio_dev->channels = channels;
+5
drivers/tty/serial/qcom_geni_serial.c
··· 1053 1053 (port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE; 1054 1054 1055 1055 if (port->rx_buf && (old_rx_fifo_depth != port->rx_fifo_depth) && port->rx_fifo_depth) { 1056 + /* 1057 + * Use krealloc rather than krealloc_array because rx_buf is 1058 + * accessed as 1 byte entries as well as 4 byte entries so it's 1059 + * not necessarily an array. 1060 + */ 1056 1061 port->rx_buf = devm_krealloc(uport->dev, port->rx_buf, 1057 1062 port->rx_fifo_depth * sizeof(u32), 1058 1063 GFP_KERNEL);
-9
fs/debugfs/file.c
··· 940 940 * This function creates a file in debugfs with the given name that 941 941 * contains the value of the variable @value. If the @mode variable is so 942 942 * set, it can be read from, and written to. 943 - * 944 - * This function will return a pointer to a dentry if it succeeds. This 945 - * pointer must be passed to the debugfs_remove() function when the file is 946 - * to be removed (no automatic cleanup happens if your module is unloaded, 947 - * you are responsible here.) If an error occurs, ERR_PTR(-ERROR) will be 948 - * returned. 949 - * 950 - * If debugfs is not enabled in the kernel, the value ERR_PTR(-ENODEV) will 951 - * be returned. 952 943 */ 953 944 void debugfs_create_str(const char *name, umode_t mode, 954 945 struct dentry *parent, char **value)
+2
fs/kernfs/dir.c
··· 655 655 return kn; 656 656 657 657 err_out3: 658 + spin_lock(&kernfs_idr_lock); 658 659 idr_remove(&root->ino_idr, (u32)kernfs_ino(kn)); 660 + spin_unlock(&kernfs_idr_lock); 659 661 err_out2: 660 662 kmem_cache_free(kernfs_node_cache, kn); 661 663 err_out1:
+8 -4
fs/sysfs/group.c
··· 118 118 /* Updates may happen before the object has been instantiated */ 119 119 if (unlikely(update && !kobj->sd)) 120 120 return -EINVAL; 121 + 121 122 if (!grp->attrs && !grp->bin_attrs) { 122 - WARN(1, "sysfs: (bin_)attrs not set by subsystem for group: %s/%s\n", 123 - kobj->name, grp->name ?: ""); 124 - return -EINVAL; 123 + pr_debug("sysfs: (bin_)attrs not set by subsystem for group: %s/%s, skipping\n", 124 + kobj->name, grp->name ?: ""); 125 + return 0; 125 126 } 127 + 126 128 kobject_get_ownership(kobj, &uid, &gid); 127 129 if (grp->name) { 128 130 if (update) { ··· 144 142 return PTR_ERR(kn); 145 143 } 146 144 } 147 - } else 145 + } else { 148 146 kn = kobj->sd; 147 + } 148 + 149 149 kernfs_get(kn); 150 150 error = create_files(kn, kobj, uid, gid, grp, update); 151 151 if (error) {
-14
include/linux/acpi.h
··· 70 70 kfree(fwnode); 71 71 } 72 72 73 - /** 74 - * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with 75 - * the PCI-defined class-code information 76 - * 77 - * @_cls : the class, subclass, prog-if triple for this device 78 - * @_msk : the class mask for this device 79 - * 80 - * This macro is used to create a struct acpi_device_id that matches a 81 - * specific PCI class. The .id and .driver_data fields will be left 82 - * initialized with the default value. 83 - */ 84 - #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk), 85 - 86 73 static inline bool has_acpi_companion(struct device *dev) 87 74 { 88 75 return is_acpi_device_node(dev->fwnode); ··· 769 782 #define ACPI_COMPANION_SET(dev, adev) do { } while (0) 770 783 #define ACPI_HANDLE(dev) (NULL) 771 784 #define ACPI_HANDLE_FWNODE(fwnode) (NULL) 772 - #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0), 773 785 774 786 #include <acpi/acpi_numa.h> 775 787
+110 -1
include/linux/device.h
··· 96 96 const struct dev_pm_ops *pm; 97 97 }; 98 98 99 - /* interface for exporting device attributes */ 99 + /** 100 + * struct device_attribute - Interface for exporting device attributes. 101 + * @attr: sysfs attribute definition. 102 + * @show: Show handler. 103 + * @store: Store handler. 104 + */ 100 105 struct device_attribute { 101 106 struct attribute attr; 102 107 ssize_t (*show)(struct device *dev, struct device_attribute *attr, ··· 110 105 const char *buf, size_t count); 111 106 }; 112 107 108 + /** 109 + * struct dev_ext_attribute - Exported device attribute with extra context. 110 + * @attr: Exported device attribute. 111 + * @var: Pointer to context. 112 + */ 113 113 struct dev_ext_attribute { 114 114 struct device_attribute attr; 115 115 void *var; ··· 133 123 ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, 134 124 const char *buf, size_t count); 135 125 126 + /** 127 + * DEVICE_ATTR - Define a device attribute. 128 + * @_name: Attribute name. 129 + * @_mode: File mode. 130 + * @_show: Show handler. Optional, but mandatory if attribute is readable. 131 + * @_store: Store handler. Optional, but mandatory if attribute is writable. 132 + * 133 + * Convenience macro for defining a struct device_attribute. 134 + * 135 + * For example, ``DEVICE_ATTR(foo, 0644, foo_show, foo_store);`` expands to: 136 + * 137 + * .. code-block:: c 138 + * 139 + * struct device_attribute dev_attr_foo = { 140 + * .attr = { .name = "foo", .mode = 0644 }, 141 + * .show = foo_show, 142 + * .store = foo_store, 143 + * }; 144 + */ 136 145 #define DEVICE_ATTR(_name, _mode, _show, _store) \ 137 146 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) 147 + 148 + /** 149 + * DEVICE_ATTR_PREALLOC - Define a preallocated device attribute. 150 + * @_name: Attribute name. 151 + * @_mode: File mode. 152 + * @_show: Show handler. Optional, but mandatory if attribute is readable. 153 + * @_store: Store handler. Optional, but mandatory if attribute is writable. 154 + * 155 + * Like DEVICE_ATTR(), but ``SYSFS_PREALLOC`` is set on @_mode. 156 + */ 138 157 #define DEVICE_ATTR_PREALLOC(_name, _mode, _show, _store) \ 139 158 struct device_attribute dev_attr_##_name = \ 140 159 __ATTR_PREALLOC(_name, _mode, _show, _store) 160 + 161 + /** 162 + * DEVICE_ATTR_RW - Define a read-write device attribute. 163 + * @_name: Attribute name. 164 + * 165 + * Like DEVICE_ATTR(), but @_mode is 0644, @_show is <_name>_show, 166 + * and @_store is <_name>_store. 167 + */ 141 168 #define DEVICE_ATTR_RW(_name) \ 142 169 struct device_attribute dev_attr_##_name = __ATTR_RW(_name) 170 + 171 + /** 172 + * DEVICE_ATTR_ADMIN_RW - Define an admin-only read-write device attribute. 173 + * @_name: Attribute name. 174 + * 175 + * Like DEVICE_ATTR_RW(), but @_mode is 0600. 176 + */ 143 177 #define DEVICE_ATTR_ADMIN_RW(_name) \ 144 178 struct device_attribute dev_attr_##_name = __ATTR_RW_MODE(_name, 0600) 179 + 180 + /** 181 + * DEVICE_ATTR_RO - Define a readable device attribute. 182 + * @_name: Attribute name. 183 + * 184 + * Like DEVICE_ATTR(), but @_mode is 0444 and @_show is <_name>_show. 185 + */ 145 186 #define DEVICE_ATTR_RO(_name) \ 146 187 struct device_attribute dev_attr_##_name = __ATTR_RO(_name) 188 + 189 + /** 190 + * DEVICE_ATTR_ADMIN_RO - Define an admin-only readable device attribute. 191 + * @_name: Attribute name. 192 + * 193 + * Like DEVICE_ATTR_RO(), but @_mode is 0400. 194 + */ 147 195 #define DEVICE_ATTR_ADMIN_RO(_name) \ 148 196 struct device_attribute dev_attr_##_name = __ATTR_RO_MODE(_name, 0400) 197 + 198 + /** 199 + * DEVICE_ATTR_WO - Define an admin-only writable device attribute. 200 + * @_name: Attribute name. 201 + * 202 + * Like DEVICE_ATTR(), but @_mode is 0200 and @_store is <_name>_store. 203 + */ 149 204 #define DEVICE_ATTR_WO(_name) \ 150 205 struct device_attribute dev_attr_##_name = __ATTR_WO(_name) 206 + 207 + /** 208 + * DEVICE_ULONG_ATTR - Define a device attribute backed by an unsigned long. 209 + * @_name: Attribute name. 210 + * @_mode: File mode. 211 + * @_var: Identifier of unsigned long. 212 + * 213 + * Like DEVICE_ATTR(), but @_show and @_store are automatically provided 214 + * such that reads and writes to the attribute from userspace affect @_var. 215 + */ 151 216 #define DEVICE_ULONG_ATTR(_name, _mode, _var) \ 152 217 struct dev_ext_attribute dev_attr_##_name = \ 153 218 { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } 219 + 220 + /** 221 + * DEVICE_INT_ATTR - Define a device attribute backed by an int. 222 + * @_name: Attribute name. 223 + * @_mode: File mode. 224 + * @_var: Identifier of int. 225 + * 226 + * Like DEVICE_ULONG_ATTR(), but @_var is an int. 227 + */ 154 228 #define DEVICE_INT_ATTR(_name, _mode, _var) \ 155 229 struct dev_ext_attribute dev_attr_##_name = \ 156 230 { __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) } 231 + 232 + /** 233 + * DEVICE_BOOL_ATTR - Define a device attribute backed by a bool. 234 + * @_name: Attribute name. 235 + * @_mode: File mode. 236 + * @_var: Identifier of bool. 237 + * 238 + * Like DEVICE_ULONG_ATTR(), but @_var is a bool. 239 + */ 157 240 #define DEVICE_BOOL_ATTR(_name, _mode, _var) \ 158 241 struct dev_ext_attribute dev_attr_##_name = \ 159 242 { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } 243 + 160 244 #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ 161 245 struct device_attribute dev_attr_##_name = \ 162 246 __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) ··· 815 711 /* Get the wakeup routines, which depend on struct device */ 816 712 #include <linux/pm_wakeup.h> 817 713 714 + /** 715 + * dev_name - Return a device's name. 716 + * @dev: Device with name to get. 717 + * Return: The kobject name of the device, or its initial name if unavailable. 718 + */ 818 719 static inline const char *dev_name(const struct device *dev) 819 720 { 820 721 /* Use the init name until the kobject becomes available */
+13
include/linux/mod_devicetable.h
··· 221 221 __u32 cls_msk; 222 222 }; 223 223 224 + /** 225 + * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with 226 + * the PCI-defined class-code information 227 + * 228 + * @_cls : the class, subclass, prog-if triple for this device 229 + * @_msk : the class mask for this device 230 + * 231 + * This macro is used to create a struct acpi_device_id that matches a 232 + * specific PCI class. The .id and .driver_data fields will be left 233 + * initialized with the default value. 234 + */ 235 + #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk), 236 + 224 237 #define PNP_ID_LEN 8 225 238 #define PNP_MAX_DEVICES 8 226 239
+12
include/linux/property.h
··· 85 85 return fwnode_property_match_string(fwnode, "compatible", compat) >= 0; 86 86 } 87 87 88 + /** 89 + * device_is_compatible - match 'compatible' property of the device with a given string 90 + * @dev: Pointer to the struct device 91 + * @compat: The string to match 'compatible' property with 92 + * 93 + * Returns: true if matches, otherwise false. 94 + */ 95 + static inline bool device_is_compatible(const struct device *dev, const char *compat) 96 + { 97 + return fwnode_device_is_compatible(dev_fwnode(dev), compat); 98 + } 99 + 88 100 int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, 89 101 const char *prop, const char *nargs_prop, 90 102 unsigned int nargs, unsigned int index,