Skip to content

Commit 71a7507

Browse files
committed
Merge tag 'driver-core-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH: "Here is the set of driver core and kernfs changes for 6.2-rc1. The "big" change in here is the addition of a new macro, container_of_const() that will preserve the "const-ness" of a pointer passed into it. The "problem" of the current container_of() macro is that if you pass in a "const *", out of it can comes a non-const pointer unless you specifically ask for it. For many usages, we want to preserve the "const" attribute by using the same call. For a specific example, this series changes the kobj_to_dev() macro to use it, allowing it to be used no matter what the const value is. This prevents every subsystem from having to declare 2 different individual macros (i.e. kobj_const_to_dev() and kobj_to_dev()) and having the compiler enforce the const value at build time, which having 2 macros would not do either. The driver for all of this have been discussions with the Rust kernel developers as to how to properly mark driver core, and kobject, objects as being "non-mutable". The changes to the kobject and driver core in this pull request are the result of that, as there are lots of paths where kobjects and device pointers are not modified at all, so marking them as "const" allows the compiler to enforce this. So, a nice side affect of the Rust development effort has been already to clean up the driver core code to be more obvious about object rules. All of this has been bike-shedded in quite a lot of detail on lkml with different names and implementations resulting in the tiny version we have in here, much better than my original proposal. Lots of subsystem maintainers have acked the changes as well. Other than this change, included in here are smaller stuff like: - kernfs fixes and updates to handle lock contention better - vmlinux.lds.h fixes and updates - sysfs and debugfs documentation updates - device property updates All of these have been in the linux-next tree for quite a while with no problems" * tag 'driver-core-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (58 commits) device property: Fix documentation for fwnode_get_next_parent() firmware_loader: fix up to_fw_sysfs() to preserve const usb.h: take advantage of container_of_const() device.h: move kobj_to_dev() to use container_of_const() container_of: add container_of_const() that preserves const-ness of the pointer driver core: fix up missed drivers/s390/char/hmcdrv_dev.c class.devnode() conversion. driver core: fix up missed scsi/cxlflash class.devnode() conversion. driver core: fix up some missing class.devnode() conversions. driver core: make struct class.devnode() take a const * driver core: make struct class.dev_uevent() take a const * cacheinfo: Remove of_node_put() for fw_token device property: Add a blank line in Kconfig of tests device property: Rename goto label to be more precise device property: Move PROPERTY_ENTRY_BOOL() a bit down device property: Get rid of __PROPERTY_ENTRY_ARRAY_EL*SIZE*() kernfs: fix all kernel-doc warnings and multiple typos driver core: pass a const * into of_device_uevent() kobject: kset_uevent_ops: make name() callback take a const * kobject: kset_uevent_ops: make filter() callback take a const * kobject: make kobject_namespace take a const * ...
2 parents ba54ff1 + f18caf2 commit 71a7507

File tree

92 files changed

+499
-505
lines changed

Some content is hidden

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

92 files changed

+499
-505
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
What: /sys/kernel/cpu_byteorder
2+
Date: February 2023
3+
KernelVersion: 6.2
4+
Contact: Thomas Weißschuh <[email protected]>
5+
Description:
6+
The endianness of the running kernel.
7+
8+
Access: Read
9+
10+
Valid values:
11+
"little", "big"
12+
Users: util-linux

Documentation/driver-api/driver-model/devres.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ MEM
365365
devm_kmemdup()
366366
devm_krealloc()
367367
devm_kstrdup()
368+
devm_kstrdup_const()
368369
devm_kvasprintf()
369370
devm_kzalloc()
370371

arch/powerpc/platforms/book3s/vas-api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct coproc_instance {
5353
struct vas_window *txwin;
5454
};
5555

56-
static char *coproc_devnode(struct device *dev, umode_t *mode)
56+
static char *coproc_devnode(const struct device *dev, umode_t *mode)
5757
{
5858
return kasprintf(GFP_KERNEL, "crypto/%s", dev_name(dev));
5959
}

arch/x86/kernel/cpu/resctrl/pseudo_lock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,9 +1560,9 @@ static const struct file_operations pseudo_lock_dev_fops = {
15601560
.mmap = pseudo_lock_dev_mmap,
15611561
};
15621562

1563-
static char *pseudo_lock_devnode(struct device *dev, umode_t *mode)
1563+
static char *pseudo_lock_devnode(const struct device *dev, umode_t *mode)
15641564
{
1565-
struct rdtgroup *rdtgrp;
1565+
const struct rdtgroup *rdtgrp;
15661566

15671567
rdtgrp = dev_get_drvdata(dev);
15681568
if (mode)

arch/x86/kernel/cpuid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static int cpuid_device_destroy(unsigned int cpu)
139139
return 0;
140140
}
141141

142-
static char *cpuid_devnode(struct device *dev, umode_t *mode)
142+
static char *cpuid_devnode(const struct device *dev, umode_t *mode)
143143
{
144144
return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt));
145145
}

arch/x86/kernel/msr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int msr_device_destroy(unsigned int cpu)
250250
return 0;
251251
}
252252

253-
static char *msr_devnode(struct device *dev, umode_t *mode)
253+
static char *msr_devnode(const struct device *dev, umode_t *mode)
254254
{
255255
return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt));
256256
}

block/bsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q,
235235
}
236236
EXPORT_SYMBOL_GPL(bsg_register_queue);
237237

238-
static char *bsg_devnode(struct device *dev, umode_t *mode)
238+
static char *bsg_devnode(const struct device *dev, umode_t *mode)
239239
{
240240
return kasprintf(GFP_KERNEL, "bsg/%s", dev_name(dev));
241241
}

block/genhd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,9 @@ static void disk_release(struct device *dev)
11891189
iput(disk->part0->bd_inode); /* frees the disk */
11901190
}
11911191

1192-
static int block_uevent(struct device *dev, struct kobj_uevent_env *env)
1192+
static int block_uevent(const struct device *dev, struct kobj_uevent_env *env)
11931193
{
1194-
struct gendisk *disk = dev_to_disk(dev);
1194+
const struct gendisk *disk = dev_to_disk(dev);
11951195

11961196
return add_uevent_var(env, "DISKSEQ=%llu", disk->diskseq);
11971197
}

drivers/base/base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ static inline int driver_match_device(struct device_driver *drv,
146146
{
147147
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
148148
}
149-
extern bool driver_allows_async_probing(struct device_driver *drv);
150149

151150
extern int driver_add_groups(struct device_driver *drv,
152151
const struct attribute_group **groups);

drivers/base/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static struct kobj_type bus_ktype = {
163163
.release = bus_release,
164164
};
165165

166-
static int bus_uevent_filter(struct kobject *kobj)
166+
static int bus_uevent_filter(const struct kobject *kobj)
167167
{
168168
const struct kobj_type *ktype = get_ktype(kobj);
169169

0 commit comments

Comments
 (0)