Skip to content

Commit 55cb93f

Browse files
committed
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() ...
2 parents a0c1ca3 + acfeb6d commit 55cb93f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+243
-254
lines changed

Documentation/driver-api/auxiliary_bus.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Auxiliary Device Creation
2424

2525
.. kernel-doc:: drivers/base/auxiliary.c
2626
:identifiers: auxiliary_device_init __auxiliary_device_add
27-
auxiliary_find_device
2827

2928
Auxiliary Device Memory Model and Lifespan
3029
------------------------------------------

arch/alpha/kernel/pci-sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int __pci_mmap_fits(struct pci_dev *pdev, int num,
6464
* Return: %0 on success, negative error code otherwise
6565
*/
6666
static int pci_mmap_resource(struct kobject *kobj,
67-
struct bin_attribute *attr,
67+
const struct bin_attribute *attr,
6868
struct vm_area_struct *vma, int sparse)
6969
{
7070
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -93,14 +93,14 @@ static int pci_mmap_resource(struct kobject *kobj,
9393
}
9494

9595
static int pci_mmap_resource_sparse(struct file *filp, struct kobject *kobj,
96-
struct bin_attribute *attr,
96+
const struct bin_attribute *attr,
9797
struct vm_area_struct *vma)
9898
{
9999
return pci_mmap_resource(kobj, attr, vma, 1);
100100
}
101101

102102
static int pci_mmap_resource_dense(struct file *filp, struct kobject *kobj,
103-
struct bin_attribute *attr,
103+
const struct bin_attribute *attr,
104104
struct vm_area_struct *vma)
105105
{
106106
return pci_mmap_resource(kobj, attr, vma, 0);

drivers/base/auxiliary.c

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
* Auxiliary devices are created and registered by a subsystem-level core
9393
* device that needs to break up its functionality into smaller fragments. One
9494
* 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
9696
* contains the auxiliary_device and any associated shared data/callbacks
9797
* needed to establish the connection with the parent.
9898
*
@@ -335,35 +335,6 @@ int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname)
335335
}
336336
EXPORT_SYMBOL_GPL(__auxiliary_device_add);
337337

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-
367338
/**
368339
* __auxiliary_driver_register - register a driver for auxiliary bus devices
369340
* @auxdrv: auxiliary_driver structure

drivers/base/cacheinfo.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ static int of_count_cache_leaves(struct device_node *np)
254254
{
255255
unsigned int leaves = 0;
256256

257-
if (of_property_read_bool(np, "cache-size"))
257+
if (of_property_present(np, "cache-size"))
258258
++leaves;
259-
if (of_property_read_bool(np, "i-cache-size"))
259+
if (of_property_present(np, "i-cache-size"))
260260
++leaves;
261-
if (of_property_read_bool(np, "d-cache-size"))
261+
if (of_property_present(np, "d-cache-size"))
262262
++leaves;
263263

264264
if (!leaves) {
@@ -367,9 +367,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu)
367367

368368
cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map);
369369
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))
373371
continue;/* skip if itself or no cacheinfo */
374372
for (sib_index = 0; sib_index < cache_leaves(i); sib_index++) {
375373
sib_leaf = per_cpu_cacheinfo_idx(i, sib_index);
@@ -409,10 +407,7 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
409407
for (index = 0; index < cache_leaves(cpu); index++) {
410408
this_leaf = per_cpu_cacheinfo_idx(cpu, index);
411409
for_each_cpu(sibling, &this_leaf->shared_cpu_map) {
412-
struct cpu_cacheinfo *sib_cpu_ci =
413-
get_cpu_cacheinfo(sibling);
414-
415-
if (sibling == cpu || !sib_cpu_ci->info_list)
410+
if (sibling == cpu || !per_cpu_cacheinfo(sibling))
416411
continue;/* skip if itself or no cacheinfo */
417412

418413
for (sib_index = 0; sib_index < cache_leaves(sibling); sib_index++) {

drivers/base/class.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ int class_for_each_device(const struct class *class, const struct device *start,
405405
if (!class)
406406
return -EINVAL;
407407
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",
409409
__func__, class->name);
410410
return -EINVAL;
411411
}
@@ -453,7 +453,7 @@ struct device *class_find_device(const struct class *class, const struct device
453453
if (!class)
454454
return NULL;
455455
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",
457457
__func__, class->name);
458458
return NULL;
459459
}

drivers/base/core.c

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ void device_link_wait_removal(void)
552552
}
553553
EXPORT_SYMBOL_GPL(device_link_wait_removal);
554554

555-
static struct class devlink_class = {
555+
static const struct class devlink_class = {
556556
.name = "devlink",
557557
.dev_groups = devlink_groups,
558558
.dev_release = devlink_dev_release,
@@ -1971,7 +1971,7 @@ static struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwn
19711971

19721972
/**
19731973
* __fw_devlink_relax_cycles - Relax and mark dependency cycles.
1974-
* @con: Potential consumer device.
1974+
* @con_handle: Potential consumer device fwnode.
19751975
* @sup_handle: Potential supplier's fwnode.
19761976
*
19771977
* Needs to be called with fwnode_lock and device link lock held.
@@ -1989,10 +1989,10 @@ static struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwn
19891989
*
19901990
* Return true if one or more cycles were found. Otherwise, return false.
19911991
*/
1992-
static bool __fw_devlink_relax_cycles(struct device *con,
1992+
static bool __fw_devlink_relax_cycles(struct fwnode_handle *con_handle,
19931993
struct fwnode_handle *sup_handle)
19941994
{
1995-
struct device *sup_dev = NULL, *par_dev = NULL;
1995+
struct device *sup_dev = NULL, *par_dev = NULL, *con_dev = NULL;
19961996
struct fwnode_link *link;
19971997
struct device_link *dev_link;
19981998
bool ret = false;
@@ -2009,22 +2009,22 @@ static bool __fw_devlink_relax_cycles(struct device *con,
20092009

20102010
sup_handle->flags |= FWNODE_FLAG_VISITED;
20112011

2012-
sup_dev = get_dev_from_fwnode(sup_handle);
2013-
20142012
/* Termination condition. */
2015-
if (sup_dev == con) {
2013+
if (sup_handle == con_handle) {
20162014
pr_debug("----- cycle: start -----\n");
20172015
ret = true;
20182016
goto out;
20192017
}
20202018

2019+
sup_dev = get_dev_from_fwnode(sup_handle);
2020+
con_dev = get_dev_from_fwnode(con_handle);
20212021
/*
20222022
* If sup_dev is bound to a driver and @con hasn't started binding to a
20232023
* driver, sup_dev can't be a consumer of @con. So, no need to check
20242024
* further.
20252025
*/
20262026
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) {
20282028
ret = false;
20292029
goto out;
20302030
}
@@ -2033,7 +2033,7 @@ static bool __fw_devlink_relax_cycles(struct device *con,
20332033
if (link->flags & FWLINK_FLAG_IGNORE)
20342034
continue;
20352035

2036-
if (__fw_devlink_relax_cycles(con, link->supplier)) {
2036+
if (__fw_devlink_relax_cycles(con_handle, link->supplier)) {
20372037
__fwnode_link_cycle(link);
20382038
ret = true;
20392039
}
@@ -2048,7 +2048,7 @@ static bool __fw_devlink_relax_cycles(struct device *con,
20482048
else
20492049
par_dev = fwnode_get_next_parent_dev(sup_handle);
20502050

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)) {
20522052
pr_debug("%pfwf: cycle: child of %pfwf\n", sup_handle,
20532053
par_dev->fwnode);
20542054
ret = true;
@@ -2066,7 +2066,7 @@ static bool __fw_devlink_relax_cycles(struct device *con,
20662066
!(dev_link->flags & DL_FLAG_CYCLE))
20672067
continue;
20682068

2069-
if (__fw_devlink_relax_cycles(con,
2069+
if (__fw_devlink_relax_cycles(con_handle,
20702070
dev_link->supplier->fwnode)) {
20712071
pr_debug("%pfwf: cycle: depends on %pfwf\n", sup_handle,
20722072
dev_link->supplier->fwnode);
@@ -2114,11 +2114,6 @@ static int fw_devlink_create_devlink(struct device *con,
21142114
if (link->flags & FWLINK_FLAG_IGNORE)
21152115
return 0;
21162116

2117-
if (con->fwnode == link->consumer)
2118-
flags = fw_devlink_get_flags(link->flags);
2119-
else
2120-
flags = FW_DEVLINK_FLAGS_PERMISSIVE;
2121-
21222117
/*
21232118
* In some cases, a device P might also be a supplier to its child node
21242119
* C. However, this would defer the probe of C until the probe of P
@@ -2139,25 +2134,23 @@ static int fw_devlink_create_devlink(struct device *con,
21392134
return -EINVAL;
21402135

21412136
/*
2142-
* SYNC_STATE_ONLY device links don't block probing and supports cycles.
2143-
* So, one might expect that cycle detection isn't necessary for them.
2144-
* However, if the device link was marked as SYNC_STATE_ONLY because
2145-
* it's part of a cycle, then we still need to do cycle detection. This
2146-
* is because the consumer and supplier might be part of multiple cycles
2147-
* and we need to detect all those cycles.
2137+
* Don't try to optimize by not calling the cycle detection logic under
2138+
* certain conditions. There's always some corner case that won't get
2139+
* detected.
21482140
*/
2149-
if (!device_link_flag_is_sync_state_only(flags) ||
2150-
flags & DL_FLAG_CYCLE) {
2151-
device_links_write_lock();
2152-
if (__fw_devlink_relax_cycles(con, sup_handle)) {
2153-
__fwnode_link_cycle(link);
2154-
flags = fw_devlink_get_flags(link->flags);
2155-
pr_debug("----- cycle: end -----\n");
2156-
dev_info(con, "Fixed dependency cycle(s) with %pfwf\n",
2157-
sup_handle);
2158-
}
2159-
device_links_write_unlock();
2141+
device_links_write_lock();
2142+
if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) {
2143+
__fwnode_link_cycle(link);
2144+
pr_debug("----- cycle: end -----\n");
2145+
pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
2146+
link->consumer, sup_handle);
21602147
}
2148+
device_links_write_unlock();
2149+
2150+
if (con->fwnode == link->consumer)
2151+
flags = fw_devlink_get_flags(link->flags);
2152+
else
2153+
flags = FW_DEVLINK_FLAGS_PERMISSIVE;
21612154

21622155
if (sup_handle->flags & FWNODE_FLAG_NOT_DEVICE)
21632156
sup_dev = fwnode_get_next_parent_dev(sup_handle);
@@ -2180,8 +2173,8 @@ static int fw_devlink_create_devlink(struct device *con,
21802173
}
21812174

21822175
if (con != sup_dev && !device_link_add(con, sup_dev, flags)) {
2183-
dev_err(con, "Failed to create device link (0x%x) with %s\n",
2184-
flags, dev_name(sup_dev));
2176+
dev_err(con, "Failed to create device link (0x%x) with supplier %s for %pfwf\n",
2177+
flags, dev_name(sup_dev), link->consumer);
21852178
ret = -EINVAL;
21862179
}
21872180

drivers/base/firmware_loader/main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,19 +829,18 @@ static void fw_log_firmware_info(const struct firmware *fw, const char *name, st
829829
shash->tfm = alg;
830830

831831
if (crypto_shash_digest(shash, fw->data, fw->size, sha256buf) < 0)
832-
goto out_shash;
832+
goto out_free;
833833

834834
for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
835835
sprintf(&outbuf[i * 2], "%02x", sha256buf[i]);
836836
outbuf[SHA256_BLOCK_SIZE] = 0;
837837
dev_dbg(device, "Loaded FW: %s, sha256: %s\n", name, outbuf);
838838

839-
out_shash:
840-
crypto_free_shash(alg);
841839
out_free:
842840
kfree(shash);
843841
kfree(outbuf);
844842
kfree(sha256buf);
843+
crypto_free_shash(alg);
845844
}
846845
#else
847846
static void fw_log_firmware_info(const struct firmware *fw, const char *name,
@@ -1075,8 +1074,8 @@ EXPORT_SYMBOL_GPL(firmware_request_platform);
10751074

10761075
/**
10771076
* firmware_request_cache() - cache firmware for suspend so resume can use it
1078-
* @name: name of firmware file
10791077
* @device: device for which firmware should be cached for
1078+
* @name: name of firmware file
10801079
*
10811080
* There are some devices with an optimization that enables the device to not
10821081
* require loading firmware on system reboot. This optimization may still

drivers/base/node.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static const struct bus_type node_subsys = {
2727
};
2828

2929
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,
3131
loff_t off, size_t count)
3232
{
3333
struct device *dev = kobj_to_dev(kobj);
@@ -45,10 +45,10 @@ static inline ssize_t cpumap_read(struct file *file, struct kobject *kobj,
4545
return n;
4646
}
4747

48-
static BIN_ATTR_RO(cpumap, CPUMAP_FILE_MAX_BYTES);
48+
static const BIN_ATTR_RO(cpumap, CPUMAP_FILE_MAX_BYTES);
4949

5050
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,
5252
loff_t off, size_t count)
5353
{
5454
struct device *dev = kobj_to_dev(kobj);
@@ -66,7 +66,7 @@ static inline ssize_t cpulist_read(struct file *file, struct kobject *kobj,
6666
return n;
6767
}
6868

69-
static BIN_ATTR_RO(cpulist, CPULIST_FILE_MAX_BYTES);
69+
static const BIN_ATTR_RO(cpulist, CPULIST_FILE_MAX_BYTES);
7070

7171
/**
7272
* struct node_access_nodes - Access class device to hold user visible
@@ -578,15 +578,15 @@ static struct attribute *node_dev_attrs[] = {
578578
NULL
579579
};
580580

581-
static struct bin_attribute *node_dev_bin_attrs[] = {
581+
static const struct bin_attribute *node_dev_bin_attrs[] = {
582582
&bin_attr_cpumap,
583583
&bin_attr_cpulist,
584584
NULL
585585
};
586586

587587
static const struct attribute_group node_dev_group = {
588588
.attrs = node_dev_attrs,
589-
.bin_attrs = node_dev_bin_attrs
589+
.bin_attrs_new = node_dev_bin_attrs,
590590
};
591591

592592
static const struct attribute_group *node_dev_groups[] = {

drivers/base/power/sysfs.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,6 @@ static ssize_t wakeup_last_time_ms_show(struct device *dev,
509509
return sysfs_emit(buf, "%lld\n", msec);
510510
}
511511

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-
520512
static DEVICE_ATTR_RO(wakeup_last_time_ms);
521513

522514
#ifdef CONFIG_PM_AUTOSLEEP
@@ -541,6 +533,15 @@ static ssize_t wakeup_prevent_sleep_time_ms_show(struct device *dev,
541533

542534
static DEVICE_ATTR_RO(wakeup_prevent_sleep_time_ms);
543535
#endif /* CONFIG_PM_AUTOSLEEP */
536+
537+
static inline int dpm_sysfs_wakeup_change_owner(struct device *dev, kuid_t kuid,
538+
kgid_t kgid)
539+
{
540+
if (dev->power.wakeup && dev->power.wakeup->dev)
541+
return device_change_owner(dev->power.wakeup->dev, kuid, kgid);
542+
return 0;
543+
}
544+
544545
#else /* CONFIG_PM_SLEEP */
545546
static inline int dpm_sysfs_wakeup_change_owner(struct device *dev, kuid_t kuid,
546547
kgid_t kgid)

0 commit comments

Comments
 (0)