Skip to content

Commit 9d230d5

Browse files
committed
Merge tag 'driver-core-6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core
Pull driver core updates from Greg KH: "Here are the driver core / kernfs changes for 6.16-rc1. Not a huge number of changes this development cycle, here's the summary of what is included in here: - kernfs locking tweaks, pushing some global locks down into a per-fs image lock - rust driver core and pci device bindings added for new features. - sysfs const work for bin_attributes. The final churn of switching away from and removing the transitional struct members, "read_new", "write_new" and "bin_attrs_new" will come after the merge window to avoid unnecesary merge conflicts. - auxbus device creation helpers added - fauxbus fix for creating sysfs files after the probe completed properly - other tiny updates for driver core things. All of these have been in linux-next for over a week with no reported issues" * tag 'driver-core-6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core: kernfs: Relax constraint in draining guard Documentation: embargoed-hardware-issues.rst: Remove myself drivers: hv: fix up const issue with vmbus_chan_bin_attrs firmware_loader: use SHA-256 library API instead of crypto_shash API docs: debugfs: do not recommend debugfs_remove_recursive PM: wakeup: Do not expose 4 device wakeup source APIs kernfs: switch global kernfs_rename_lock to per-fs lock kernfs: switch global kernfs_idr_lock to per-fs lock driver core: auxiliary bus: Fix IS_ERR() vs NULL mixup in __devm_auxiliary_device_create() sysfs: constify attribute_group::bin_attrs sysfs: constify bin_attribute argument of bin_attribute::read/write() software node: Correct a OOB check in software_node_get_reference_args() devres: simplify devm_kstrdup() using devm_kmemdup() platform: replace magic number with macro PLATFORM_DEVID_NONE component: do not try to unbind unbound components driver core: auxiliary bus: add device creation helpers driver core: faux: Add sysfs groups after probing
2 parents bf373e4 + 071d8e4 commit 9d230d5

File tree

20 files changed

+205
-132
lines changed

20 files changed

+205
-132
lines changed

Documentation/filesystems/debugfs.rst

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,15 @@ module is unloaded without explicitly removing debugfs entries, the result
229229
will be a lot of stale pointers and no end of highly antisocial behavior.
230230
So all debugfs users - at least those which can be built as modules - must
231231
be prepared to remove all files and directories they create there. A file
232-
can be removed with::
232+
or directory can be removed with::
233233

234234
void debugfs_remove(struct dentry *dentry);
235235

236236
The dentry value can be NULL or an error value, in which case nothing will
237-
be removed.
238-
239-
Once upon a time, debugfs users were required to remember the dentry
240-
pointer for every debugfs file they created so that all files could be
241-
cleaned up. We live in more civilized times now, though, and debugfs users
242-
can call::
243-
244-
void debugfs_remove_recursive(struct dentry *dentry);
245-
246-
If this function is passed a pointer for the dentry corresponding to the
247-
top-level directory, the entire hierarchy below that directory will be
248-
removed.
237+
be removed. Note that this function will recursively remove all files and
238+
directories underneath it. Previously, debugfs_remove_recursive() was used
239+
to perform that task, but this function is now just an alias to
240+
debugfs_remove(). debugfs_remove_recursive() should be considered
241+
deprecated.
249242

250243
.. [1] http://lwn.net/Articles/309298/

Documentation/process/debugging/driver_development_debugging_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ The general idea is:
155155
``my_variable``
156156

157157
- Clean up the directory when removing the device
158-
(``debugfs_remove_recursive(parent);``)
158+
(``debugfs_remove(parent);``)
159159

160160
For the full documentation see :doc:`/filesystems/debugfs`.
161161

Documentation/process/embargoed-hardware-issues.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ an involved disclosed party. The current ambassadors list:
290290
AMD Tom Lendacky <thomas.lendacky@amd.com>
291291
Ampere Darren Hart <darren@os.amperecomputing.com>
292292
ARM Catalin Marinas <catalin.marinas@arm.com>
293-
IBM Power Michael Ellerman <ellerman@au.ibm.com>
294293
IBM Z Christian Borntraeger <borntraeger@de.ibm.com>
295294
Intel Tony Luck <tony.luck@intel.com>
296295
Qualcomm Trilok Soni <quic_tsoni@quicinc.com>

drivers/base/auxiliary.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,114 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
395395
}
396396
EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
397397

