Skip to content

Commit e5f0e38

Browse files
committed
Merge tag 'driver-core-6.12-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 patches for the driver core code for 6.12-rc1. This set is the one that caused the most delay on my side, due to lots of last-minute reports of problems in the async shutdown feature that was added. In the end, I've reverted all of the patches in that series so we are back to "normal" and the patch set is being reworked for the next merge window. Other than the async shutdown patches that were reverted, included in here are: - minor driver core cleanups - minor driver core bus and class api cleanups and simplifications for some callbacks - some const markings of structures - other even more minor cleanups All of these, including the last minute reverts, have been in linux-next, but all of the reports of problems in linux-next were before the reverts happened. After the reverts, all is good" * tag 'driver-core-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits) Revert "driver core: don't always lock parent in shutdown" Revert "driver core: separate function to shutdown one device" Revert "driver core: shut down devices asynchronously" Revert "nvme-pci: Make driver prefer asynchronous shutdown" Revert "driver core: fix async device shutdown hang" driver core: fix async device shutdown hang driver core: attribute_container: Remove unused functions driver core: Trivially simplify ((struct device_private *)curr)->device->p to @Curr devres: Correclty strip percpu address space of devm_free_percpu() argument driver core: Make parameter check consistent for API cluster device_(for_each|find)_child() bus: fsl-mc: make fsl_mc_bus_type const nvme-pci: Make driver prefer asynchronous shutdown driver core: shut down devices asynchronously driver core: separate function to shutdown one device driver core: don't always lock parent in shutdown platform: Make platform_bus_type constant driver core: class: Check namespace relevant parameters in class_register() driver:base:core: Adding a "Return:" line in comment for device_link_add() drivers/base: Introduce device_match_t for device finding APIs firmware_loader: Block path traversal ...
2 parents cb787f4 + eb46cb3 commit e5f0e38

File tree

20 files changed

+165
-164
lines changed

20 files changed

+165
-164
lines changed