398+
static void auxiliary_device_release(struct device *dev)
399+
{
400+
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
401+
402+
kfree(auxdev);
403+
}
404+
405+
/**
406+
* auxiliary_device_create - create a device on the auxiliary bus
407+
* @dev: parent device
408+
* @modname: module name used to create the auxiliary driver name.
409+
* @devname: auxiliary bus device name
410+
* @platform_data: auxiliary bus device platform data
411+
* @id: auxiliary bus device id
412+
*
413+
* Helper to create an auxiliary bus device.
414+
* The device created matches driver 'modname.devname' on the auxiliary bus.
415+
*/
416+
struct auxiliary_device *auxiliary_device_create(struct device *dev,
417+
const char *modname,
418+
const char *devname,
419+
void *platform_data,
420+
int id)
421+
{
422+
struct auxiliary_device *auxdev;
423+
int ret;
424+
425+
auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
426+
if (!auxdev)
427+
return NULL;
428+
429+
auxdev->id = id;
430+
auxdev->name = devname;
431+
auxdev->dev.parent = dev;
432+
auxdev->dev.platform_data = platform_data;
433+
auxdev->dev.release = auxiliary_device_release;
434+
device_set_of_node_from_dev(&auxdev->dev, dev);
435+
436+
ret = auxiliary_device_init(auxdev);
437+
if (ret) {
438+
kfree(auxdev);
439+
return NULL;
440+
}
441+
442+
ret = __auxiliary_device_add(auxdev, modname);
443+
if (ret) {
444+
/*
445+
* It may look odd but auxdev should not be freed here.
446+
* auxiliary_device_uninit() calls device_put() which call
447+
* the device release function, freeing auxdev.
448+
*/
449+
auxiliary_device_uninit(auxdev);
450+
return NULL;
451+
}
452+
453+
return auxdev;
454+
}
455+
EXPORT_SYMBOL_GPL(auxiliary_device_create);
456+
457+
/**
458+
* auxiliary_device_destroy - remove an auxiliary device
459+
* @auxdev: pointer to the auxdev to be removed
460+
*
461+
* Helper to remove an auxiliary device created with
462+
* auxiliary_device_create()
463+
*/
464+
void auxiliary_device_destroy(void *auxdev)
465+
{
466+
struct auxiliary_device *_auxdev = auxdev;
467+
468+
auxiliary_device_delete(_auxdev);
469+
auxiliary_device_uninit(_auxdev);
470+
}
471+
EXPORT_SYMBOL_GPL(auxiliary_device_destroy);
472+
473+
/**
474+
* __devm_auxiliary_device_create - create a managed device on the auxiliary bus
475+
* @dev: parent device
476+
* @modname: module name used to create the auxiliary driver name.
477+
* @devname: auxiliary bus device name
478+
* @platform_data: auxiliary bus device platform data
479+
* @id: auxiliary bus device id
480+
*
481+
* Device managed helper to create an auxiliary bus device.
482+
* The device created matches driver 'modname.devname' on the auxiliary bus.
483+
*/
484+
struct auxiliary_device *__devm_auxiliary_device_create(struct device *dev,
485+
const char *modname,
486+
const char *devname,
487+
void *platform_data,
488+
int id)
489+
{
490+
struct auxiliary_device *auxdev;
491+
int ret;
492+
493+
auxdev = auxiliary_device_create(dev, modname, devname, platform_data, id);
494+
if (!auxdev)
495+
return NULL;
496+
497+
ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
498+
auxdev);
499+
if (ret)
500+
return NULL;
501+
502+
return auxdev;
503+
}
504+
EXPORT_SYMBOL_GPL(__devm_auxiliary_device_create);
505+
398506
void __init auxiliary_bus_init(void)
399507
{
400508
WARN_ON(bus_register(&auxiliary_bus_type));

drivers/base/component.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ EXPORT_SYMBOL_GPL(component_master_is_bound);
586586
static void component_unbind(struct component *component,
587587
struct aggregate_device *adev, void *data)
588588
{
589-
WARN_ON(!component->bound);
589+
if (WARN_ON(!component->bound))
590+
return;
590591

591592
dev_dbg(adev->parent, "unbinding %s component %p (ops %ps)\n",
592593
dev_name(component->dev), component, component->ops);

drivers/base/devres.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -987,17 +987,10 @@ EXPORT_SYMBOL_GPL(devm_krealloc);
987987
*/
988988
char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp)
989989
{
990-
size_t size;
991-
char *buf;
992-
993990
if (!s)
994991
return NULL;
995992

996-
size = strlen(s) + 1;
997-
buf = devm_kmalloc(dev, size, gfp);
998-
if (buf)
999-
memcpy(buf, s, size);
1000-
return buf;
993+
return devm_kmemdup(dev, s, strlen(s) + 1, gfp);
1001994
}
1002995
EXPORT_SYMBOL_GPL(devm_kstrdup);
1003996

drivers/base/faux.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
struct faux_object {
2626
struct faux_device faux_dev;
2727
const struct faux_device_ops *faux_ops;
28+
const struct attribute_group **groups;
2829
};
2930
#define to_faux_object(dev) container_of_const(dev, struct faux_object, faux_dev.dev)
3031

@@ -43,10 +44,21 @@ static int faux_probe(struct device *dev)
4344
struct faux_object *faux_obj = to_faux_object(dev);
4445
struct faux_device *faux_dev = &faux_obj->faux_dev;
4546
const struct faux_device_ops *faux_ops = faux_obj->faux_ops;
46-
int ret = 0;
47+
int ret;
4748

48-
if (faux_ops && faux_ops->probe)
49+
if (faux_ops && faux_ops->probe) {
4950
ret = faux_ops->probe(faux_dev);
51+
if (ret)
52+
return ret;
53+
}
54+
55+
/*
56+
* Add groups after the probe succeeds to ensure resources are
57+
* initialized correctly
58+
*/
59+
ret = device_add_groups(dev, faux_obj->groups);
60+
if (ret && faux_ops && faux_ops->remove)
61+
faux_ops->remove(faux_dev);
5062

5163
return ret;
5264
}
@@ -57,6 +69,8 @@ static void faux_remove(struct device *dev)
5769
struct faux_device *faux_dev = &faux_obj->faux_dev;
5870
const struct faux_device_ops *faux_ops = faux_obj->faux_ops;
5971

72+
device_remove_groups(dev, faux_obj->groups);
73+
6074
if (faux_ops && faux_ops->remove)
6175
faux_ops->remove(faux_dev);
6276
}
@@ -124,8 +138,9 @@ struct faux_device *faux_device_create_with_groups(const char *name,
124138
if (!faux_obj)
125139
return NULL;
126140

127-
/* Save off the callbacks so we can use them in the future */
141+
/* Save off the callbacks and groups so we can use them in the future */
128142
faux_obj->faux_ops = faux_ops;
143+
faux_obj->groups = groups;
129144

130145
/* Initialize the device portion and register it with the driver core */
131146
faux_dev = &faux_obj->faux_dev;
@@ -138,7 +153,6 @@ struct faux_device *faux_device_create_with_groups(const char *name,
138153
else
139154
dev->parent = &faux_bus_root;
140155
dev->bus = &faux_bus_type;
141-
dev->groups = groups;
142156
dev_set_name(dev, "%s", name);
143157

144158
ret = device_add(dev);

drivers/base/firmware_loader/Kconfig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ menu "Firmware loader"
33

44
config FW_LOADER
55
tristate "Firmware loading facility" if EXPERT
6-
select CRYPTO_HASH if FW_LOADER_DEBUG
7-
select CRYPTO_SHA256 if FW_LOADER_DEBUG
6+
select CRYPTO_LIB_SHA256 if FW_LOADER_DEBUG
87
default y
98
help
109
This enables the firmware loading facility in the kernel. The kernel
@@ -28,7 +27,6 @@ config FW_LOADER
2827

2928
config FW_LOADER_DEBUG
3029
bool "Log filenames and checksums for loaded firmware"
31-
depends on CRYPTO = FW_LOADER || CRYPTO=y
3230
depends on DYNAMIC_DEBUG
3331
depends on FW_LOADER
3432
default FW_LOADER

drivers/base/firmware_loader/main.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -806,41 +806,15 @@ static void fw_abort_batch_reqs(struct firmware *fw)
806806
}
807807

808808
#if defined(CONFIG_FW_LOADER_DEBUG)
809-
#include <crypto/hash.h>
810809
#include <crypto/sha2.h>
811810

812811
static void fw_log_firmware_info(const struct firmware *fw, const char *name, struct device *device)
813812
{
814-
struct shash_desc *shash;
815-
struct crypto_shash *alg;
816-
u8 *sha256buf;
817-
char *outbuf;
813+
u8 digest[SHA256_DIGEST_SIZE];
818814

819-
alg = crypto_alloc_shash("sha256", 0, 0);
820-
if (IS_ERR(alg))
821-
return;
822-
823-
sha256buf = kmalloc(SHA256_DIGEST_SIZE, GFP_KERNEL);
824-
outbuf = kmalloc(SHA256_BLOCK_SIZE + 1, GFP_KERNEL);
825-
shash = kmalloc(sizeof(*shash) + crypto_shash_descsize(alg), GFP_KERNEL);
826-
if (!sha256buf || !outbuf || !shash)
827-
goto out_free;
828-
829-
shash->tfm = alg;
830-
831-
if (crypto_shash_digest(shash, fw->data, fw->size, sha256buf) < 0)
832-
goto out_free;
833-
834-
for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
835-
sprintf(&outbuf[i * 2], "%02x", sha256buf[i]);
836-
outbuf[SHA256_BLOCK_SIZE] = 0;
837-
dev_dbg(device, "Loaded FW: %s, sha256: %s\n", name, outbuf);
838-
839-
out_free:
840-
kfree(shash);
841-
kfree(outbuf);
842-
kfree(sha256buf);
843-
crypto_free_shash(alg);
815+
sha256(fw->data, fw->size, digest);
816+
dev_dbg(device, "Loaded FW: %s, sha256: %*phN\n",
817+
name, SHA256_DIGEST_SIZE, digest);
844818
}
845819
#else
846820
static void fw_log_firmware_info(const struct firmware *fw, const char *name,

drivers/base/platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ struct platform_device * __init_or_module __platform_create_bundle(
982982
struct platform_device *pdev;
983983
int error;
984984

985-
pdev = platform_device_alloc(driver->driver.name, -1);
985+
pdev = platform_device_alloc(driver->driver.name, PLATFORM_DEVID_NONE);
986986
if (!pdev) {
987987
error = -ENOMEM;
988988
goto err_out;

0 commit comments

Comments
 (0)