drivers/base/attribute_container.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ attribute_container_device_trigger_safe(struct device *dev,
346346
* @fn: the function to execute for each classdev.
347347
*
348348
* This function is for executing a trigger when you need to know both
349-
* the container and the classdev. If you only care about the
350-
* container, then use attribute_container_trigger() instead.
349+
* the container and the classdev.
351350
*/
352351
void
353352
attribute_container_device_trigger(struct device *dev,
@@ -378,33 +377,6 @@ attribute_container_device_trigger(struct device *dev,
378377
mutex_unlock(&attribute_container_mutex);
379378
}
380379

381-
/**
382-
* attribute_container_trigger - trigger a function for each matching container
383-
*
384-
* @dev: The generic device to activate the trigger for
385-
* @fn: the function to trigger
386-
*
387-
* This routine triggers a function that only needs to know the
388-
* matching containers (not the classdev) associated with a device.
389-
* It is more lightweight than attribute_container_device_trigger, so
390-
* should be used in preference unless the triggering function
391-
* actually needs to know the classdev.
392-
*/
393-
void
394-
attribute_container_trigger(struct device *dev,
395-
int (*fn)(struct attribute_container *,
396-
struct device *))
397-
{
398-
struct attribute_container *cont;
399-
400-
mutex_lock(&attribute_container_mutex);
401-
list_for_each_entry(cont, &attribute_container_list, node) {
402-
if (cont->match(cont, dev))
403-
fn(cont, dev);
404-
}
405-
mutex_unlock(&attribute_container_mutex);
406-
}
407-
408380
/**
409381
* attribute_container_add_attrs - add attributes
410382
*
@@ -458,24 +430,6 @@ attribute_container_add_class_device(struct device *classdev)
458430
return attribute_container_add_attrs(classdev);
459431
}
460432

461-
/**
462-
* attribute_container_add_class_device_adapter - simple adapter for triggers
463-
*
464-
* @cont: the container to register.
465-
* @dev: the generic device to activate the trigger for
466-
* @classdev: the class device to add
467-
*
468-
* This function is identical to attribute_container_add_class_device except
469-
* that it is designed to be called from the triggers
470-
*/
471-
int
472-
attribute_container_add_class_device_adapter(struct attribute_container *cont,
473-
struct device *dev,
474-
struct device *classdev)
475-
{
476-
return attribute_container_add_class_device(classdev);
477-
}
478-
479433
/**
480434
* attribute_container_remove_attrs - remove any attribute files
481435
*

drivers/base/auxiliary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(__auxiliary_device_add);
352352
*/
353353
struct auxiliary_device *auxiliary_find_device(struct device *start,
354354
const void *data,
355-
int (*match)(struct device *dev, const void *data))
355+
device_match_t match)
356356
{
357357
struct device *dev;
358358

drivers/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void auxiliary_bus_init(void);
145145
static inline void auxiliary_bus_init(void) { }
146146
#endif
147147

148-
struct kobject *virtual_device_parent(struct device *dev);
148+
struct kobject *virtual_device_parent(void);
149149

150150
int bus_add_device(struct device *dev);
151151
void bus_probe_device(struct device *dev);

drivers/base/bus.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr,
152152
{
153153
struct bus_attribute *bus_attr = to_bus_attr(attr);
154154
struct subsys_private *subsys_priv = to_subsys_private(kobj);
155-
ssize_t ret = 0;
155+
/* return -EIO for reading a bus attribute without show() */
156+
ssize_t ret = -EIO;
156157

157158
if (bus_attr->show)
158159
ret = bus_attr->show(subsys_priv->bus, buf);
@@ -164,7 +165,8 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
164165
{
165166
struct bus_attribute *bus_attr = to_bus_attr(attr);
166167
struct subsys_private *subsys_priv = to_subsys_private(kobj);
167-
ssize_t ret = 0;
168+
/* return -EIO for writing a bus attribute without store() */
169+
ssize_t ret = -EIO;
168170

169171
if (bus_attr->store)
170172
ret = bus_attr->store(subsys_priv->bus, buf, count);
@@ -389,7 +391,7 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev);
389391
*/
390392
struct device *bus_find_device(const struct bus_type *bus,
391393
struct device *start, const void *data,
392-
int (*match)(struct device *dev, const void *data))
394+
device_match_t match)
393395
{
394396
struct subsys_private *sp = bus_to_subsys(bus);
395397
struct klist_iter i;
@@ -920,6 +922,8 @@ int bus_register(const struct bus_type *bus)
920922
bus_remove_file(bus, &bus_attr_uevent);
921923
bus_uevent_fail:
922924
kset_unregister(&priv->subsys);
925+
/* Above kset_unregister() will kfree @priv */
926+
priv = NULL;
923927
out:
924928
kfree(priv);
925929
return retval;
@@ -1294,7 +1298,7 @@ int subsys_virtual_register(const struct bus_type *subsys,
12941298
{
12951299
struct kobject *virtual_dir;
12961300

1297-
virtual_dir = virtual_device_parent(NULL);
1301+
virtual_dir = virtual_device_parent();
12981302
if (!virtual_dir)
12991303
return -ENOMEM;
13001304

@@ -1385,8 +1389,13 @@ int __init buses_init(void)
13851389
return -ENOMEM;
13861390

13871391
system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj);
1388-
if (!system_kset)
1392+
if (!system_kset) {
1393+
/* Do error handling here as devices_init() do */
1394+
kset_unregister(bus_kset);
1395+
bus_kset = NULL;
1396+
pr_err("%s: failed to create and add kset 'bus'\n", __func__);
13891397
return -ENOMEM;
1398+
}
13901399

13911400
return 0;
13921401
}

drivers/base/class.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ int class_register(const struct class *cls)
183183

184184
pr_debug("device class '%s': registering\n", cls->name);
185185

186+
if (cls->ns_type && !cls->namespace) {
187+
pr_err("%s: class '%s' does not have namespace\n",
188+
__func__, cls->name);
189+
return -EINVAL;
190+
}
191+
if (!cls->ns_type && cls->namespace) {
192+
pr_err("%s: class '%s' does not have ns_type\n",
193+
__func__, cls->name);
194+
return -EINVAL;
195+
}
196+
186197
cp = kzalloc(sizeof(*cp), GFP_KERNEL);
187198
if (!cp)
188199
return -ENOMEM;
@@ -433,8 +444,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
433444
* code. There's no locking restriction.
434445
*/
435446
struct device *class_find_device(const struct class *class, const struct device *start,
436-
const void *data,
437-
int (*match)(struct device *, const void *))
447+
const void *data, device_match_t match)
438448
{
439449
struct subsys_private *sp = class_to_subsys(class);
440450
struct class_dev_iter iter;

0 commit comments

Comments
 (0)