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

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

Pull driver core updates from Greg KH:
"Here is the big set of driver core changes for 6.11-rc1.

Lots of stuff in here, with not a huge diffstat, but apis are evolving
which required lots of files to be touched. Highlights of the changes
in here are:

- platform remove callback api final fixups (Uwe took many releases
to get here, finally!)

- Rust bindings for basic firmware apis and initial driver-core
interactions.

It's not all that useful for a "write a whole driver in rust" type
of thing, but the firmware bindings do help out the phy rust
drivers, and the driver core bindings give a solid base on which
others can start their work.

There is still a long way to go here before we have a multitude of
rust drivers being added, but it's a great first step.

- driver core const api changes.

This reached across all bus types, and there are some fix-ups for
some not-common bus types that linux-next and 0-day testing shook
out.

This work is being done to help make the rust bindings more safe,
as well as the C code, moving toward the end-goal of allowing us to
put driver structures into read-only memory. We aren't there yet,
but are getting closer.

- minor devres cleanups and fixes found by code inspection

- arch_topology minor changes

- other minor driver core cleanups

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

* tag 'driver-core-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (55 commits)
ARM: sa1100: make match function take a const pointer
sysfs/cpu: Make crash_hotplug attribute world-readable
dio: Have dio_bus_match() callback take a const *
zorro: make match function take a const pointer
driver core: module: make module_[add|remove]_driver take a const *
driver core: make driver_find_device() take a const *
driver core: make driver_[create|remove]_file take a const *
firmware_loader: fix soundness issue in `request_internal`
firmware_loader: annotate doctests as `no_run`
devres: Correct code style for functions that return a pointer type
devres: Initialize an uninitialized struct member
devres: Fix memory leakage caused by driver API devm_free_percpu()
devres: Fix devm_krealloc() wasting memory
driver core: platform: Switch to use kmemdup_array()
driver core: have match() callback in struct bus_type take a const *
MAINTAINERS: add Rust device abstractions to DRIVER CORE
device: rust: improve safety comments
MAINTAINERS: add Danilo as FIRMWARE LOADER maintainer
MAINTAINERS: add Rust FW abstractions to FIRMWARE LOADER
firmware: rust: improve safety comments
...

+777 -623
+3
MAINTAINERS
··· 6850 6850 F: include/linux/kobj* 6851 6851 F: include/linux/property.h 6852 6852 F: lib/kobj* 6853 + F: rust/kernel/device.rs 6853 6854 6854 6855 DRIVERS FOR OMAP ADAPTIVE VOLTAGE SCALING (AVS) 6855 6856 M: Nishanth Menon <nm@ti.com> ··· 8717 8716 FIRMWARE LOADER (request_firmware) 8718 8717 M: Luis Chamberlain <mcgrof@kernel.org> 8719 8718 M: Russ Weight <russ.weight@linux.dev> 8719 + M: Danilo Krummrich <dakr@redhat.com> 8720 8720 L: linux-kernel@vger.kernel.org 8721 8721 S: Maintained 8722 8722 F: Documentation/firmware_class/ 8723 8723 F: drivers/base/firmware_loader/ 8724 + F: rust/kernel/firmware.rs 8724 8725 F: include/linux/firmware.h 8725 8726 8726 8727 FLEXTIMER FTM-QUADDEC DRIVER
+2 -2
arch/arm/common/locomo.c
··· 816 816 * We model this as a regular bus type, and hang devices directly 817 817 * off this. 818 818 */ 819 - static int locomo_match(struct device *_dev, struct device_driver *_drv) 819 + static int locomo_match(struct device *_dev, const struct device_driver *_drv) 820 820 { 821 821 struct locomo_dev *dev = LOCOMO_DEV(_dev); 822 - struct locomo_driver *drv = LOCOMO_DRV(_drv); 822 + const struct locomo_driver *drv = LOCOMO_DRV(_drv); 823 823 824 824 return dev->devid == drv->devid; 825 825 }
+2 -2
arch/arm/common/sa1111.c
··· 1339 1339 * We model this as a regular bus type, and hang devices directly 1340 1340 * off this. 1341 1341 */ 1342 - static int sa1111_match(struct device *_dev, struct device_driver *_drv) 1342 + static int sa1111_match(struct device *_dev, const struct device_driver *_drv) 1343 1343 { 1344 1344 struct sa1111_dev *dev = to_sa1111_device(_dev); 1345 - struct sa1111_driver *drv = SA1111_DRV(_drv); 1345 + const struct sa1111_driver *drv = SA1111_DRV(_drv); 1346 1346 1347 1347 return !!(dev->devid & drv->devid); 1348 1348 }
+1 -1
arch/arm/include/asm/hardware/locomo.h
··· 189 189 void (*remove)(struct locomo_dev *); 190 190 }; 191 191 192 - #define LOCOMO_DRV(_d) container_of((_d), struct locomo_driver, drv) 192 + #define LOCOMO_DRV(_d) container_of_const((_d), struct locomo_driver, drv) 193 193 194 194 #define LOCOMO_DRIVER_NAME(_ldev) ((_ldev)->dev.driver->name) 195 195
+1 -1
arch/arm/include/asm/hardware/sa1111.h
··· 404 404 void (*remove)(struct sa1111_dev *); 405 405 }; 406 406 407 - #define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv) 407 + #define SA1111_DRV(_d) container_of_const((_d), struct sa1111_driver, drv) 408 408 409 409 #define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name) 410 410
+1 -1
arch/parisc/include/asm/parisc-device.h
··· 41 41 42 42 43 43 #define to_parisc_device(d) container_of(d, struct parisc_device, dev) 44 - #define to_parisc_driver(d) container_of(d, struct parisc_driver, drv) 44 + #define to_parisc_driver(d) container_of_const(d, struct parisc_driver, drv) 45 45 #define parisc_parent(d) to_parisc_device(d->dev.parent) 46 46 47 47 static inline const char *parisc_pathname(struct parisc_device *d)
+2 -2
arch/parisc/kernel/drivers.c
··· 97 97 * @driver: the PA-RISC driver to try 98 98 * @dev: the PA-RISC device to try 99 99 */ 100 - static int match_device(struct parisc_driver *driver, struct parisc_device *dev) 100 + static int match_device(const struct parisc_driver *driver, struct parisc_device *dev) 101 101 { 102 102 const struct parisc_device_id *ids; 103 103 ··· 548 548 return dev; 549 549 } 550 550 551 - static int parisc_generic_match(struct device *dev, struct device_driver *drv) 551 + static int parisc_generic_match(struct device *dev, const struct device_driver *drv) 552 552 { 553 553 return match_device(to_parisc_driver(drv), to_parisc_device(dev)); 554 554 }
+1 -5
arch/powerpc/include/asm/ps3.h
··· 390 390 int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv); 391 391 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv); 392 392 393 - static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv( 394 - struct device_driver *_drv) 395 - { 396 - return container_of(_drv, struct ps3_system_bus_driver, core); 397 - } 393 + #define ps3_drv_to_system_bus_drv(_drv) container_of_const(_drv, struct ps3_system_bus_driver, core) 398 394 static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev( 399 395 const struct device *_dev) 400 396 {
+1 -5
arch/powerpc/include/asm/vio.h
··· 156 156 } 157 157 #endif 158 158 159 - static inline struct vio_driver *to_vio_driver(struct device_driver *drv) 160 - { 161 - return container_of(drv, struct vio_driver, driver); 162 - } 163 - 159 + #define to_vio_driver(__drv) container_of_const(__drv, struct vio_driver, driver) 164 160 #define to_vio_dev(__dev) container_of_const(__dev, struct vio_dev, dev) 165 161 166 162 #endif /* __KERNEL__ */
+2 -2
arch/powerpc/platforms/ps3/system-bus.c
··· 333 333 EXPORT_SYMBOL_GPL(ps3_mmio_region_init); 334 334 335 335 static int ps3_system_bus_match(struct device *_dev, 336 - struct device_driver *_drv) 336 + const struct device_driver *_drv) 337 337 { 338 338 int result; 339 - struct ps3_system_bus_driver *drv = ps3_drv_to_system_bus_drv(_drv); 339 + const struct ps3_system_bus_driver *drv = ps3_drv_to_system_bus_drv(_drv); 340 340 struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev); 341 341 342 342 if (!dev->match_sub_id)
+1 -1
arch/powerpc/platforms/pseries/ibmebus.c
··· 339 339 }; 340 340 ATTRIBUTE_GROUPS(ibmbus_bus); 341 341 342 - static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv) 342 + static int ibmebus_bus_bus_match(struct device *dev, const struct device_driver *drv) 343 343 { 344 344 const struct of_device_id *matches = drv->of_match_table; 345 345
+3 -3
arch/powerpc/platforms/pseries/vio.c
··· 1576 1576 } 1577 1577 EXPORT_SYMBOL(vio_unregister_device); 1578 1578 1579 - static int vio_bus_match(struct device *dev, struct device_driver *drv) 1579 + static int vio_bus_match(struct device *dev, const struct device_driver *drv) 1580 1580 { 1581 1581 const struct vio_dev *vio_dev = to_vio_dev(dev); 1582 - struct vio_driver *vio_drv = to_vio_driver(drv); 1582 + const struct vio_driver *vio_drv = to_vio_driver(drv); 1583 1583 const struct vio_device_id *ids = vio_drv->id_table; 1584 1584 1585 1585 return (ids != NULL) && (vio_match_device(ids, vio_dev) != NULL); ··· 1689 1689 /* construct the kobject name from the device node */ 1690 1690 if (of_node_is_type(vnode_parent, "vdevice")) { 1691 1691 const __be32 *prop; 1692 - 1692 + 1693 1693 prop = of_get_property(vnode, "reg", NULL); 1694 1694 if (!prop) 1695 1695 goto out;
+1 -1
arch/s390/include/asm/ccwdev.h
··· 210 210 #define get_ccwdev_lock(x) (x)->ccwlock 211 211 212 212 #define to_ccwdev(n) container_of(n, struct ccw_device, dev) 213 - #define to_ccwdrv(n) container_of(n, struct ccw_driver, driver) 213 + #define to_ccwdrv(n) container_of_const(n, struct ccw_driver, driver) 214 214 215 215 extern struct ccw_device *ccw_device_create_console(struct ccw_driver *); 216 216 extern void ccw_device_destroy_console(struct ccw_device *);
+1 -5
arch/sparc/include/asm/vio.h
··· 483 483 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) 484 484 void vio_unregister_driver(struct vio_driver *drv); 485 485 486 - static inline struct vio_driver *to_vio_driver(struct device_driver *drv) 487 - { 488 - return container_of(drv, struct vio_driver, driver); 489 - } 490 - 486 + #define to_vio_driver(__drv) container_of_const(__drv, struct vio_driver, driver) 491 487 #define to_vio_dev(__dev) container_of_const(__dev, struct vio_dev, dev) 492 488 493 489 int vio_ldc_send(struct vio_driver_state *vio, void *data, int len);
+2 -2
arch/sparc/kernel/vio.c
··· 54 54 return 0; 55 55 } 56 56 57 - static int vio_bus_match(struct device *dev, struct device_driver *drv) 57 + static int vio_bus_match(struct device *dev, const struct device_driver *drv) 58 58 { 59 59 struct vio_dev *vio_dev = to_vio_dev(dev); 60 - struct vio_driver *vio_drv = to_vio_driver(drv); 60 + const struct vio_driver *vio_drv = to_vio_driver(drv); 61 61 const struct vio_device_id *matches = vio_drv->id_table; 62 62 63 63 if (!matches)
+2 -2
drivers/acpi/bus.c
··· 1047 1047 ACPI Bus operations 1048 1048 -------------------------------------------------------------------------- */ 1049 1049 1050 - static int acpi_bus_match(struct device *dev, struct device_driver *drv) 1050 + static int acpi_bus_match(struct device *dev, const struct device_driver *drv) 1051 1051 { 1052 1052 struct acpi_device *acpi_dev = to_acpi_device(dev); 1053 - struct acpi_driver *acpi_drv = to_acpi_driver(drv); 1053 + const struct acpi_driver *acpi_drv = to_acpi_driver(drv); 1054 1054 1055 1055 return acpi_dev->flags.match_driver 1056 1056 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
+3 -3
drivers/amba/bus.c
··· 26 26 #include <linux/iommu.h> 27 27 #include <linux/dma-map-ops.h> 28 28 29 - #define to_amba_driver(d) container_of(d, struct amba_driver, drv) 29 + #define to_amba_driver(d) container_of_const(d, struct amba_driver, drv) 30 30 31 31 /* called on periphid match and class 0x9 coresight device. */ 32 32 static int ··· 205 205 return ret; 206 206 } 207 207 208 - static int amba_match(struct device *dev, struct device_driver *drv) 208 + static int amba_match(struct device *dev, const struct device_driver *drv) 209 209 { 210 210 struct amba_device *pcdev = to_amba_device(dev); 211 - struct amba_driver *pcdrv = to_amba_driver(drv); 211 + const struct amba_driver *pcdrv = to_amba_driver(drv); 212 212 213 213 mutex_lock(&pcdev->periphid_lock); 214 214 if (!pcdev->periphid) {
+71 -72
drivers/base/arch_topology.c
··· 8 8 9 9 #include <linux/acpi.h> 10 10 #include <linux/cacheinfo.h> 11 + #include <linux/cleanup.h> 11 12 #include <linux/cpu.h> 12 13 #include <linux/cpufreq.h> 13 14 #include <linux/device.h> ··· 514 513 */ 515 514 static int __init get_cpu_for_node(struct device_node *node) 516 515 { 517 - struct device_node *cpu_node; 518 516 int cpu; 517 + struct device_node *cpu_node __free(device_node) = 518 + of_parse_phandle(node, "cpu", 0); 519 519 520 - cpu_node = of_parse_phandle(node, "cpu", 0); 521 520 if (!cpu_node) 522 521 return -1; 523 522 ··· 528 527 pr_info("CPU node for %pOF exist but the possible cpu range is :%*pbl\n", 529 528 cpu_node, cpumask_pr_args(cpu_possible_mask)); 530 529 531 - of_node_put(cpu_node); 532 530 return cpu; 533 531 } 534 532 ··· 538 538 bool leaf = true; 539 539 int i = 0; 540 540 int cpu; 541 - struct device_node *t; 542 541 543 542 do { 544 543 snprintf(name, sizeof(name), "thread%d", i); 545 - t = of_get_child_by_name(core, name); 546 - if (t) { 547 - leaf = false; 548 - cpu = get_cpu_for_node(t); 549 - if (cpu >= 0) { 550 - cpu_topology[cpu].package_id = package_id; 551 - cpu_topology[cpu].cluster_id = cluster_id; 552 - cpu_topology[cpu].core_id = core_id; 553 - cpu_topology[cpu].thread_id = i; 554 - } else if (cpu != -ENODEV) { 555 - pr_err("%pOF: Can't get CPU for thread\n", t); 556 - of_node_put(t); 557 - return -EINVAL; 558 - } 559 - of_node_put(t); 544 + struct device_node *t __free(device_node) = 545 + of_get_child_by_name(core, name); 546 + 547 + if (!t) 548 + break; 549 + 550 + leaf = false; 551 + cpu = get_cpu_for_node(t); 552 + if (cpu >= 0) { 553 + cpu_topology[cpu].package_id = package_id; 554 + cpu_topology[cpu].cluster_id = cluster_id; 555 + cpu_topology[cpu].core_id = core_id; 556 + cpu_topology[cpu].thread_id = i; 557 + } else if (cpu != -ENODEV) { 558 + pr_err("%pOF: Can't get CPU for thread\n", t); 559 + return -EINVAL; 560 560 } 561 561 i++; 562 - } while (t); 562 + } while (1); 563 563 564 564 cpu = get_cpu_for_node(core); 565 565 if (cpu >= 0) { ··· 586 586 char name[20]; 587 587 bool leaf = true; 588 588 bool has_cores = false; 589 - struct device_node *c; 590 589 int core_id = 0; 591 590 int i, ret; 592 591 ··· 597 598 i = 0; 598 599 do { 599 600 snprintf(name, sizeof(name), "cluster%d", i); 600 - c = of_get_child_by_name(cluster, name); 601 - if (c) { 602 - leaf = false; 603 - ret = parse_cluster(c, package_id, i, depth + 1); 604 - if (depth > 0) 605 - pr_warn("Topology for clusters of clusters not yet supported\n"); 606 - of_node_put(c); 607 - if (ret != 0) 608 - return ret; 609 - } 601 + struct device_node *c __free(device_node) = 602 + of_get_child_by_name(cluster, name); 603 + 604 + if (!c) 605 + break; 606 + 607 + leaf = false; 608 + ret = parse_cluster(c, package_id, i, depth + 1); 609 + if (depth > 0) 610 + pr_warn("Topology for clusters of clusters not yet supported\n"); 611 + if (ret != 0) 612 + return ret; 610 613 i++; 611 - } while (c); 614 + } while (1); 612 615 613 616 /* Now check for cores */ 614 617 i = 0; 615 618 do { 616 619 snprintf(name, sizeof(name), "core%d", i); 617 - c = of_get_child_by_name(cluster, name); 618 - if (c) { 619 - has_cores = true; 620 + struct device_node *c __free(device_node) = 621 + of_get_child_by_name(cluster, name); 620 622 621 - if (depth == 0) { 622 - pr_err("%pOF: cpu-map children should be clusters\n", 623 - c); 624 - of_node_put(c); 625 - return -EINVAL; 626 - } 623 + if (!c) 624 + break; 627 625 628 - if (leaf) { 629 - ret = parse_core(c, package_id, cluster_id, 630 - core_id++); 631 - } else { 632 - pr_err("%pOF: Non-leaf cluster with core %s\n", 633 - cluster, name); 634 - ret = -EINVAL; 635 - } 626 + has_cores = true; 636 627 637 - of_node_put(c); 628 + if (depth == 0) { 629 + pr_err("%pOF: cpu-map children should be clusters\n", c); 630 + return -EINVAL; 631 + } 632 + 633 + if (leaf) { 634 + ret = parse_core(c, package_id, cluster_id, core_id++); 638 635 if (ret != 0) 639 636 return ret; 637 + } else { 638 + pr_err("%pOF: Non-leaf cluster with core %s\n", 639 + cluster, name); 640 + return -EINVAL; 640 641 } 642 + 641 643 i++; 642 - } while (c); 644 + } while (1); 643 645 644 646 if (leaf && !has_cores) 645 647 pr_warn("%pOF: empty cluster\n", cluster); ··· 651 651 static int __init parse_socket(struct device_node *socket) 652 652 { 653 653 char name[20]; 654 - struct device_node *c; 655 654 bool has_socket = false; 656 655 int package_id = 0, ret; 657 656 658 657 do { 659 658 snprintf(name, sizeof(name), "socket%d", package_id); 660 - c = of_get_child_by_name(socket, name); 661 - if (c) { 662 - has_socket = true; 663 - ret = parse_cluster(c, package_id, -1, 0); 664 - of_node_put(c); 665 - if (ret != 0) 666 - return ret; 667 - } 659 + struct device_node *c __free(device_node) = 660 + of_get_child_by_name(socket, name); 661 + 662 + if (!c) 663 + break; 664 + 665 + has_socket = true; 666 + ret = parse_cluster(c, package_id, -1, 0); 667 + if (ret != 0) 668 + return ret; 669 + 668 670 package_id++; 669 - } while (c); 671 + } while (1); 670 672 671 673 if (!has_socket) 672 674 ret = parse_cluster(socket, 0, -1, 0); ··· 678 676 679 677 static int __init parse_dt_topology(void) 680 678 { 681 - struct device_node *cn, *map; 682 679 int ret = 0; 683 680 int cpu; 681 + struct device_node *cn __free(device_node) = 682 + of_find_node_by_path("/cpus"); 684 683 685 - cn = of_find_node_by_path("/cpus"); 686 684 if (!cn) { 687 685 pr_err("No CPU information found in DT\n"); 688 686 return 0; ··· 692 690 * When topology is provided cpu-map is essentially a root 693 691 * cluster with restricted subnodes. 694 692 */ 695 - map = of_get_child_by_name(cn, "cpu-map"); 693 + struct device_node *map __free(device_node) = 694 + of_get_child_by_name(cn, "cpu-map"); 695 + 696 696 if (!map) 697 - goto out; 697 + return ret; 698 698 699 699 ret = parse_socket(map); 700 700 if (ret != 0) 701 - goto out_map; 701 + return ret; 702 702 703 703 topology_normalize_cpu_scale(); 704 704 ··· 710 706 */ 711 707 for_each_possible_cpu(cpu) 712 708 if (cpu_topology[cpu].package_id < 0) { 713 - ret = -EINVAL; 714 - break; 709 + return -EINVAL; 715 710 } 716 711 717 - out_map: 718 - of_node_put(map); 719 - out: 720 - of_node_put(cn); 721 712 return ret; 722 713 } 723 714 #endif
+5 -5
drivers/base/auxiliary.c
··· 177 177 return NULL; 178 178 } 179 179 180 - static int auxiliary_match(struct device *dev, struct device_driver *drv) 180 + static int auxiliary_match(struct device *dev, const struct device_driver *drv) 181 181 { 182 182 struct auxiliary_device *auxdev = to_auxiliary_dev(dev); 183 - struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv); 183 + const struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv); 184 184 185 185 return !!auxiliary_match_id(auxdrv->id_table, auxdev); 186 186 } ··· 203 203 204 204 static int auxiliary_bus_probe(struct device *dev) 205 205 { 206 - struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver); 206 + const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver); 207 207 struct auxiliary_device *auxdev = to_auxiliary_dev(dev); 208 208 int ret; 209 209 ··· 222 222 223 223 static void auxiliary_bus_remove(struct device *dev) 224 224 { 225 - struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver); 225 + const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver); 226 226 struct auxiliary_device *auxdev = to_auxiliary_dev(dev); 227 227 228 228 if (auxdrv->remove) ··· 232 232 233 233 static void auxiliary_bus_shutdown(struct device *dev) 234 234 { 235 - struct auxiliary_driver *auxdrv = NULL; 235 + const struct auxiliary_driver *auxdrv = NULL; 236 236 struct auxiliary_device *auxdev; 237 237 238 238 if (dev->driver) {
+8 -8
drivers/base/base.h
··· 112 112 struct klist_node knode_bus; 113 113 struct klist_node knode_class; 114 114 struct list_head deferred_probe; 115 - struct device_driver *async_driver; 115 + const struct device_driver *async_driver; 116 116 char *deferred_probe_reason; 117 117 struct device *device; 118 118 u8 dead:1; ··· 155 155 156 156 int bus_add_driver(struct device_driver *drv); 157 157 void bus_remove_driver(struct device_driver *drv); 158 - void device_release_driver_internal(struct device *dev, struct device_driver *drv, 158 + void device_release_driver_internal(struct device *dev, const struct device_driver *drv, 159 159 struct device *parent); 160 160 161 - void driver_detach(struct device_driver *drv); 161 + void driver_detach(const struct device_driver *drv); 162 162 void driver_deferred_probe_del(struct device *dev); 163 163 void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf); 164 - static inline int driver_match_device(struct device_driver *drv, 164 + static inline int driver_match_device(const struct device_driver *drv, 165 165 struct device *dev) 166 166 { 167 167 return drv->bus->match ? drv->bus->match(dev, drv) : 1; ··· 175 175 dev->driver->sync_state(dev); 176 176 } 177 177 178 - int driver_add_groups(struct device_driver *drv, const struct attribute_group **groups); 179 - void driver_remove_groups(struct device_driver *drv, const struct attribute_group **groups); 178 + int driver_add_groups(const struct device_driver *drv, const struct attribute_group **groups); 179 + void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups); 180 180 void device_driver_detach(struct device *dev); 181 181 182 182 int devres_release_all(struct device *dev); ··· 192 192 void devices_kset_move_last(struct device *dev); 193 193 194 194 #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) 195 - int module_add_driver(struct module *mod, struct device_driver *drv); 196 - void module_remove_driver(struct device_driver *drv); 195 + int module_add_driver(struct module *mod, const struct device_driver *drv); 196 + void module_remove_driver(const struct device_driver *drv); 197 197 #else 198 198 static inline int module_add_driver(struct module *mod, 199 199 struct device_driver *drv)
+14 -3
drivers/base/core.c
··· 5021 5021 vaf.fmt = fmt; 5022 5022 vaf.va = &args; 5023 5023 5024 - if (err != -EPROBE_DEFER) { 5025 - dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf); 5026 - } else { 5024 + switch (err) { 5025 + case -EPROBE_DEFER: 5027 5026 device_set_deferred_probe_reason(dev, &vaf); 5028 5027 dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf); 5028 + break; 5029 + 5030 + case -ENOMEM: 5031 + /* 5032 + * We don't print anything on -ENOMEM, there is already enough 5033 + * output. 5034 + */ 5035 + break; 5036 + 5037 + default: 5038 + dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf); 5039 + break; 5029 5040 } 5030 5041 5031 5042 va_end(args);
+2 -2
drivers/base/cpu.c
··· 26 26 27 27 static DEFINE_PER_CPU(struct device *, cpu_sys_devices); 28 28 29 - static int cpu_subsys_match(struct device *dev, struct device_driver *drv) 29 + static int cpu_subsys_match(struct device *dev, const struct device_driver *drv) 30 30 { 31 31 /* ACPI style match is the only one that may succeed. */ 32 32 if (acpi_driver_match_device(dev, drv)) ··· 316 316 { 317 317 return sysfs_emit(buf, "%d\n", crash_check_hotplug_support()); 318 318 } 319 - static DEVICE_ATTR_ADMIN_RO(crash_hotplug); 319 + static DEVICE_ATTR_RO(crash_hotplug); 320 320 #endif 321 321 322 322 static void cpu_device_release(struct device *dev)
+16 -14
drivers/base/dd.c
··· 568 568 dev->driver->remove(dev); 569 569 } 570 570 571 - static int call_driver_probe(struct device *dev, struct device_driver *drv) 571 + static int call_driver_probe(struct device *dev, const struct device_driver *drv) 572 572 { 573 573 int ret = 0; 574 574 ··· 599 599 return ret; 600 600 } 601 601 602 - static int really_probe(struct device *dev, struct device_driver *drv) 602 + static int really_probe(struct device *dev, const struct device_driver *drv) 603 603 { 604 604 bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) && 605 605 !drv->suppress_bind_attrs; ··· 628 628 } 629 629 630 630 re_probe: 631 - dev->driver = drv; 631 + // FIXME - this cast should not be needed "soon" 632 + dev->driver = (struct device_driver *)drv; 632 633 633 634 /* If using pinctrl, bind pins now before probing */ 634 635 ret = pinctrl_bind_pins(dev); ··· 728 727 /* 729 728 * For initcall_debug, show the driver probe time. 730 729 */ 731 - static int really_probe_debug(struct device *dev, struct device_driver *drv) 730 + static int really_probe_debug(struct device *dev, const struct device_driver *drv) 732 731 { 733 732 ktime_t calltime, rettime; 734 733 int ret; ··· 775 774 } 776 775 EXPORT_SYMBOL_GPL(wait_for_device_probe); 777 776 778 - static int __driver_probe_device(struct device_driver *drv, struct device *dev) 777 + static int __driver_probe_device(const struct device_driver *drv, struct device *dev) 779 778 { 780 779 int ret = 0; 781 780 ··· 820 819 * 821 820 * If the device has a parent, runtime-resume the parent before driver probing. 822 821 */ 823 - static int driver_probe_device(struct device_driver *drv, struct device *dev) 822 + static int driver_probe_device(const struct device_driver *drv, struct device *dev) 824 823 { 825 824 int trigger_count = atomic_read(&deferred_trigger_count); 826 825 int ret; ··· 864 863 } 865 864 __setup("driver_async_probe=", save_async_options); 866 865 867 - static bool driver_allows_async_probing(struct device_driver *drv) 866 + static bool driver_allows_async_probing(const struct device_driver *drv) 868 867 { 869 868 switch (drv->probe_type) { 870 869 case PROBE_PREFER_ASYNCHRONOUS: ··· 1118 1117 * Manually attach driver to a device. Will acquire both @dev lock and 1119 1118 * @dev->parent lock if needed. Returns 0 on success, -ERR on failure. 1120 1119 */ 1121 - int device_driver_attach(struct device_driver *drv, struct device *dev) 1120 + int device_driver_attach(const struct device_driver *drv, struct device *dev) 1122 1121 { 1123 1122 int ret; 1124 1123 ··· 1138 1137 static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie) 1139 1138 { 1140 1139 struct device *dev = _dev; 1141 - struct device_driver *drv; 1140 + const struct device_driver *drv; 1142 1141 int ret; 1143 1142 1144 1143 __device_driver_lock(dev, dev->parent); ··· 1154 1153 1155 1154 static int __driver_attach(struct device *dev, void *data) 1156 1155 { 1157 - struct device_driver *drv = data; 1156 + const struct device_driver *drv = data; 1158 1157 bool async = false; 1159 1158 int ret; 1160 1159 ··· 1227 1226 * returns 0 and the @dev->driver is set, we've found a 1228 1227 * compatible pair. 1229 1228 */ 1230 - int driver_attach(struct device_driver *drv) 1229 + int driver_attach(const struct device_driver *drv) 1231 1230 { 1232 - return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); 1231 + /* The (void *) will be put back to const * in __driver_attach() */ 1232 + return bus_for_each_dev(drv->bus, NULL, (void *)drv, __driver_attach); 1233 1233 } 1234 1234 EXPORT_SYMBOL_GPL(driver_attach); 1235 1235 ··· 1286 1284 } 1287 1285 1288 1286 void device_release_driver_internal(struct device *dev, 1289 - struct device_driver *drv, 1287 + const struct device_driver *drv, 1290 1288 struct device *parent) 1291 1289 { 1292 1290 __device_driver_lock(dev, parent); ··· 1335 1333 * driver_detach - detach driver from all devices it controls. 1336 1334 * @drv: driver. 1337 1335 */ 1338 - void driver_detach(struct device_driver *drv) 1336 + void driver_detach(const struct device_driver *drv) 1339 1337 { 1340 1338 struct device_private *dev_prv; 1341 1339 struct device *dev;
+21 -13
drivers/base/devres.c
··· 85 85 /* noop */ 86 86 } 87 87 88 - static struct devres_group * node_to_group(struct devres_node *node) 88 + static struct devres_group *node_to_group(struct devres_node *node) 89 89 { 90 90 if (node->release == &group_open_release) 91 91 return container_of(node, struct devres_group, node[0]); ··· 107 107 return true; 108 108 } 109 109 110 - static __always_inline struct devres * alloc_dr(dr_release_t release, 111 - size_t size, gfp_t gfp, int nid) 110 + static __always_inline struct devres *alloc_dr(dr_release_t release, 111 + size_t size, gfp_t gfp, int nid) 112 112 { 113 113 size_t tot_size; 114 114 struct devres *dr; ··· 283 283 * RETURNS: 284 284 * Pointer to found devres, NULL if not found. 285 285 */ 286 - void * devres_find(struct device *dev, dr_release_t release, 287 - dr_match_t match, void *match_data) 286 + void *devres_find(struct device *dev, dr_release_t release, 287 + dr_match_t match, void *match_data) 288 288 { 289 289 struct devres *dr; 290 290 unsigned long flags; ··· 313 313 * RETURNS: 314 314 * Pointer to found or added devres. 315 315 */ 316 - void * devres_get(struct device *dev, void *new_res, 317 - dr_match_t match, void *match_data) 316 + void *devres_get(struct device *dev, void *new_res, 317 + dr_match_t match, void *match_data) 318 318 { 319 319 struct devres *new_dr = container_of(new_res, struct devres, data); 320 320 struct devres *dr; ··· 349 349 * RETURNS: 350 350 * Pointer to removed devres on success, NULL if not found. 351 351 */ 352 - void * devres_remove(struct device *dev, dr_release_t release, 353 - dr_match_t match, void *match_data) 352 + void *devres_remove(struct device *dev, dr_release_t release, 353 + dr_match_t match, void *match_data) 354 354 { 355 355 struct devres *dr; 356 356 unsigned long flags; ··· 549 549 * RETURNS: 550 550 * ID of the new group, NULL on failure. 551 551 */ 552 - void * devres_open_group(struct device *dev, void *id, gfp_t gfp) 552 + void *devres_open_group(struct device *dev, void *id, gfp_t gfp) 553 553 { 554 554 struct devres_group *grp; 555 555 unsigned long flags; ··· 567 567 grp->id = grp; 568 568 if (id) 569 569 grp->id = id; 570 + grp->color = 0; 570 571 571 572 spin_lock_irqsave(&dev->devres_lock, flags); 572 573 add_dr(dev, &grp->node[0]); ··· 577 576 EXPORT_SYMBOL_GPL(devres_open_group); 578 577 579 578 /* Find devres group with ID @id. If @id is NULL, look for the latest. */ 580 - static struct devres_group * find_group(struct device *dev, void *id) 579 + static struct devres_group *find_group(struct device *dev, void *id) 581 580 { 582 581 struct devres_node *node; 583 582 ··· 897 896 /* 898 897 * Otherwise: allocate new, larger chunk. We need to allocate before 899 898 * taking the lock as most probably the caller uses GFP_KERNEL. 899 + * alloc_dr() will call check_dr_size() to reserve extra memory 900 + * for struct devres automatically, so size @new_size user request 901 + * is delivered to it directly as devm_kmalloc() does. 900 902 */ 901 903 new_dr = alloc_dr(devm_kmalloc_release, 902 - total_new_size, gfp, dev_to_node(dev)); 904 + new_size, gfp, dev_to_node(dev)); 903 905 if (!new_dr) 904 906 return NULL; 905 907 ··· 1226 1222 */ 1227 1223 void devm_free_percpu(struct device *dev, void __percpu *pdata) 1228 1224 { 1229 - WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match, 1225 + /* 1226 + * Use devres_release() to prevent memory leakage as 1227 + * devm_free_pages() does. 1228 + */ 1229 + WARN_ON(devres_release(dev, devm_percpu_release, devm_percpu_match, 1230 1230 (__force void *)pdata)); 1231 1231 } 1232 1232 EXPORT_SYMBOL_GPL(devm_free_percpu);
+5 -5
drivers/base/driver.c
··· 148 148 * if it does. If the callback returns non-zero, this function will 149 149 * return to the caller and not iterate over any more devices. 150 150 */ 151 - struct device *driver_find_device(struct device_driver *drv, 151 + struct device *driver_find_device(const struct device_driver *drv, 152 152 struct device *start, const void *data, 153 153 int (*match)(struct device *dev, const void *data)) 154 154 { ··· 173 173 * @drv: driver. 174 174 * @attr: driver attribute descriptor. 175 175 */ 176 - int driver_create_file(struct device_driver *drv, 176 + int driver_create_file(const struct device_driver *drv, 177 177 const struct driver_attribute *attr) 178 178 { 179 179 int error; ··· 191 191 * @drv: driver. 192 192 * @attr: driver attribute descriptor. 193 193 */ 194 - void driver_remove_file(struct device_driver *drv, 194 + void driver_remove_file(const struct device_driver *drv, 195 195 const struct driver_attribute *attr) 196 196 { 197 197 if (drv) ··· 199 199 } 200 200 EXPORT_SYMBOL_GPL(driver_remove_file); 201 201 202 - int driver_add_groups(struct device_driver *drv, 202 + int driver_add_groups(const struct device_driver *drv, 203 203 const struct attribute_group **groups) 204 204 { 205 205 return sysfs_create_groups(&drv->p->kobj, groups); 206 206 } 207 207 208 - void driver_remove_groups(struct device_driver *drv, 208 + void driver_remove_groups(const struct device_driver *drv, 209 209 const struct attribute_group **groups) 210 210 { 211 211 sysfs_remove_groups(&drv->p->kobj, groups);
+7
drivers/base/firmware_loader/Kconfig
··· 37 37 SHA256 checksums to the kernel log for each firmware file that is 38 38 loaded. 39 39 40 + config RUST_FW_LOADER_ABSTRACTIONS 41 + bool "Rust Firmware Loader abstractions" 42 + depends on RUST 43 + depends on FW_LOADER=y 44 + help 45 + This enables the Rust abstractions for the firmware loader API. 46 + 40 47 if FW_LOADER 41 48 42 49 config FW_LOADER_PAGED_BUF
+1 -1
drivers/base/isa.c
··· 23 23 24 24 #define to_isa_dev(x) container_of((x), struct isa_dev, dev) 25 25 26 - static int isa_bus_match(struct device *dev, struct device_driver *driver) 26 + static int isa_bus_match(struct device *dev, const struct device_driver *driver) 27 27 { 28 28 struct isa_driver *isa_driver = to_isa_driver(driver); 29 29
+3 -3
drivers/base/module.c
··· 9 9 #include <linux/string.h> 10 10 #include "base.h" 11 11 12 - static char *make_driver_name(struct device_driver *drv) 12 + static char *make_driver_name(const struct device_driver *drv) 13 13 { 14 14 char *driver_name; 15 15 ··· 30 30 mutex_unlock(&drivers_dir_mutex); 31 31 } 32 32 33 - int module_add_driver(struct module *mod, struct device_driver *drv) 33 + int module_add_driver(struct module *mod, const struct device_driver *drv) 34 34 { 35 35 char *driver_name; 36 36 struct module_kobject *mk = NULL; ··· 89 89 return ret; 90 90 } 91 91 92 - void module_remove_driver(struct device_driver *drv) 92 + void module_remove_driver(const struct device_driver *drv) 93 93 { 94 94 struct module_kobject *mk = NULL; 95 95 char *driver_name;
+10 -16
drivers/base/platform.c
··· 608 608 struct resource *r = NULL; 609 609 610 610 if (res) { 611 - r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL); 611 + r = kmemdup_array(res, num, sizeof(*r), GFP_KERNEL); 612 612 if (!r) 613 613 return -ENOMEM; 614 614 } ··· 1122 1122 1123 1123 int platform_pm_suspend(struct device *dev) 1124 1124 { 1125 - struct device_driver *drv = dev->driver; 1125 + const struct device_driver *drv = dev->driver; 1126 1126 int ret = 0; 1127 1127 1128 1128 if (!drv) ··· 1140 1140 1141 1141 int platform_pm_resume(struct device *dev) 1142 1142 { 1143 - struct device_driver *drv = dev->driver; 1143 + const struct device_driver *drv = dev->driver; 1144 1144 int ret = 0; 1145 1145 1146 1146 if (!drv) ··· 1162 1162 1163 1163 int platform_pm_freeze(struct device *dev) 1164 1164 { 1165 - struct device_driver *drv = dev->driver; 1165 + const struct device_driver *drv = dev->driver; 1166 1166 int ret = 0; 1167 1167 1168 1168 if (!drv) ··· 1180 1180 1181 1181 int platform_pm_thaw(struct device *dev) 1182 1182 { 1183 - struct device_driver *drv = dev->driver; 1183 + const struct device_driver *drv = dev->driver; 1184 1184 int ret = 0; 1185 1185 1186 1186 if (!drv) ··· 1198 1198 1199 1199 int platform_pm_poweroff(struct device *dev) 1200 1200 { 1201 - struct device_driver *drv = dev->driver; 1201 + const struct device_driver *drv = dev->driver; 1202 1202 int ret = 0; 1203 1203 1204 1204 if (!drv) ··· 1216 1216 1217 1217 int platform_pm_restore(struct device *dev) 1218 1218 { 1219 - struct device_driver *drv = dev->driver; 1219 + const struct device_driver *drv = dev->driver; 1220 1220 int ret = 0; 1221 1221 1222 1222 if (!drv) ··· 1332 1332 * and compare it against the name of the driver. Return whether they match 1333 1333 * or not. 1334 1334 */ 1335 - static int platform_match(struct device *dev, struct device_driver *drv) 1335 + static int platform_match(struct device *dev, const struct device_driver *drv) 1336 1336 { 1337 1337 struct platform_device *pdev = to_platform_device(dev); 1338 1338 struct platform_driver *pdrv = to_platform_driver(drv); ··· 1420 1420 struct platform_driver *drv = to_platform_driver(_dev->driver); 1421 1421 struct platform_device *dev = to_platform_device(_dev); 1422 1422 1423 - if (drv->remove_new) { 1424 - drv->remove_new(dev); 1425 - } else if (drv->remove) { 1426 - int ret = drv->remove(dev); 1427 - 1428 - if (ret) 1429 - dev_warn(_dev, "remove callback returned a non-zero value. This will be ignored.\n"); 1430 - } 1423 + if (drv->remove) 1424 + drv->remove(dev); 1431 1425 dev_pm_domain_detach(_dev, true); 1432 1426 } 1433 1427
+3 -3
drivers/bcma/main.c
··· 26 26 /* bcma_buses_mutex locks the bcma_bus_next_num */ 27 27 static DEFINE_MUTEX(bcma_buses_mutex); 28 28 29 - static int bcma_bus_match(struct device *dev, struct device_driver *drv); 29 + static int bcma_bus_match(struct device *dev, const struct device_driver *drv); 30 30 static int bcma_device_probe(struct device *dev); 31 31 static void bcma_device_remove(struct device *dev); 32 32 static int bcma_device_uevent(const struct device *dev, struct kobj_uevent_env *env); ··· 584 584 } 585 585 EXPORT_SYMBOL_GPL(bcma_driver_unregister); 586 586 587 - static int bcma_bus_match(struct device *dev, struct device_driver *drv) 587 + static int bcma_bus_match(struct device *dev, const struct device_driver *drv) 588 588 { 589 589 struct bcma_device *core = container_of(dev, struct bcma_device, dev); 590 - struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv); 590 + const struct bcma_driver *adrv = container_of_const(drv, struct bcma_driver, drv); 591 591 const struct bcma_device_id *cid = &core->id; 592 592 const struct bcma_device_id *did; 593 593
+2 -2
drivers/bus/fsl-mc/fsl-mc-bus.c
··· 80 80 * 81 81 * Returns 1 on success, 0 otherwise. 82 82 */ 83 - static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv) 83 + static int fsl_mc_bus_match(struct device *dev, const struct device_driver *drv) 84 84 { 85 85 const struct fsl_mc_device_id *id; 86 86 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 87 - struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv); 87 + const struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv); 88 88 bool found = false; 89 89 90 90 /* When driver_override is set, only bind to the matching driver */
+2 -2
drivers/bus/mhi/ep/main.c
··· 1694 1694 mhi_dev->name); 1695 1695 } 1696 1696 1697 - static int mhi_ep_match(struct device *dev, struct device_driver *drv) 1697 + static int mhi_ep_match(struct device *dev, const struct device_driver *drv) 1698 1698 { 1699 1699 struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev); 1700 - struct mhi_ep_driver *mhi_drv = to_mhi_ep_driver(drv); 1700 + const struct mhi_ep_driver *mhi_drv = to_mhi_ep_driver(drv); 1701 1701 const struct mhi_device_id *id; 1702 1702 1703 1703 /*
+2 -2
drivers/bus/mhi/host/init.c
··· 1442 1442 mhi_dev->name); 1443 1443 } 1444 1444 1445 - static int mhi_match(struct device *dev, struct device_driver *drv) 1445 + static int mhi_match(struct device *dev, const struct device_driver *drv) 1446 1446 { 1447 1447 struct mhi_device *mhi_dev = to_mhi_device(dev); 1448 - struct mhi_driver *mhi_drv = to_mhi_driver(drv); 1448 + const struct mhi_driver *mhi_drv = to_mhi_driver(drv); 1449 1449 const struct mhi_device_id *id; 1450 1450 1451 1451 /*
+3 -3
drivers/bus/mips_cdmm.c
··· 37 37 /* Each block of device registers is 64 bytes */ 38 38 #define CDMM_DRB_SIZE 64 39 39 40 - #define to_mips_cdmm_driver(d) container_of(d, struct mips_cdmm_driver, drv) 40 + #define to_mips_cdmm_driver(d) container_of_const(d, struct mips_cdmm_driver, drv) 41 41 42 42 /* Default physical base address */ 43 43 static phys_addr_t mips_cdmm_default_base; ··· 59 59 return ret ? table : NULL; 60 60 } 61 61 62 - static int mips_cdmm_match(struct device *dev, struct device_driver *drv) 62 + static int mips_cdmm_match(struct device *dev, const struct device_driver *drv) 63 63 { 64 64 struct mips_cdmm_device *cdev = to_mips_cdmm_device(dev); 65 - struct mips_cdmm_driver *cdrv = to_mips_cdmm_driver(drv); 65 + const struct mips_cdmm_driver *cdrv = to_mips_cdmm_driver(drv); 66 66 67 67 return mips_cdmm_lookup(cdrv->id_table, cdev) != NULL; 68 68 }
+2 -2
drivers/bus/moxtet.c
··· 83 83 NULL, 84 84 }; 85 85 86 - static int moxtet_match(struct device *dev, struct device_driver *drv) 86 + static int moxtet_match(struct device *dev, const struct device_driver *drv) 87 87 { 88 88 struct moxtet_device *mdev = to_moxtet_device(dev); 89 - struct moxtet_driver *tdrv = to_moxtet_driver(drv); 89 + const struct moxtet_driver *tdrv = to_moxtet_driver(drv); 90 90 const enum turris_mox_module_id *t; 91 91 92 92 if (of_driver_match_device(dev, drv))
+1 -1
drivers/bus/sunxi-rsb.c
··· 130 130 /* bus / slave device related functions */ 131 131 static const struct bus_type sunxi_rsb_bus; 132 132 133 - static int sunxi_rsb_device_match(struct device *dev, struct device_driver *drv) 133 + static int sunxi_rsb_device_match(struct device *dev, const struct device_driver *drv) 134 134 { 135 135 return of_driver_match_device(dev, drv); 136 136 }
+2 -2
drivers/cdx/cdx.c
··· 262 262 * 263 263 * Return: true on success, false otherwise. 264 264 */ 265 - static int cdx_bus_match(struct device *dev, struct device_driver *drv) 265 + static int cdx_bus_match(struct device *dev, const struct device_driver *drv) 266 266 { 267 267 struct cdx_device *cdx_dev = to_cdx_device(dev); 268 - struct cdx_driver *cdx_drv = to_cdx_driver(drv); 268 + const struct cdx_driver *cdx_drv = to_cdx_driver(drv); 269 269 const struct cdx_device_id *found_id = NULL; 270 270 const struct cdx_device_id *ids; 271 271
+1 -1
drivers/cxl/core/port.c
··· 2082 2082 cxl_device_id(dev)); 2083 2083 } 2084 2084 2085 - static int cxl_bus_match(struct device *dev, struct device_driver *drv) 2085 + static int cxl_bus_match(struct device *dev, const struct device_driver *drv) 2086 2086 { 2087 2087 return cxl_device_id(dev) == to_cxl_drv(drv)->id; 2088 2088 }
+1 -4
drivers/cxl/cxl.h
··· 825 825 int id; 826 826 }; 827 827 828 - static inline struct cxl_driver *to_cxl_drv(struct device_driver *drv) 829 - { 830 - return container_of(drv, struct cxl_driver, drv); 831 - } 828 + #define to_cxl_drv(__drv) container_of_const(__drv, struct cxl_driver, drv) 832 829 833 830 int __cxl_driver_register(struct cxl_driver *cxl_drv, struct module *owner, 834 831 const char *modname);
+7 -10
drivers/dax/bus.c
··· 39 39 return add_uevent_var(env, "MODALIAS=" DAX_DEVICE_MODALIAS_FMT, 0); 40 40 } 41 41 42 - static struct dax_device_driver *to_dax_drv(struct device_driver *drv) 43 - { 44 - return container_of(drv, struct dax_device_driver, drv); 45 - } 42 + #define to_dax_drv(__drv) container_of_const(__drv, struct dax_device_driver, drv) 46 43 47 - static struct dax_id *__dax_match_id(struct dax_device_driver *dax_drv, 44 + static struct dax_id *__dax_match_id(const struct dax_device_driver *dax_drv, 48 45 const char *dev_name) 49 46 { 50 47 struct dax_id *dax_id; ··· 54 57 return NULL; 55 58 } 56 59 57 - static int dax_match_id(struct dax_device_driver *dax_drv, struct device *dev) 60 + static int dax_match_id(const struct dax_device_driver *dax_drv, struct device *dev) 58 61 { 59 62 int match; 60 63 ··· 65 68 return match; 66 69 } 67 70 68 - static int dax_match_type(struct dax_device_driver *dax_drv, struct device *dev) 71 + static int dax_match_type(const struct dax_device_driver *dax_drv, struct device *dev) 69 72 { 70 73 enum dax_driver_type type = DAXDRV_DEVICE_TYPE; 71 74 struct dev_dax *dev_dax = to_dev_dax(dev); ··· 153 156 }; 154 157 ATTRIBUTE_GROUPS(dax_drv); 155 158 156 - static int dax_bus_match(struct device *dev, struct device_driver *drv); 159 + static int dax_bus_match(struct device *dev, const struct device_driver *drv); 157 160 158 161 /* 159 162 * Static dax regions are regions created by an external subsystem ··· 247 250 .drv_groups = dax_drv_groups, 248 251 }; 249 252 250 - static int dax_bus_match(struct device *dev, struct device_driver *drv) 253 + static int dax_bus_match(struct device *dev, const struct device_driver *drv) 251 254 { 252 - struct dax_device_driver *dax_drv = to_dax_drv(drv); 255 + const struct dax_device_driver *dax_drv = to_dax_drv(drv); 253 256 254 257 if (dax_match_id(dax_drv, dev)) 255 258 return 1;
+12 -8
drivers/dca/dca-sysfs.c
··· 13 13 #include <linux/gfp.h> 14 14 #include <linux/export.h> 15 15 16 - static struct class *dca_class; 16 + static const struct class dca_class = { 17 + .name = "dca", 18 + }; 17 19 static struct idr dca_idr; 18 20 static spinlock_t dca_idr_lock; 19 21 ··· 24 22 struct device *cd; 25 23 static int req_count; 26 24 27 - cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), NULL, 25 + cd = device_create(&dca_class, dca->cd, MKDEV(0, slot + 1), NULL, 28 26 "requester%d", req_count++); 29 27 return PTR_ERR_OR_ZERO(cd); 30 28 } 31 29 32 30 void dca_sysfs_remove_req(struct dca_provider *dca, int slot) 33 31 { 34 - device_destroy(dca_class, MKDEV(0, slot + 1)); 32 + device_destroy(&dca_class, MKDEV(0, slot + 1)); 35 33 } 36 34 37 35 int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev) ··· 51 49 if (ret < 0) 52 50 return ret; 53 51 54 - cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id); 52 + cd = device_create(&dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id); 55 53 if (IS_ERR(cd)) { 56 54 spin_lock(&dca_idr_lock); 57 55 idr_remove(&dca_idr, dca->id); ··· 73 71 74 72 int __init dca_sysfs_init(void) 75 73 { 74 + int err; 75 + 76 76 idr_init(&dca_idr); 77 77 spin_lock_init(&dca_idr_lock); 78 78 79 - dca_class = class_create("dca"); 80 - if (IS_ERR(dca_class)) { 79 + err = class_register(&dca_class); 80 + if (err) { 81 81 idr_destroy(&dca_idr); 82 - return PTR_ERR(dca_class); 82 + return err; 83 83 } 84 84 return 0; 85 85 } 86 86 87 87 void __exit dca_sysfs_exit(void) 88 88 { 89 - class_destroy(dca_class); 89 + class_unregister(&dca_class); 90 90 idr_destroy(&dca_idr); 91 91 } 92 92
+2 -2
drivers/dio/dio-driver.c
··· 110 110 * and 0 if there is no match. 111 111 */ 112 112 113 - static int dio_bus_match(struct device *dev, struct device_driver *drv) 113 + static int dio_bus_match(struct device *dev, const struct device_driver *drv) 114 114 { 115 115 struct dio_dev *d = to_dio_dev(dev); 116 - struct dio_driver *dio_drv = to_dio_driver(drv); 116 + const struct dio_driver *dio_drv = to_dio_driver(drv); 117 117 const struct dio_device_id *ids = dio_drv->id_table; 118 118 119 119 if (!ids)
+3 -3
drivers/dma/idxd/bus.c
··· 33 33 EXPORT_SYMBOL_GPL(idxd_driver_unregister); 34 34 35 35 static int idxd_config_bus_match(struct device *dev, 36 - struct device_driver *drv) 36 + const struct device_driver *drv) 37 37 { 38 - struct idxd_device_driver *idxd_drv = 39 - container_of(drv, struct idxd_device_driver, drv); 38 + const struct idxd_device_driver *idxd_drv = 39 + container_of_const(drv, struct idxd_device_driver, drv); 40 40 struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); 41 41 int i = 0; 42 42
-1
drivers/dma/idxd/compat.c
··· 7 7 #include <linux/device/bus.h> 8 8 #include "idxd.h" 9 9 10 - extern int device_driver_attach(struct device_driver *drv, struct device *dev); 11 10 extern void device_driver_detach(struct device *dev); 12 11 13 12 #define DRIVER_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \
+2 -2
drivers/eisa/eisa-bus.c
··· 105 105 return sig_str; 106 106 } 107 107 108 - static int eisa_bus_match(struct device *dev, struct device_driver *drv) 108 + static int eisa_bus_match(struct device *dev, const struct device_driver *drv) 109 109 { 110 110 struct eisa_device *edev = to_eisa_device(dev); 111 - struct eisa_driver *edrv = to_eisa_driver(drv); 111 + const struct eisa_driver *edrv = to_eisa_driver(drv); 112 112 const struct eisa_device_id *eids = edrv->id_table; 113 113 114 114 if (!eids)
+3 -3
drivers/firewire/core-device.c
··· 190 190 } 191 191 192 192 static const struct ieee1394_device_id *unit_match(struct device *dev, 193 - struct device_driver *drv) 193 + const struct device_driver *drv) 194 194 { 195 195 const struct ieee1394_device_id *id_table = 196 - container_of(drv, struct fw_driver, driver)->id_table; 196 + container_of_const(drv, struct fw_driver, driver)->id_table; 197 197 int id[] = {0, 0, 0, 0}; 198 198 199 199 get_modalias_ids(fw_unit(dev), id); ··· 207 207 208 208 static bool is_fw_unit(const struct device *dev); 209 209 210 - static int fw_unit_match(struct device *dev, struct device_driver *drv) 210 + static int fw_unit_match(struct device *dev, const struct device_driver *drv) 211 211 { 212 212 /* We only allow binding to fw_units. */ 213 213 return is_fw_unit(dev) && unit_match(dev, drv) != NULL;
+1 -1
drivers/firmware/arm_ffa/bus.c
··· 19 19 20 20 static DEFINE_IDA(ffa_bus_id); 21 21 22 - static int ffa_device_match(struct device *dev, struct device_driver *drv) 22 + static int ffa_device_match(struct device *dev, const struct device_driver *drv) 23 23 { 24 24 const struct ffa_device_id *id_table; 25 25 struct ffa_device *ffa_dev;
+3 -3
drivers/firmware/arm_scmi/bus.c
··· 207 207 } 208 208 209 209 static const struct scmi_device_id * 210 - scmi_dev_match_id(struct scmi_device *scmi_dev, struct scmi_driver *scmi_drv) 210 + scmi_dev_match_id(struct scmi_device *scmi_dev, const struct scmi_driver *scmi_drv) 211 211 { 212 212 const struct scmi_device_id *id = scmi_drv->id_table; 213 213 ··· 225 225 return NULL; 226 226 } 227 227 228 - static int scmi_dev_match(struct device *dev, struct device_driver *drv) 228 + static int scmi_dev_match(struct device *dev, const struct device_driver *drv) 229 229 { 230 - struct scmi_driver *scmi_drv = to_scmi_driver(drv); 230 + const struct scmi_driver *scmi_drv = to_scmi_driver(drv); 231 231 struct scmi_device *scmi_dev = to_scmi_dev(dev); 232 232 const struct scmi_device_id *id; 233 233
+3 -3
drivers/firmware/google/coreboot_table.c
··· 22 22 #include "coreboot_table.h" 23 23 24 24 #define CB_DEV(d) container_of(d, struct coreboot_device, dev) 25 - #define CB_DRV(d) container_of(d, struct coreboot_driver, drv) 25 + #define CB_DRV(d) container_of_const(d, struct coreboot_driver, drv) 26 26 27 - static int coreboot_bus_match(struct device *dev, struct device_driver *drv) 27 + static int coreboot_bus_match(struct device *dev, const struct device_driver *drv) 28 28 { 29 29 struct coreboot_device *device = CB_DEV(dev); 30 - struct coreboot_driver *driver = CB_DRV(drv); 30 + const struct coreboot_driver *driver = CB_DRV(drv); 31 31 const struct coreboot_device_id *id; 32 32 33 33 if (!driver->id_table)
+2 -2
drivers/fpga/dfl.c
··· 257 257 return NULL; 258 258 } 259 259 260 - static int dfl_bus_match(struct device *dev, struct device_driver *drv) 260 + static int dfl_bus_match(struct device *dev, const struct device_driver *drv) 261 261 { 262 262 struct dfl_device *ddev = to_dfl_dev(dev); 263 - struct dfl_driver *ddrv = to_dfl_drv(drv); 263 + const struct dfl_driver *ddrv = to_dfl_drv(drv); 264 264 const struct dfl_device_id *id_entry; 265 265 266 266 id_entry = ddrv->id_table;
+2 -2
drivers/fsi/fsi-core.c
··· 1361 1361 1362 1362 /* FSI core & Linux bus type definitions */ 1363 1363 1364 - static int fsi_bus_match(struct device *dev, struct device_driver *drv) 1364 + static int fsi_bus_match(struct device *dev, const struct device_driver *drv) 1365 1365 { 1366 1366 struct fsi_device *fsi_dev = to_fsi_dev(dev); 1367 - struct fsi_driver *fsi_drv = to_fsi_drv(drv); 1367 + const struct fsi_driver *fsi_drv = to_fsi_drv(drv); 1368 1368 const struct fsi_device_id *id; 1369 1369 1370 1370 if (!fsi_drv->id_table)
+2 -4
drivers/fsi/fsi-master-aspeed.c
··· 646 646 return rc; 647 647 } 648 648 649 - static int fsi_master_aspeed_remove(struct platform_device *pdev) 649 + static void fsi_master_aspeed_remove(struct platform_device *pdev) 650 650 { 651 651 struct fsi_master_aspeed *aspeed = platform_get_drvdata(pdev); 652 652 653 653 fsi_master_unregister(&aspeed->master); 654 654 clk_disable_unprepare(aspeed->clk); 655 - 656 - return 0; 657 655 } 658 656 659 657 static const struct of_device_id fsi_master_aspeed_match[] = { ··· 666 668 .of_match_table = fsi_master_aspeed_match, 667 669 }, 668 670 .probe = fsi_master_aspeed_probe, 669 - .remove = fsi_master_aspeed_remove, 671 + .remove_new = fsi_master_aspeed_remove, 670 672 }; 671 673 672 674 module_platform_driver(fsi_master_aspeed_driver);
+2 -4
drivers/fsi/fsi-master-ast-cf.c
··· 1412 1412 } 1413 1413 1414 1414 1415 - static int fsi_master_acf_remove(struct platform_device *pdev) 1415 + static void fsi_master_acf_remove(struct platform_device *pdev) 1416 1416 { 1417 1417 struct fsi_master_acf *master = platform_get_drvdata(pdev); 1418 1418 1419 1419 device_remove_file(master->dev, &dev_attr_external_mode); 1420 1420 1421 1421 fsi_master_unregister(&master->master); 1422 - 1423 - return 0; 1424 1422 } 1425 1423 1426 1424 static const struct of_device_id fsi_master_acf_match[] = { ··· 1434 1436 .of_match_table = fsi_master_acf_match, 1435 1437 }, 1436 1438 .probe = fsi_master_acf_probe, 1437 - .remove = fsi_master_acf_remove, 1439 + .remove_new = fsi_master_acf_remove, 1438 1440 }; 1439 1441 1440 1442 module_platform_driver(fsi_master_acf);
+2 -4
drivers/fsi/fsi-master-gpio.c
··· 867 867 868 868 869 869 870 - static int fsi_master_gpio_remove(struct platform_device *pdev) 870 + static void fsi_master_gpio_remove(struct platform_device *pdev) 871 871 { 872 872 struct fsi_master_gpio *master = platform_get_drvdata(pdev); 873 873 874 874 device_remove_file(&pdev->dev, &dev_attr_external_mode); 875 875 876 876 fsi_master_unregister(&master->master); 877 - 878 - return 0; 879 877 } 880 878 881 879 static const struct of_device_id fsi_master_gpio_match[] = { ··· 888 890 .of_match_table = fsi_master_gpio_match, 889 891 }, 890 892 .probe = fsi_master_gpio_probe, 891 - .remove = fsi_master_gpio_remove, 893 + .remove_new = fsi_master_gpio_remove, 892 894 }; 893 895 894 896 module_platform_driver(fsi_master_gpio_driver);
+2 -4
drivers/fsi/fsi-occ.c
··· 702 702 return 0; 703 703 } 704 704 705 - static int occ_remove(struct platform_device *pdev) 705 + static void occ_remove(struct platform_device *pdev) 706 706 { 707 707 struct occ *occ = platform_get_drvdata(pdev); 708 708 ··· 719 719 device_for_each_child(&pdev->dev, NULL, occ_unregister_of_child); 720 720 721 721 ida_free(&occ_ida, occ->idx); 722 - 723 - return 0; 724 722 } 725 723 726 724 static const struct of_device_id occ_match[] = { ··· 740 742 .of_match_table = occ_match, 741 743 }, 742 744 .probe = occ_probe, 743 - .remove = occ_remove, 745 + .remove_new = occ_remove, 744 746 }; 745 747 746 748 static int occ_init(void)
+1 -1
drivers/gpio/gpiolib.c
··· 55 55 static dev_t gpio_devt; 56 56 #define GPIO_DEV_MAX 256 /* 256 GPIO chip devices supported */ 57 57 58 - static int gpio_bus_match(struct device *dev, struct device_driver *drv) 58 + static int gpio_bus_match(struct device *dev, const struct device_driver *drv) 59 59 { 60 60 struct fwnode_handle *fwnode = dev_fwnode(dev); 61 61
+1 -1
drivers/gpu/drm/display/drm_dp_aux_bus.c
··· 36 36 * 37 37 * Return: True if this driver matches this device; false otherwise. 38 38 */ 39 - static int dp_aux_ep_match(struct device *dev, struct device_driver *drv) 39 + static int dp_aux_ep_match(struct device *dev, const struct device_driver *drv) 40 40 { 41 41 return !!of_match_device(drv->of_match_table, dev); 42 42 }
+1 -1
drivers/gpu/drm/drm_mipi_dsi.c
··· 48 48 * subset of the MIPI DCS command set. 49 49 */ 50 50 51 - static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv) 51 + static int mipi_dsi_device_match(struct device *dev, const struct device_driver *drv) 52 52 { 53 53 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); 54 54
+2 -5
drivers/gpu/drm/imagination/pvr_drv.c
··· 1451 1451 return err; 1452 1452 } 1453 1453 1454 - static int 1455 - pvr_remove(struct platform_device *plat_dev) 1454 + static void pvr_remove(struct platform_device *plat_dev) 1456 1455 { 1457 1456 struct drm_device *drm_dev = platform_get_drvdata(plat_dev); 1458 1457 struct pvr_device *pvr_dev = to_pvr_device(drm_dev); ··· 1468 1469 pvr_watchdog_fini(pvr_dev); 1469 1470 pvr_queue_device_fini(pvr_dev); 1470 1471 pvr_context_device_fini(pvr_dev); 1471 - 1472 - return 0; 1473 1472 } 1474 1473 1475 1474 static const struct of_device_id dt_match[] = { ··· 1482 1485 1483 1486 static struct platform_driver pvr_driver = { 1484 1487 .probe = pvr_probe, 1485 - .remove = pvr_remove, 1488 + .remove_new = pvr_remove, 1486 1489 .driver = { 1487 1490 .name = PVR_DRIVER_NAME, 1488 1491 .pm = &pvr_pm_ops,
+1 -3
drivers/gpu/drm/stm/lvds.c
··· 1186 1186 return ret; 1187 1187 } 1188 1188 1189 - static int lvds_remove(struct platform_device *pdev) 1189 + static void lvds_remove(struct platform_device *pdev) 1190 1190 { 1191 1191 struct stm_lvds *lvds = platform_get_drvdata(pdev); 1192 1192 1193 1193 lvds_pixel_clk_unregister(lvds); 1194 1194 1195 1195 drm_bridge_remove(&lvds->lvds_bridge); 1196 - 1197 - return 0; 1198 1196 } 1199 1197 1200 1198 static const struct of_device_id lvds_dt_ids[] = {
+1 -1
drivers/gpu/host1x/bus.c
··· 333 333 return -ENODEV; 334 334 } 335 335 336 - static int host1x_device_match(struct device *dev, struct device_driver *drv) 336 + static int host1x_device_match(struct device *dev, const struct device_driver *drv) 337 337 { 338 338 return strcmp(dev_name(dev), drv->name) == 0; 339 339 }
+2 -4
drivers/gpu/host1x/dev.c
··· 677 677 return err; 678 678 } 679 679 680 - static int host1x_remove(struct platform_device *pdev) 680 + static void host1x_remove(struct platform_device *pdev) 681 681 { 682 682 struct host1x *host = platform_get_drvdata(pdev); 683 683 ··· 692 692 host1x_channel_list_free(&host->channel_list); 693 693 host1x_iommu_exit(host); 694 694 host1x_bo_cache_destroy(&host->cache); 695 - 696 - return 0; 697 695 } 698 696 699 697 static int __maybe_unused host1x_runtime_suspend(struct device *dev) ··· 776 778 .pm = &host1x_pm_ops, 777 779 }, 778 780 .probe = host1x_probe, 779 - .remove = host1x_remove, 781 + .remove_new = host1x_remove, 780 782 }; 781 783 782 784 static struct platform_driver * const drivers[] = {
+1 -16
drivers/gpu/host1x/mipi.c
··· 501 501 { 502 502 const struct of_device_id *match; 503 503 struct tegra_mipi *mipi; 504 - int err; 505 504 506 505 match = of_match_node(tegra_mipi_of_match, pdev->dev.of_node); 507 506 if (!match) ··· 519 520 520 521 mutex_init(&mipi->lock); 521 522 522 - mipi->clk = devm_clk_get(&pdev->dev, NULL); 523 + mipi->clk = devm_clk_get_prepared(&pdev->dev, NULL); 523 524 if (IS_ERR(mipi->clk)) { 524 525 dev_err(&pdev->dev, "failed to get clock\n"); 525 526 return PTR_ERR(mipi->clk); 526 527 } 527 528 528 - err = clk_prepare(mipi->clk); 529 - if (err < 0) 530 - return err; 531 - 532 529 platform_set_drvdata(pdev, mipi); 533 - 534 - return 0; 535 - } 536 - 537 - static int tegra_mipi_remove(struct platform_device *pdev) 538 - { 539 - struct tegra_mipi *mipi = platform_get_drvdata(pdev); 540 - 541 - clk_unprepare(mipi->clk); 542 530 543 531 return 0; 544 532 } ··· 536 550 .of_match_table = tegra_mipi_of_match, 537 551 }, 538 552 .probe = tegra_mipi_probe, 539 - .remove = tegra_mipi_remove, 540 553 };
+2 -4
drivers/gpu/ipu-v3/ipu-common.c
··· 1450 1450 return ret; 1451 1451 } 1452 1452 1453 - static int ipu_remove(struct platform_device *pdev) 1453 + static void ipu_remove(struct platform_device *pdev) 1454 1454 { 1455 1455 struct ipu_soc *ipu = platform_get_drvdata(pdev); 1456 1456 ··· 1459 1459 ipu_irq_exit(ipu); 1460 1460 1461 1461 clk_disable_unprepare(ipu->clk); 1462 - 1463 - return 0; 1464 1462 } 1465 1463 1466 1464 static struct platform_driver imx_ipu_driver = { ··· 1467 1469 .of_match_table = imx_ipu_dt_ids, 1468 1470 }, 1469 1471 .probe = ipu_probe, 1470 - .remove = ipu_remove, 1472 + .remove_new = ipu_remove, 1471 1473 }; 1472 1474 1473 1475 static struct platform_driver * const drivers[] = {
+2 -3
drivers/gpu/ipu-v3/ipu-pre.c
··· 351 351 return 0; 352 352 } 353 353 354 - static int ipu_pre_remove(struct platform_device *pdev) 354 + static void ipu_pre_remove(struct platform_device *pdev) 355 355 { 356 356 struct ipu_pre *pre = platform_get_drvdata(pdev); 357 357 ··· 365 365 if (pre->buffer_virt) 366 366 gen_pool_free(pre->iram, (unsigned long)pre->buffer_virt, 367 367 IPU_PRE_MAX_WIDTH * IPU_PRE_NUM_SCANLINES * 4); 368 - return 0; 369 368 } 370 369 371 370 static const struct of_device_id ipu_pre_dt_ids[] = { ··· 374 375 375 376 struct platform_driver ipu_pre_drv = { 376 377 .probe = ipu_pre_probe, 377 - .remove = ipu_pre_remove, 378 + .remove_new = ipu_pre_remove, 378 379 .driver = { 379 380 .name = "imx-ipu-pre", 380 381 .of_match_table = ipu_pre_dt_ids,
+2 -4
drivers/gpu/ipu-v3/ipu-prg.c
··· 419 419 return 0; 420 420 } 421 421 422 - static int ipu_prg_remove(struct platform_device *pdev) 422 + static void ipu_prg_remove(struct platform_device *pdev) 423 423 { 424 424 struct ipu_prg *prg = platform_get_drvdata(pdev); 425 425 426 426 mutex_lock(&ipu_prg_list_mutex); 427 427 list_del(&prg->list); 428 428 mutex_unlock(&ipu_prg_list_mutex); 429 - 430 - return 0; 431 429 } 432 430 433 431 #ifdef CONFIG_PM ··· 469 471 470 472 struct platform_driver ipu_prg_drv = { 471 473 .probe = ipu_prg_probe, 472 - .remove = ipu_prg_remove, 474 + .remove_new = ipu_prg_remove, 473 475 .driver = { 474 476 .name = "imx-ipu-prg", 475 477 .pm = &prg_pm_ops,
+2 -2
drivers/greybus/core.c
··· 90 90 return NULL; 91 91 } 92 92 93 - static int greybus_match_device(struct device *dev, struct device_driver *drv) 93 + static int greybus_match_device(struct device *dev, const struct device_driver *drv) 94 94 { 95 - struct greybus_driver *driver = to_greybus_driver(drv); 95 + const struct greybus_driver *driver = to_greybus_driver(drv); 96 96 struct gb_bundle *bundle; 97 97 const struct greybus_bundle_id *id; 98 98
+1 -1
drivers/hid/hid-core.c
··· 2604 2604 } 2605 2605 EXPORT_SYMBOL_GPL(hid_match_device); 2606 2606 2607 - static int hid_bus_match(struct device *dev, struct device_driver *drv) 2607 + static int hid_bus_match(struct device *dev, const struct device_driver *drv) 2608 2608 { 2609 2609 struct hid_driver *hdrv = to_hid_driver(drv); 2610 2610 struct hid_device *hdev = to_hid_device(dev);
+1 -1
drivers/hid/intel-ish-hid/ishtp/bus.c
··· 236 236 * 237 237 * Return: 1 if dev & drv matches, 0 otherwise. 238 238 */ 239 - static int ishtp_cl_bus_match(struct device *dev, struct device_driver *drv) 239 + static int ishtp_cl_bus_match(struct device *dev, const struct device_driver *drv) 240 240 { 241 241 struct ishtp_cl_device *device = to_ishtp_cl_device(dev); 242 242 struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv);
+1 -1
drivers/hsi/hsi_core.c
··· 37 37 return 0; 38 38 } 39 39 40 - static int hsi_bus_match(struct device *dev, struct device_driver *driver) 40 + static int hsi_bus_match(struct device *dev, const struct device_driver *driver) 41 41 { 42 42 if (of_driver_match_device(dev, driver)) 43 43 return true;
+4 -4
drivers/hv/vmbus_drv.c
··· 685 685 * Return a matching hv_vmbus_device_id pointer. 686 686 * If there is no match, return NULL. 687 687 */ 688 - static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv, 688 + static const struct hv_vmbus_device_id *hv_vmbus_get_id(const struct hv_driver *drv, 689 689 struct hv_device *dev) 690 690 { 691 691 const guid_t *guid = &dev->dev_type; ··· 696 696 return NULL; 697 697 698 698 /* Look at the dynamic ids first, before the static ones */ 699 - id = hv_vmbus_dynid_match(drv, guid); 699 + id = hv_vmbus_dynid_match((struct hv_driver *)drv, guid); 700 700 if (!id) 701 701 id = hv_vmbus_dev_match(drv->id_table, guid); 702 702 ··· 809 809 /* 810 810 * vmbus_match - Attempt to match the specified device to the specified driver 811 811 */ 812 - static int vmbus_match(struct device *device, struct device_driver *driver) 812 + static int vmbus_match(struct device *device, const struct device_driver *driver) 813 813 { 814 - struct hv_driver *drv = drv_to_hv_drv(driver); 814 + const struct hv_driver *drv = drv_to_hv_drv(driver); 815 815 struct hv_device *hv_dev = device_to_hv_device(device); 816 816 817 817 /* The hv_sock driver handles all hv_sock offers. */
+2 -2
drivers/hwtracing/intel_th/core.c
··· 26 26 27 27 static DEFINE_IDA(intel_th_ida); 28 28 29 - static int intel_th_match(struct device *dev, struct device_driver *driver) 29 + static int intel_th_match(struct device *dev, const struct device_driver *driver) 30 30 { 31 - struct intel_th_driver *thdrv = to_intel_th_driver(driver); 31 + const struct intel_th_driver *thdrv = to_intel_th_driver(driver); 32 32 struct intel_th_device *thdev = to_intel_th_device(dev); 33 33 34 34 if (thdev->type == INTEL_TH_SWITCH &&
+1 -1
drivers/hwtracing/intel_th/intel_th.h
··· 189 189 }; 190 190 191 191 #define to_intel_th_driver(_d) \ 192 - container_of((_d), struct intel_th_driver, driver) 192 + container_of_const((_d), struct intel_th_driver, driver) 193 193 194 194 #define to_intel_th_driver_or_null(_d) \ 195 195 ((_d) ? to_intel_th_driver(_d) : NULL)
+2 -2
drivers/i2c/i2c-core-base.c
··· 136 136 } 137 137 EXPORT_SYMBOL(i2c_get_match_data); 138 138 139 - static int i2c_device_match(struct device *dev, struct device_driver *drv) 139 + static int i2c_device_match(struct device *dev, const struct device_driver *drv) 140 140 { 141 141 struct i2c_client *client = i2c_verify_client(dev); 142 - struct i2c_driver *driver; 142 + const struct i2c_driver *driver; 143 143 144 144 145 145 /* Attempt an OF style match */
+2 -2
drivers/i3c/master.c
··· 301 301 .uevent = i3c_device_uevent, 302 302 }; 303 303 304 - static int i3c_device_match(struct device *dev, struct device_driver *drv) 304 + static int i3c_device_match(struct device *dev, const struct device_driver *drv) 305 305 { 306 306 struct i3c_device *i3cdev; 307 - struct i3c_driver *i3cdrv; 307 + const struct i3c_driver *i3cdrv; 308 308 309 309 if (dev->type != &i3c_device_type) 310 310 return 0;
+2 -2
drivers/input/gameport/gameport.c
··· 806 806 } 807 807 EXPORT_SYMBOL(gameport_unregister_driver); 808 808 809 - static int gameport_bus_match(struct device *dev, struct device_driver *drv) 809 + static int gameport_bus_match(struct device *dev, const struct device_driver *drv) 810 810 { 811 - struct gameport_driver *gameport_drv = to_gameport_driver(drv); 811 + const struct gameport_driver *gameport_drv = to_gameport_driver(drv); 812 812 813 813 return !gameport_drv->ignore; 814 814 }
+3 -3
drivers/input/rmi4/rmi_bus.c
··· 144 144 return dev->type == &rmi_function_type; 145 145 } 146 146 147 - static int rmi_function_match(struct device *dev, struct device_driver *drv) 147 + static int rmi_function_match(struct device *dev, const struct device_driver *drv) 148 148 { 149 - struct rmi_function_handler *handler = to_rmi_function_handler(drv); 149 + const struct rmi_function_handler *handler = to_rmi_function_handler(drv); 150 150 struct rmi_function *fn = to_rmi_function(dev); 151 151 152 152 return fn->fd.function_number == handler->func; ··· 333 333 334 334 /* Bus specific stuff */ 335 335 336 - static int rmi_bus_match(struct device *dev, struct device_driver *drv) 336 + static int rmi_bus_match(struct device *dev, const struct device_driver *drv) 337 337 { 338 338 bool physical = rmi_is_physical_device(dev); 339 339
+1 -1
drivers/input/rmi4/rmi_bus.h
··· 87 87 }; 88 88 89 89 #define to_rmi_function_handler(d) \ 90 - container_of(d, struct rmi_function_handler, driver) 90 + container_of_const(d, struct rmi_function_handler, driver) 91 91 92 92 int __must_check __rmi_register_function_handler(struct rmi_function_handler *, 93 93 struct module *, const char *);
+1 -1
drivers/input/rmi4/rmi_driver.c
··· 1258 1258 .set_input_params = rmi_driver_set_input_params, 1259 1259 }; 1260 1260 1261 - bool rmi_is_physical_driver(struct device_driver *drv) 1261 + bool rmi_is_physical_driver(const struct device_driver *drv) 1262 1262 { 1263 1263 return drv == &rmi_physical_driver.driver; 1264 1264 }
+1 -1
drivers/input/rmi4/rmi_driver.h
··· 84 84 bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item *item, 85 85 u8 subpacket); 86 86 87 - bool rmi_is_physical_driver(struct device_driver *); 87 + bool rmi_is_physical_driver(const struct device_driver *); 88 88 int rmi_register_physical_driver(void); 89 89 void rmi_unregister_physical_driver(void); 90 90 void rmi_free_function_list(struct rmi_device *rmi_dev);
+2 -2
drivers/input/serio/serio.c
··· 877 877 serio_continue_rx(serio); 878 878 } 879 879 880 - static int serio_bus_match(struct device *dev, struct device_driver *drv) 880 + static int serio_bus_match(struct device *dev, const struct device_driver *drv) 881 881 { 882 882 struct serio *serio = to_serio_port(dev); 883 - struct serio_driver *serio_drv = to_serio_driver(drv); 883 + const struct serio_driver *serio_drv = to_serio_driver(drv); 884 884 885 885 if (serio->manual_bind || serio_drv->manual_bind) 886 886 return 0;
+3 -3
drivers/ipack/ipack.c
··· 13 13 #include <linux/ipack.h> 14 14 15 15 #define to_ipack_dev(device) container_of(device, struct ipack_device, dev) 16 - #define to_ipack_driver(drv) container_of(drv, struct ipack_driver, driver) 16 + #define to_ipack_driver(drv) container_of_const(drv, struct ipack_driver, driver) 17 17 18 18 static DEFINE_IDA(ipack_ida); 19 19 ··· 49 49 return NULL; 50 50 } 51 51 52 - static int ipack_bus_match(struct device *dev, struct device_driver *drv) 52 + static int ipack_bus_match(struct device *dev, const struct device_driver *drv) 53 53 { 54 54 struct ipack_device *idev = to_ipack_dev(dev); 55 - struct ipack_driver *idrv = to_ipack_driver(drv); 55 + const struct ipack_driver *idrv = to_ipack_driver(drv); 56 56 const struct ipack_device_id *found_id; 57 57 58 58 found_id = ipack_match_id(idrv->id_table, idev);
+1 -1
drivers/macintosh/macio_asic.c
··· 36 36 37 37 static struct macio_chip *macio_on_hold; 38 38 39 - static int macio_bus_match(struct device *dev, struct device_driver *drv) 39 + static int macio_bus_match(struct device *dev, const struct device_driver *drv) 40 40 { 41 41 const struct of_device_id * matches = drv->of_match_table; 42 42
+2 -2
drivers/mcb/mcb-core.c
··· 28 28 return NULL; 29 29 } 30 30 31 - static int mcb_match(struct device *dev, struct device_driver *drv) 31 + static int mcb_match(struct device *dev, const struct device_driver *drv) 32 32 { 33 - struct mcb_driver *mdrv = to_mcb_driver(drv); 33 + const struct mcb_driver *mdrv = to_mcb_driver(drv); 34 34 struct mcb_device *mdev = to_mcb_device(dev); 35 35 const struct mcb_device_id *found_id; 36 36
+2 -2
drivers/media/pci/bt8xx/bttv-gpio.c
··· 28 28 /* ----------------------------------------------------------------------- */ 29 29 /* internal: the bttv "bus" */ 30 30 31 - static int bttv_sub_bus_match(struct device *dev, struct device_driver *drv) 31 + static int bttv_sub_bus_match(struct device *dev, const struct device_driver *drv) 32 32 { 33 - struct bttv_sub_driver *sub = to_bttv_sub_drv(drv); 33 + const struct bttv_sub_driver *sub = to_bttv_sub_drv(drv); 34 34 int len = strlen(sub->wanted); 35 35 36 36 if (0 == strncmp(dev_name(dev), sub->wanted, len))
+1 -1
drivers/media/pci/bt8xx/bttv.h
··· 341 341 int (*probe)(struct bttv_sub_device *sub); 342 342 void (*remove)(struct bttv_sub_device *sub); 343 343 }; 344 - #define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv) 344 + #define to_bttv_sub_drv(x) container_of_const((x), struct bttv_sub_driver, drv) 345 345 346 346 int bttv_sub_register(struct bttv_sub_driver *drv, char *wanted); 347 347 int bttv_sub_unregister(struct bttv_sub_driver *drv);
+1 -1
drivers/media/pci/intel/ipu6/ipu6-bus.h
··· 21 21 22 22 struct ipu6_bus_device { 23 23 struct auxiliary_device auxdev; 24 - struct auxiliary_driver *auxdrv; 24 + const struct auxiliary_driver *auxdrv; 25 25 const struct ipu6_auxdrv_data *auxdrv_data; 26 26 struct list_head list; 27 27 void *pdata;
+3 -4
drivers/memstick/core/memstick.c
··· 38 38 return 0; 39 39 } 40 40 41 - static int memstick_bus_match(struct device *dev, struct device_driver *drv) 41 + static int memstick_bus_match(struct device *dev, const struct device_driver *drv) 42 42 { 43 43 struct memstick_dev *card = container_of(dev, struct memstick_dev, 44 44 dev); 45 - struct memstick_driver *ms_drv = container_of(drv, 46 - struct memstick_driver, 47 - driver); 45 + const struct memstick_driver *ms_drv = container_of_const(drv, struct memstick_driver, 46 + driver); 48 47 struct memstick_device_id *ids = ms_drv->id_table; 49 48 50 49 if (ids) {
+1 -1
drivers/mfd/mcp-core.c
··· 20 20 #define to_mcp(d) container_of(d, struct mcp, attached_device) 21 21 #define to_mcp_driver(d) container_of(d, struct mcp_driver, drv) 22 22 23 - static int mcp_bus_match(struct device *dev, struct device_driver *drv) 23 + static int mcp_bus_match(struct device *dev, const struct device_driver *drv) 24 24 { 25 25 return 1; 26 26 }
+2 -2
drivers/misc/mei/bus.c
··· 19 19 #include "mei_dev.h" 20 20 #include "client.h" 21 21 22 - #define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver) 22 + #define to_mei_cl_driver(d) container_of_const(d, struct mei_cl_driver, driver) 23 23 24 24 /** 25 25 * __mei_cl_send - internal client send (write) ··· 1124 1124 * 1125 1125 * Return: 1 if matching device was found 0 otherwise 1126 1126 */ 1127 - static int mei_cl_device_match(struct device *dev, struct device_driver *drv) 1127 + static int mei_cl_device_match(struct device *dev, const struct device_driver *drv) 1128 1128 { 1129 1129 const struct mei_cl_device *cldev = to_mei_cl_device(dev); 1130 1130 const struct mei_cl_driver *cldrv = to_mei_cl_driver(drv);
+3 -3
drivers/misc/tifm_core.c
··· 38 38 return 0; 39 39 } 40 40 41 - static int tifm_bus_match(struct device *dev, struct device_driver *drv) 41 + static int tifm_bus_match(struct device *dev, const struct device_driver *drv) 42 42 { 43 43 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev); 44 - struct tifm_driver *fm_drv = container_of(drv, struct tifm_driver, 45 - driver); 44 + const struct tifm_driver *fm_drv = container_of_const(drv, struct tifm_driver, 45 + driver); 46 46 struct tifm_device_id *ids = fm_drv->id_table; 47 47 48 48 if (ids) {
+5 -5
drivers/mmc/core/sdio_bus.c
··· 26 26 #include "sdio_cis.h" 27 27 #include "sdio_bus.h" 28 28 29 - #define to_sdio_driver(d) container_of(d, struct sdio_driver, drv) 29 + #define to_sdio_driver(d) container_of_const(d, struct sdio_driver, drv) 30 30 31 31 /* show configuration fields */ 32 32 #define sdio_config_attr(field, format_string, args...) \ ··· 91 91 } 92 92 93 93 static const struct sdio_device_id *sdio_match_device(struct sdio_func *func, 94 - struct sdio_driver *sdrv) 94 + const struct sdio_driver *sdrv) 95 95 { 96 96 const struct sdio_device_id *ids; 97 97 ··· 108 108 return NULL; 109 109 } 110 110 111 - static int sdio_bus_match(struct device *dev, struct device_driver *drv) 111 + static int sdio_bus_match(struct device *dev, const struct device_driver *drv) 112 112 { 113 113 struct sdio_func *func = dev_to_sdio_func(dev); 114 - struct sdio_driver *sdrv = to_sdio_driver(drv); 114 + const struct sdio_driver *sdrv = to_sdio_driver(drv); 115 115 116 116 if (sdio_match_device(func, sdrv)) 117 117 return 1; ··· 129 129 "SDIO_CLASS=%02X", func->class)) 130 130 return -ENOMEM; 131 131 132 - if (add_uevent_var(env, 132 + if (add_uevent_var(env, 133 133 "SDIO_ID=%04X:%04X", func->vendor, func->device)) 134 134 return -ENOMEM; 135 135
+1 -1
drivers/most/core.c
··· 491 491 return 0; 492 492 } 493 493 494 - static int most_match(struct device *dev, struct device_driver *drv) 494 + static int most_match(struct device *dev, const struct device_driver *drv) 495 495 { 496 496 if (!strcmp(dev_name(dev), "most")) 497 497 return 0;
+2 -2
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
··· 239 239 240 240 adev = &aux_priv->aux_dev; 241 241 if (adev->dev.driver) { 242 - struct auxiliary_driver *adrv; 242 + const struct auxiliary_driver *adrv; 243 243 pm_message_t pm = {}; 244 244 245 245 adrv = to_auxiliary_drv(adev->dev.driver); ··· 277 277 278 278 adev = &aux_priv->aux_dev; 279 279 if (adev->dev.driver) { 280 - struct auxiliary_driver *adrv; 280 + const struct auxiliary_driver *adrv; 281 281 282 282 adrv = to_auxiliary_drv(adev->dev.driver); 283 283 edev->en_state = bp->state;
+1 -1
drivers/net/ethernet/intel/ice/ice_ptp.c
··· 2915 2915 ice_ptp_aux_dev_to_owner_pf(struct auxiliary_device *aux_dev) 2916 2916 { 2917 2917 struct ice_ptp_port_owner *ports_owner; 2918 - struct auxiliary_driver *aux_drv; 2918 + const struct auxiliary_driver *aux_drv; 2919 2919 struct ice_ptp *owner_ptp; 2920 2920 2921 2921 if (!aux_dev->dev.driver)
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/dev.c
··· 349 349 { 350 350 struct mlx5_priv *priv = &dev->priv; 351 351 struct auxiliary_device *adev; 352 - struct auxiliary_driver *adrv; 352 + const struct auxiliary_driver *adrv; 353 353 int ret = 0, i; 354 354 355 355 devl_assert_locked(priv_to_devlink(dev)); ··· 406 406 { 407 407 struct mlx5_priv *priv = &dev->priv; 408 408 struct auxiliary_device *adev; 409 - struct auxiliary_driver *adrv; 409 + const struct auxiliary_driver *adrv; 410 410 pm_message_t pm = {}; 411 411 int i; 412 412
+1 -3
drivers/net/ethernet/renesas/rtsn.c
··· 1358 1358 return ret; 1359 1359 } 1360 1360 1361 - static int rtsn_remove(struct platform_device *pdev) 1361 + static void rtsn_remove(struct platform_device *pdev) 1362 1362 { 1363 1363 struct rtsn_private *priv = platform_get_drvdata(pdev); 1364 1364 ··· 1372 1372 pm_runtime_disable(&pdev->dev); 1373 1373 1374 1374 free_netdev(priv->ndev); 1375 - 1376 - return 0; 1377 1375 } 1378 1376 1379 1377 static struct platform_driver rtsn_driver = {
+2 -2
drivers/net/phy/mdio_bus.c
··· 1375 1375 * require calling the devices own match function, since different classes 1376 1376 * of MDIO devices have different match criteria. 1377 1377 */ 1378 - static int mdio_bus_match(struct device *dev, struct device_driver *drv) 1378 + static int mdio_bus_match(struct device *dev, const struct device_driver *drv) 1379 1379 { 1380 - struct mdio_driver *mdiodrv = to_mdio_driver(drv); 1380 + const struct mdio_driver *mdiodrv = to_mdio_driver(drv); 1381 1381 struct mdio_device *mdio = to_mdio_device(dev); 1382 1382 1383 1383 /* Both the driver and device must type-match */
+2 -2
drivers/net/phy/mdio_device.c
··· 35 35 kfree(to_mdio_device(dev)); 36 36 } 37 37 38 - int mdio_device_bus_match(struct device *dev, struct device_driver *drv) 38 + int mdio_device_bus_match(struct device *dev, const struct device_driver *drv) 39 39 { 40 40 struct mdio_device *mdiodev = to_mdio_device(dev); 41 - struct mdio_driver *mdiodrv = to_mdio_driver(drv); 41 + const struct mdio_driver *mdiodrv = to_mdio_driver(drv); 42 42 43 43 if (mdiodrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY) 44 44 return 0;
+2 -2
drivers/net/phy/phy_device.c
··· 533 533 return 0; 534 534 } 535 535 536 - static int phy_bus_match(struct device *dev, struct device_driver *drv) 536 + static int phy_bus_match(struct device *dev, const struct device_driver *drv) 537 537 { 538 538 struct phy_device *phydev = to_phy_device(dev); 539 - struct phy_driver *phydrv = to_phy_driver(drv); 539 + const struct phy_driver *phydrv = to_phy_driver(drv); 540 540 const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); 541 541 int i; 542 542
+1 -1
drivers/ntb/ntb_transport.c
··· 284 284 285 285 286 286 static int ntb_transport_bus_match(struct device *dev, 287 - struct device_driver *drv) 287 + const struct device_driver *drv) 288 288 { 289 289 return !strncmp(dev_name(dev), drv->name, strlen(drv->name)); 290 290 }
+13 -12
drivers/nvdimm/bus.c
··· 25 25 26 26 int nvdimm_major; 27 27 static int nvdimm_bus_major; 28 - static struct class *nd_class; 29 28 static DEFINE_IDA(nd_ida); 29 + 30 + static const struct class nd_class = { 31 + .name = "nd", 32 + }; 30 33 31 34 static int to_nd_device_type(const struct device *dev) 32 35 { ··· 272 269 } 273 270 EXPORT_SYMBOL_GPL(nvdimm_clear_poison); 274 271 275 - static int nvdimm_bus_match(struct device *dev, struct device_driver *drv); 272 + static int nvdimm_bus_match(struct device *dev, const struct device_driver *drv); 276 273 277 274 static const struct bus_type nvdimm_bus_type = { 278 275 .name = "nd", ··· 468 465 }, 469 466 }; 470 467 471 - static int nvdimm_bus_match(struct device *dev, struct device_driver *drv) 468 + static int nvdimm_bus_match(struct device *dev, const struct device_driver *drv) 472 469 { 473 - struct nd_device_driver *nd_drv = to_nd_device_driver(drv); 470 + const struct nd_device_driver *nd_drv = to_nd_device_driver(drv); 474 471 475 472 if (is_nvdimm_bus(dev) && nd_drv == &nd_bus_driver) 476 473 return true; ··· 745 742 device_initialize(dev); 746 743 lockdep_set_class(&dev->mutex, &nvdimm_ndctl_key); 747 744 device_set_pm_not_required(dev); 748 - dev->class = nd_class; 745 + dev->class = &nd_class; 749 746 dev->parent = &nvdimm_bus->dev; 750 747 dev->devt = devt; 751 748 dev->release = ndctl_release; ··· 768 765 769 766 void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus) 770 767 { 771 - device_destroy(nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); 768 + device_destroy(&nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); 772 769 } 773 770 774 771 static const struct nd_cmd_desc __nd_cmd_dimm_descs[] = { ··· 1323 1320 goto err_dimm_chrdev; 1324 1321 nvdimm_major = rc; 1325 1322 1326 - nd_class = class_create("nd"); 1327 - if (IS_ERR(nd_class)) { 1328 - rc = PTR_ERR(nd_class); 1323 + rc = class_register(&nd_class); 1324 + if (rc) 1329 1325 goto err_class; 1330 - } 1331 1326 1332 1327 rc = driver_register(&nd_bus_driver.drv); 1333 1328 if (rc) ··· 1334 1333 return 0; 1335 1334 1336 1335 err_nd_bus: 1337 - class_destroy(nd_class); 1336 + class_unregister(&nd_class); 1338 1337 err_class: 1339 1338 unregister_chrdev(nvdimm_major, "dimmctl"); 1340 1339 err_dimm_chrdev: ··· 1348 1347 void nvdimm_bus_exit(void) 1349 1348 { 1350 1349 driver_unregister(&nd_bus_driver.drv); 1351 - class_destroy(nd_class); 1350 + class_unregister(&nd_class); 1352 1351 unregister_chrdev(nvdimm_bus_major, "ndctl"); 1353 1352 unregister_chrdev(nvdimm_major, "dimmctl"); 1354 1353 bus_unregister(&nvdimm_bus_type);
+2 -3
drivers/nvdimm/e820.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/numa.h> 11 11 12 - static int e820_pmem_remove(struct platform_device *pdev) 12 + static void e820_pmem_remove(struct platform_device *pdev) 13 13 { 14 14 struct nvdimm_bus *nvdimm_bus = platform_get_drvdata(pdev); 15 15 16 16 nvdimm_bus_unregister(nvdimm_bus); 17 - return 0; 18 17 } 19 18 20 19 static int e820_register_one(struct resource *res, void *data) ··· 59 60 60 61 static struct platform_driver e820_pmem_driver = { 61 62 .probe = e820_pmem_probe, 62 - .remove = e820_pmem_remove, 63 + .remove_new = e820_pmem_remove, 63 64 .driver = { 64 65 .name = "e820_pmem", 65 66 },
+2 -4
drivers/nvdimm/of_pmem.c
··· 84 84 return 0; 85 85 } 86 86 87 - static int of_pmem_region_remove(struct platform_device *pdev) 87 + static void of_pmem_region_remove(struct platform_device *pdev) 88 88 { 89 89 struct of_pmem_private *priv = platform_get_drvdata(pdev); 90 90 91 91 nvdimm_bus_unregister(priv->bus); 92 92 kfree(priv); 93 - 94 - return 0; 95 93 } 96 94 97 95 static const struct of_device_id of_pmem_region_match[] = { ··· 100 102 101 103 static struct platform_driver of_pmem_region_driver = { 102 104 .probe = of_pmem_region_probe, 103 - .remove = of_pmem_region_remove, 105 + .remove_new = of_pmem_region_remove, 104 106 .driver = { 105 107 .name = "of_pmem", 106 108 .of_match_table = of_pmem_region_match,
+2 -2
drivers/nvmem/layouts.c
··· 17 17 #include "internals.h" 18 18 19 19 #define to_nvmem_layout_driver(drv) \ 20 - (container_of((drv), struct nvmem_layout_driver, driver)) 20 + (container_of_const((drv), struct nvmem_layout_driver, driver)) 21 21 #define to_nvmem_layout_device(_dev) \ 22 22 container_of((_dev), struct nvmem_layout, dev) 23 23 24 - static int nvmem_layout_bus_match(struct device *dev, struct device_driver *drv) 24 + static int nvmem_layout_bus_match(struct device *dev, const struct device_driver *drv) 25 25 { 26 26 return of_driver_match_device(dev, drv); 27 27 }
+1 -1
drivers/parport/share.c
··· 128 128 return drv->probe(to_pardevice(dev)); 129 129 } 130 130 131 - static struct bus_type parport_bus_type = { 131 + static const struct bus_type parport_bus_type = { 132 132 .name = "parport", 133 133 .probe = parport_probe, 134 134 };
+2 -2
drivers/pci/endpoint/pci-epf-core.c
··· 488 488 return NULL; 489 489 } 490 490 491 - static int pci_epf_device_match(struct device *dev, struct device_driver *drv) 491 + static int pci_epf_device_match(struct device *dev, const struct device_driver *drv) 492 492 { 493 493 struct pci_epf *epf = to_pci_epf(dev); 494 - struct pci_epf_driver *driver = to_pci_epf_driver(drv); 494 + const struct pci_epf_driver *driver = to_pci_epf_driver(drv); 495 495 496 496 if (driver->id_table) 497 497 return !!pci_epf_match_id(driver->id_table, epf);
+4 -4
drivers/pci/pci-driver.c
··· 1503 1503 * system is in its list of supported devices. Returns the matching 1504 1504 * pci_device_id structure or %NULL if there is no match. 1505 1505 */ 1506 - static int pci_bus_match(struct device *dev, struct device_driver *drv) 1506 + static int pci_bus_match(struct device *dev, const struct device_driver *drv) 1507 1507 { 1508 1508 struct pci_dev *pci_dev = to_pci_dev(dev); 1509 1509 struct pci_driver *pci_drv; ··· 1512 1512 if (!pci_dev->match_driver) 1513 1513 return 0; 1514 1514 1515 - pci_drv = to_pci_driver(drv); 1515 + pci_drv = (struct pci_driver *)to_pci_driver(drv); 1516 1516 found_id = pci_match_device(pci_drv, pci_dev); 1517 1517 if (found_id) 1518 1518 return 1; ··· 1688 1688 EXPORT_SYMBOL(pci_bus_type); 1689 1689 1690 1690 #ifdef CONFIG_PCIEPORTBUS 1691 - static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) 1691 + static int pcie_port_bus_match(struct device *dev, const struct device_driver *drv) 1692 1692 { 1693 1693 struct pcie_device *pciedev; 1694 - struct pcie_port_service_driver *driver; 1694 + const struct pcie_port_service_driver *driver; 1695 1695 1696 1696 if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type) 1697 1697 return 0;
+1 -1
drivers/pcmcia/ds.c
··· 900 900 } 901 901 902 902 903 - static int pcmcia_bus_match(struct device *dev, struct device_driver *drv) 903 + static int pcmcia_bus_match(struct device *dev, const struct device_driver *drv) 904 904 { 905 905 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 906 906 struct pcmcia_driver *p_drv = to_pcmcia_drv(drv);
+2 -2
drivers/peci/core.c
··· 172 172 return NULL; 173 173 } 174 174 175 - static int peci_bus_device_match(struct device *dev, struct device_driver *drv) 175 + static int peci_bus_device_match(struct device *dev, const struct device_driver *drv) 176 176 { 177 177 struct peci_device *device = to_peci_device(dev); 178 - struct peci_driver *peci_drv = to_peci_driver(drv); 178 + const struct peci_driver *peci_drv = to_peci_driver(drv); 179 179 180 180 if (dev->type != &peci_device_type) 181 181 return 0;
+1 -4
drivers/peci/internal.h
··· 96 96 const struct peci_device_id *id_table; 97 97 }; 98 98 99 - static inline struct peci_driver *to_peci_driver(struct device_driver *d) 100 - { 101 - return container_of(d, struct peci_driver, driver); 102 - } 99 + #define to_peci_driver(__drv) container_of_const(__drv, struct peci_driver, driver) 103 100 104 101 int __peci_driver_register(struct peci_driver *driver, struct module *owner, 105 102 const char *mod_name);
+2 -2
drivers/platform/surface/aggregator/bus.c
··· 306 306 } 307 307 EXPORT_SYMBOL_GPL(ssam_device_get_match_data); 308 308 309 - static int ssam_bus_match(struct device *dev, struct device_driver *drv) 309 + static int ssam_bus_match(struct device *dev, const struct device_driver *drv) 310 310 { 311 - struct ssam_device_driver *sdrv = to_ssam_device_driver(drv); 311 + const struct ssam_device_driver *sdrv = to_ssam_device_driver(drv); 312 312 struct ssam_device *sdev = to_ssam_device(dev); 313 313 314 314 if (!is_ssam_device(dev))
+3 -6
drivers/platform/x86/wmi.c
··· 727 727 } 728 728 EXPORT_SYMBOL_GPL(wmi_get_acpi_device_uid); 729 729 730 - static inline struct wmi_driver *drv_to_wdrv(struct device_driver *drv) 731 - { 732 - return container_of(drv, struct wmi_driver, driver); 733 - } 730 + #define drv_to_wdrv(__drv) container_of_const(__drv, struct wmi_driver, driver) 734 731 735 732 /* 736 733 * sysfs interface ··· 874 877 kfree(wblock); 875 878 } 876 879 877 - static int wmi_dev_match(struct device *dev, struct device_driver *driver) 880 + static int wmi_dev_match(struct device *dev, const struct device_driver *driver) 878 881 { 879 - struct wmi_driver *wmi_driver = drv_to_wdrv(driver); 882 + const struct wmi_driver *wmi_driver = drv_to_wdrv(driver); 880 883 struct wmi_block *wblock = dev_to_wblock(dev); 881 884 const struct wmi_device_id *id = wmi_driver->id_table; 882 885
+3 -3
drivers/pnp/driver.c
··· 41 41 return 0; 42 42 } 43 43 44 - static const struct pnp_device_id *match_device(struct pnp_driver *drv, 44 + static const struct pnp_device_id *match_device(const struct pnp_driver *drv, 45 45 struct pnp_dev *dev) 46 46 { 47 47 const struct pnp_device_id *drv_id = drv->id_table; ··· 150 150 drv->shutdown(pnp_dev); 151 151 } 152 152 153 - static int pnp_bus_match(struct device *dev, struct device_driver *drv) 153 + static int pnp_bus_match(struct device *dev, const struct device_driver *drv) 154 154 { 155 155 struct pnp_dev *pnp_dev = to_pnp_dev(dev); 156 - struct pnp_driver *pnp_drv = to_pnp_driver(drv); 156 + const struct pnp_driver *pnp_drv = to_pnp_driver(drv); 157 157 158 158 if (match_device(pnp_drv, pnp_dev) == NULL) 159 159 return 0;
+2 -3
drivers/pps/clients/pps-gpio.c
··· 220 220 return 0; 221 221 } 222 222 223 - static int pps_gpio_remove(struct platform_device *pdev) 223 + static void pps_gpio_remove(struct platform_device *pdev) 224 224 { 225 225 struct pps_gpio_device_data *data = platform_get_drvdata(pdev); 226 226 ··· 229 229 /* reset echo pin in any case */ 230 230 gpiod_set_value(data->echo_pin, 0); 231 231 dev_info(&pdev->dev, "removed IRQ %d as PPS source\n", data->irq); 232 - return 0; 233 232 } 234 233 235 234 static const struct of_device_id pps_gpio_dt_ids[] = { ··· 239 240 240 241 static struct platform_driver pps_gpio_driver = { 241 242 .probe = pps_gpio_probe, 242 - .remove = pps_gpio_remove, 243 + .remove_new = pps_gpio_remove, 243 244 .driver = { 244 245 .name = PPS_GPIO_NAME, 245 246 .of_match_table = pps_gpio_dt_ids,
+2 -2
drivers/rapidio/rio-driver.c
··· 186 186 * there is a matching &struct rio_device_id or 0 if there is 187 187 * no match. 188 188 */ 189 - static int rio_match_bus(struct device *dev, struct device_driver *drv) 189 + static int rio_match_bus(struct device *dev, const struct device_driver *drv) 190 190 { 191 191 struct rio_dev *rdev = to_rio_dev(dev); 192 - struct rio_driver *rdrv = to_rio_driver(drv); 192 + const struct rio_driver *rdrv = to_rio_driver(drv); 193 193 const struct rio_device_id *id = rdrv->id_table; 194 194 const struct rio_device_id *found_id; 195 195
+2 -4
drivers/reset/reset-meson-audio-arb.c
··· 120 120 }; 121 121 MODULE_DEVICE_TABLE(of, meson_audio_arb_of_match); 122 122 123 - static int meson_audio_arb_remove(struct platform_device *pdev) 123 + static void meson_audio_arb_remove(struct platform_device *pdev) 124 124 { 125 125 struct meson_audio_arb_data *arb = platform_get_drvdata(pdev); 126 126 ··· 128 128 spin_lock(&arb->lock); 129 129 writel(0, arb->regs); 130 130 spin_unlock(&arb->lock); 131 - 132 - return 0; 133 131 } 134 132 135 133 static int meson_audio_arb_probe(struct platform_device *pdev) ··· 180 182 181 183 static struct platform_driver meson_audio_arb_pdrv = { 182 184 .probe = meson_audio_arb_probe, 183 - .remove = meson_audio_arb_remove, 185 + .remove_new = meson_audio_arb_remove, 184 186 .driver = { 185 187 .name = "meson-audio-arb-reset", 186 188 .of_match_table = meson_audio_arb_of_match,
+2 -4
drivers/reset/reset-rzg2l-usbphy-ctrl.c
··· 192 192 return error; 193 193 } 194 194 195 - static int rzg2l_usbphy_ctrl_remove(struct platform_device *pdev) 195 + static void rzg2l_usbphy_ctrl_remove(struct platform_device *pdev) 196 196 { 197 197 struct rzg2l_usbphy_ctrl_priv *priv = dev_get_drvdata(&pdev->dev); 198 198 ··· 200 200 pm_runtime_put(&pdev->dev); 201 201 pm_runtime_disable(&pdev->dev); 202 202 reset_control_assert(priv->rstc); 203 - 204 - return 0; 205 203 } 206 204 207 205 static struct platform_driver rzg2l_usbphy_ctrl_driver = { ··· 208 210 .of_match_table = rzg2l_usbphy_ctrl_match_table, 209 211 }, 210 212 .probe = rzg2l_usbphy_ctrl_probe, 211 - .remove = rzg2l_usbphy_ctrl_remove, 213 + .remove_new = rzg2l_usbphy_ctrl_remove, 212 214 }; 213 215 module_platform_driver(rzg2l_usbphy_ctrl_driver); 214 216
+2 -4
drivers/reset/reset-ti-sci.c
··· 235 235 return reset_controller_register(&data->rcdev); 236 236 } 237 237 238 - static int ti_sci_reset_remove(struct platform_device *pdev) 238 + static void ti_sci_reset_remove(struct platform_device *pdev) 239 239 { 240 240 struct ti_sci_reset_data *data = platform_get_drvdata(pdev); 241 241 242 242 reset_controller_unregister(&data->rcdev); 243 243 244 244 idr_destroy(&data->idr); 245 - 246 - return 0; 247 245 } 248 246 249 247 static struct platform_driver ti_sci_reset_driver = { 250 248 .probe = ti_sci_reset_probe, 251 - .remove = ti_sci_reset_remove, 249 + .remove_new = ti_sci_reset_remove, 252 250 .driver = { 253 251 .name = "ti-sci-reset", 254 252 .of_match_table = ti_sci_reset_of_match,
+2 -2
drivers/rpmsg/rpmsg_core.c
··· 493 493 } 494 494 495 495 /* match rpmsg channel and rpmsg driver */ 496 - static int rpmsg_dev_match(struct device *dev, struct device_driver *drv) 496 + static int rpmsg_dev_match(struct device *dev, const struct device_driver *drv) 497 497 { 498 498 struct rpmsg_device *rpdev = to_rpmsg_device(dev); 499 - struct rpmsg_driver *rpdrv = to_rpmsg_driver(drv); 499 + const struct rpmsg_driver *rpdrv = to_rpmsg_driver(drv); 500 500 const struct rpmsg_device_id *ids = rpdrv->id_table; 501 501 unsigned int i; 502 502
+1 -1
drivers/rpmsg/rpmsg_internal.h
··· 16 16 #include <linux/poll.h> 17 17 18 18 #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) 19 - #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) 19 + #define to_rpmsg_driver(d) container_of_const(d, struct rpmsg_driver, drv) 20 20 21 21 extern const struct class rpmsg_class; 22 22
+2 -2
drivers/s390/cio/css.c
··· 1354 1354 return sch == to_css(sch->dev.parent)->pseudo_subchannel; 1355 1355 } 1356 1356 1357 - static int css_bus_match(struct device *dev, struct device_driver *drv) 1357 + static int css_bus_match(struct device *dev, const struct device_driver *drv) 1358 1358 { 1359 1359 struct subchannel *sch = to_subchannel(dev); 1360 - struct css_driver *driver = to_cssdriver(drv); 1360 + const struct css_driver *driver = to_cssdriver(drv); 1361 1361 struct css_device_id *id; 1362 1362 1363 1363 /* When driver_override is set, only bind to the matching driver */
+1 -1
drivers/s390/cio/css.h
··· 103 103 int (*settle)(void); 104 104 }; 105 105 106 - #define to_cssdriver(n) container_of(n, struct css_driver, drv) 106 + #define to_cssdriver(n) container_of_const(n, struct css_driver, drv) 107 107 108 108 extern int css_driver_register(struct css_driver *); 109 109 extern void css_driver_unregister(struct css_driver *);
+2 -2
drivers/s390/cio/device.c
··· 58 58 * subsystem driver and one channel system per machine, but 59 59 * we still use the abstraction. T.R. says it's a good idea. */ 60 60 static int 61 - ccw_bus_match (struct device * dev, struct device_driver * drv) 61 + ccw_bus_match (struct device * dev, const struct device_driver * drv) 62 62 { 63 63 struct ccw_device *cdev = to_ccwdev(dev); 64 - struct ccw_driver *cdrv = to_ccwdrv(drv); 64 + const struct ccw_driver *cdrv = to_ccwdrv(drv); 65 65 const struct ccw_device_id *ids = cdrv->ids, *found; 66 66 67 67 if (!ids)
+2 -2
drivers/s390/crypto/ap_bus.c
··· 552 552 * 553 553 * AP bus driver registration/unregistration. 554 554 */ 555 - static int ap_bus_match(struct device *dev, struct device_driver *drv) 555 + static int ap_bus_match(struct device *dev, const struct device_driver *drv) 556 556 { 557 - struct ap_driver *ap_drv = to_ap_drv(drv); 557 + const struct ap_driver *ap_drv = to_ap_drv(drv); 558 558 struct ap_device_id *id; 559 559 560 560 /*
+1 -1
drivers/s390/crypto/ap_bus.h
··· 158 158 struct ap_config_info *old_config_info); 159 159 }; 160 160 161 - #define to_ap_drv(x) container_of((x), struct ap_driver, driver) 161 + #define to_ap_drv(x) container_of_const((x), struct ap_driver, driver) 162 162 163 163 int ap_driver_register(struct ap_driver *, struct module *, char *); 164 164 void ap_driver_unregister(struct ap_driver *);
+1 -1
drivers/scsi/fcoe/fcoe_sysfs.c
··· 600 600 static const struct bus_type fcoe_bus_type; 601 601 602 602 static int fcoe_bus_match(struct device *dev, 603 - struct device_driver *drv) 603 + const struct device_driver *drv) 604 604 { 605 605 if (dev->bus == &fcoe_bus_type) 606 606 return 1;
+3 -3
drivers/scsi/scsi_sysfs.c
··· 528 528 }; 529 529 530 530 /* all probing is done in the individual ->probe routines */ 531 - static int scsi_bus_match(struct device *dev, struct device_driver *gendrv) 531 + static int scsi_bus_match(struct device *dev, const struct device_driver *gendrv) 532 532 { 533 533 struct scsi_device *sdp; 534 534 ··· 661 661 return 1; 662 662 else if (buf[0] == '0') 663 663 return 0; 664 - else 664 + else 665 665 return -EINVAL; 666 666 } else 667 667 return -EINVAL; ··· 886 886 887 887 if (!sdev->tagged_supported) 888 888 return -EINVAL; 889 - 889 + 890 890 sdev_printk(KERN_INFO, sdev, 891 891 "ignoring write to deprecated queue_type attribute"); 892 892 return count;
+1 -1
drivers/scsi/scsi_transport_iscsi.c
··· 1204 1204 static const struct bus_type iscsi_flashnode_bus; 1205 1205 1206 1206 int iscsi_flashnode_bus_match(struct device *dev, 1207 - struct device_driver *drv) 1207 + const struct device_driver *drv) 1208 1208 { 1209 1209 if (dev->bus == &iscsi_flashnode_bus) 1210 1210 return 1;
+2 -2
drivers/sh/maple/maple.c
··· 747 747 } 748 748 749 749 static int maple_match_bus_driver(struct device *devptr, 750 - struct device_driver *drvptr) 750 + const struct device_driver *drvptr) 751 751 { 752 - struct maple_driver *maple_drv = to_maple_driver(drvptr); 752 + const struct maple_driver *maple_drv = to_maple_driver(drvptr); 753 753 struct maple_device *maple_dev = to_maple_dev(devptr); 754 754 755 755 /* Trap empty port case */
+1 -1
drivers/siox/siox-core.c
··· 503 503 .release = siox_device_release, 504 504 }; 505 505 506 - static int siox_match(struct device *dev, struct device_driver *drv) 506 + static int siox_match(struct device *dev, const struct device_driver *drv) 507 507 { 508 508 if (dev->type != &siox_device_type) 509 509 return 0;
+2 -2
drivers/slimbus/core.c
··· 30 30 return NULL; 31 31 } 32 32 33 - static int slim_device_match(struct device *dev, struct device_driver *drv) 33 + static int slim_device_match(struct device *dev, const struct device_driver *drv) 34 34 { 35 35 struct slim_device *sbdev = to_slim_device(dev); 36 - struct slim_driver *sbdrv = to_slim_driver(drv); 36 + const struct slim_driver *sbdrv = to_slim_driver(drv); 37 37 38 38 /* Attempt an OF style match first */ 39 39 if (of_driver_match_device(dev, drv))
+2 -2
drivers/soc/qcom/apr.c
··· 338 338 } 339 339 } 340 340 341 - static int apr_device_match(struct device *dev, struct device_driver *drv) 341 + static int apr_device_match(struct device *dev, const struct device_driver *drv) 342 342 { 343 343 struct apr_device *adev = to_apr_device(dev); 344 - struct apr_driver *adrv = to_apr_driver(drv); 344 + const struct apr_driver *adrv = to_apr_driver(drv); 345 345 const struct apr_device_id *id = adrv->id_table; 346 346 347 347 /* Attempt an OF style match first */
+3 -3
drivers/soundwire/bus_type.c
··· 19 19 * struct sdw_device_id. 20 20 */ 21 21 static const struct sdw_device_id * 22 - sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv) 22 + sdw_get_device_id(struct sdw_slave *slave, const struct sdw_driver *drv) 23 23 { 24 24 const struct sdw_device_id *id; 25 25 ··· 35 35 return NULL; 36 36 } 37 37 38 - static int sdw_bus_match(struct device *dev, struct device_driver *ddrv) 38 + static int sdw_bus_match(struct device *dev, const struct device_driver *ddrv) 39 39 { 40 40 struct sdw_slave *slave; 41 - struct sdw_driver *drv; 41 + const struct sdw_driver *drv; 42 42 int ret = 0; 43 43 44 44 if (is_sdw_slave(dev)) {
+1 -1
drivers/spi/spi.c
··· 371 371 } 372 372 EXPORT_SYMBOL_GPL(spi_get_device_match_data); 373 373 374 - static int spi_match_device(struct device *dev, struct device_driver *drv) 374 + static int spi_match_device(struct device *dev, const struct device_driver *drv) 375 375 { 376 376 const struct spi_device *spi = to_spi_device(dev); 377 377 const struct spi_driver *sdrv = to_spi_driver(drv);
+1 -1
drivers/spmi/spmi.c
··· 43 43 .release = spmi_ctrl_release, 44 44 }; 45 45 46 - static int spmi_device_match(struct device *dev, struct device_driver *drv) 46 + static int spmi_device_match(struct device *dev, const struct device_driver *drv) 47 47 { 48 48 if (of_driver_match_device(dev, drv)) 49 49 return 1;
+2 -2
drivers/ssb/main.c
··· 323 323 return 1; 324 324 } 325 325 326 - static int ssb_bus_match(struct device *dev, struct device_driver *drv) 326 + static int ssb_bus_match(struct device *dev, const struct device_driver *drv) 327 327 { 328 328 struct ssb_device *ssb_dev = dev_to_ssb_dev(dev); 329 - struct ssb_driver *ssb_drv = drv_to_ssb_drv(drv); 329 + const struct ssb_driver *ssb_drv = drv_to_ssb_drv(drv); 330 330 const struct ssb_device_id *id; 331 331 332 332 for (id = ssb_drv->id_table;
+1 -5
drivers/staging/fieldbus/anybuss/anybuss-client.h
··· 44 44 return container_of(dev, struct anybuss_client, dev); 45 45 } 46 46 47 - static inline struct anybuss_client_driver * 48 - to_anybuss_client_driver(struct device_driver *drv) 49 - { 50 - return container_of(drv, struct anybuss_client_driver, driver); 51 - } 47 + #define to_anybuss_client_driver(__drv) container_of_const(__drv, struct anybuss_client_driver, driver) 52 48 53 49 static inline void * 54 50 anybuss_get_drvdata(const struct anybuss_client *client)
+2 -2
drivers/staging/fieldbus/anybuss/host.c
··· 1166 1166 /* ------------------------ bus functions ------------------------ */ 1167 1167 1168 1168 static int anybus_bus_match(struct device *dev, 1169 - struct device_driver *drv) 1169 + const struct device_driver *drv) 1170 1170 { 1171 - struct anybuss_client_driver *adrv = 1171 + const struct anybuss_client_driver *adrv = 1172 1172 to_anybuss_client_driver(drv); 1173 1173 struct anybuss_client *adev = 1174 1174 to_anybuss_client(dev);
+1 -1
drivers/staging/greybus/gbphy.c
··· 117 117 return NULL; 118 118 } 119 119 120 - static int gbphy_dev_match(struct device *dev, struct device_driver *drv) 120 + static int gbphy_dev_match(struct device *dev, const struct device_driver *drv) 121 121 { 122 122 struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv); 123 123 struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+1 -1
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
··· 14 14 #include "vchiq_arm.h" 15 15 #include "vchiq_bus.h" 16 16 17 - static int vchiq_bus_type_match(struct device *dev, struct device_driver *drv) 17 + static int vchiq_bus_type_match(struct device *dev, const struct device_driver *drv) 18 18 { 19 19 if (dev->bus == &vchiq_bus_type && 20 20 strcmp(dev_name(dev), drv->name) == 0)
+1 -1
drivers/staging/vme_user/vme.c
··· 1931 1931 1932 1932 /* - Bus Registration ------------------------------------------------------ */ 1933 1933 1934 - static int vme_bus_match(struct device *dev, struct device_driver *drv) 1934 + static int vme_bus_match(struct device *dev, const struct device_driver *drv) 1935 1935 { 1936 1936 struct vme_driver *vme_drv; 1937 1937
+3 -3
drivers/tc/tc-driver.c
··· 56 56 * system is in its list of supported devices. Returns the matching 57 57 * tc_device_id structure or %NULL if there is no match. 58 58 */ 59 - static const struct tc_device_id *tc_match_device(struct tc_driver *tdrv, 59 + static const struct tc_device_id *tc_match_device(const struct tc_driver *tdrv, 60 60 struct tc_dev *tdev) 61 61 { 62 62 const struct tc_device_id *id = tdrv->id_table; ··· 82 82 * system is in its list of supported devices. Returns 1 if there 83 83 * is a match or 0 otherwise. 84 84 */ 85 - static int tc_bus_match(struct device *dev, struct device_driver *drv) 85 + static int tc_bus_match(struct device *dev, const struct device_driver *drv) 86 86 { 87 87 struct tc_dev *tdev = to_tc_dev(dev); 88 - struct tc_driver *tdrv = to_tc_driver(drv); 88 + const struct tc_driver *tdrv = to_tc_driver(drv); 89 89 const struct tc_device_id *id; 90 90 91 91 id = tc_match_device(tdrv, tdev);
+1 -1
drivers/tee/tee_core.c
··· 1201 1201 } 1202 1202 1203 1203 static int tee_client_device_match(struct device *dev, 1204 - struct device_driver *drv) 1204 + const struct device_driver *drv) 1205 1205 { 1206 1206 const struct tee_client_device_id *id_table; 1207 1207 struct tee_client_device *tee_device;
+4 -4
drivers/thunderbolt/domain.c
··· 45 45 } 46 46 47 47 static const struct tb_service_id *__tb_service_match(struct device *dev, 48 - struct device_driver *drv) 48 + const struct device_driver *drv) 49 49 { 50 - struct tb_service_driver *driver; 50 + const struct tb_service_driver *driver; 51 51 const struct tb_service_id *ids; 52 52 struct tb_service *svc; 53 53 ··· 55 55 if (!svc) 56 56 return NULL; 57 57 58 - driver = container_of(drv, struct tb_service_driver, driver); 58 + driver = container_of_const(drv, struct tb_service_driver, driver); 59 59 if (!driver->id_table) 60 60 return NULL; 61 61 ··· 67 67 return NULL; 68 68 } 69 69 70 - static int tb_service_match(struct device *dev, struct device_driver *drv) 70 + static int tb_service_match(struct device *dev, const struct device_driver *drv) 71 71 { 72 72 return !!__tb_service_match(dev, drv); 73 73 }
+1 -1
drivers/tty/serdev/core.c
··· 85 85 .release = serdev_ctrl_release, 86 86 }; 87 87 88 - static int serdev_device_match(struct device *dev, struct device_driver *drv) 88 + static int serdev_device_match(struct device *dev, const struct device_driver *drv) 89 89 { 90 90 if (!is_serdev_device(dev)) 91 91 return 0;
+1 -1
drivers/tty/serial/serial_base_bus.c
··· 29 29 .name = "port", 30 30 }; 31 31 32 - static int serial_base_match(struct device *dev, struct device_driver *drv) 32 + static int serial_base_match(struct device *dev, const struct device_driver *drv) 33 33 { 34 34 if (dev->type == &serial_ctrl_type && 35 35 str_has_prefix(drv->name, serial_ctrl_type.name))
+1 -1
drivers/usb/common/ulpi.c
··· 34 34 35 35 /* -------------------------------------------------------------------------- */ 36 36 37 - static int ulpi_match(struct device *dev, struct device_driver *driver) 37 + static int ulpi_match(struct device *dev, const struct device_driver *driver) 38 38 { 39 39 struct ulpi_driver *drv = to_ulpi_driver(driver); 40 40 struct ulpi *ulpi = to_ulpi_dev(dev);
+1 -1
drivers/usb/core/driver.c
··· 868 868 return false; 869 869 } 870 870 871 - static int usb_device_match(struct device *dev, struct device_driver *drv) 871 + static int usb_device_match(struct device *dev, const struct device_driver *drv) 872 872 { 873 873 /* devices and interfaces are handled separately */ 874 874 if (is_usb_device(dev)) {
+1 -1
drivers/usb/gadget/udc/core.c
··· 1568 1568 1569 1569 /* ------------------------------------------------------------------------- */ 1570 1570 1571 - static int gadget_match_driver(struct device *dev, struct device_driver *drv) 1571 + static int gadget_match_driver(struct device *dev, const struct device_driver *drv) 1572 1572 { 1573 1573 struct usb_gadget *gadget = dev_to_usb_gadget(dev); 1574 1574 struct usb_udc *udc = gadget->udc;
+1 -1
drivers/usb/serial/bus.c
··· 14 14 #include <linux/usb/serial.h> 15 15 16 16 static int usb_serial_device_match(struct device *dev, 17 - struct device_driver *drv) 17 + const struct device_driver *drv) 18 18 { 19 19 const struct usb_serial_port *port = to_usb_serial_port(dev); 20 20 struct usb_serial_driver *driver = to_usb_serial_driver(drv);
+1 -1
drivers/usb/typec/bus.c
··· 447 447 }; 448 448 ATTRIBUTE_GROUPS(typec); 449 449 450 - static int typec_match(struct device *dev, struct device_driver *driver) 450 + static int typec_match(struct device *dev, const struct device_driver *driver) 451 451 { 452 452 struct typec_altmode_driver *drv = to_altmode_driver(driver); 453 453 struct typec_altmode *altmode = to_typec_altmode(dev);
+1 -1
drivers/vdpa/vdpa.c
··· 65 65 drv->remove(vdev); 66 66 } 67 67 68 - static int vdpa_dev_match(struct device *dev, struct device_driver *drv) 68 + static int vdpa_dev_match(struct device *dev, const struct device_driver *drv) 69 69 { 70 70 struct vdpa_device *vdev = dev_to_vdpa(dev); 71 71
+1 -1
drivers/vfio/mdev/mdev_driver.c
··· 31 31 drv->remove(to_mdev_device(dev)); 32 32 } 33 33 34 - static int mdev_match(struct device *dev, struct device_driver *drv) 34 + static int mdev_match(struct device *dev, const struct device_driver *drv) 35 35 { 36 36 /* 37 37 * No drivers automatically match. Drivers are only bound by explicit
+1 -1
drivers/virtio/virtio.c
··· 82 82 83 83 /* This looks through all the IDs a driver claims to support. If any of them 84 84 * match, we return 1 and the kernel will call virtio_dev_probe(). */ 85 - static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) 85 + static int virtio_dev_match(struct device *_dv, const struct device_driver *_dr) 86 86 { 87 87 unsigned int i; 88 88 struct virtio_device *dev = dev_to_virtio(_dv);
+1 -1
drivers/xen/xenbus/xenbus.h
··· 104 104 int xs_watch_msg(struct xs_watch_event *event); 105 105 void xs_request_exit(struct xb_req_data *req); 106 106 107 - int xenbus_match(struct device *_dev, struct device_driver *_drv); 107 + int xenbus_match(struct device *_dev, const struct device_driver *_drv); 108 108 int xenbus_dev_probe(struct device *_dev); 109 109 void xenbus_dev_remove(struct device *_dev); 110 110 int xenbus_register_driver_common(struct xenbus_driver *drv,
+2 -2
drivers/xen/xenbus/xenbus_probe.c
··· 94 94 return NULL; 95 95 } 96 96 97 - int xenbus_match(struct device *_dev, struct device_driver *_drv) 97 + int xenbus_match(struct device *_dev, const struct device_driver *_drv) 98 98 { 99 - struct xenbus_driver *drv = to_xenbus_driver(_drv); 99 + const struct xenbus_driver *drv = to_xenbus_driver(_drv); 100 100 101 101 if (!drv->ids) 102 102 return 0;
+2 -2
drivers/zorro/zorro-driver.c
··· 118 118 * supported, and 0 if there is no match. 119 119 */ 120 120 121 - static int zorro_bus_match(struct device *dev, struct device_driver *drv) 121 + static int zorro_bus_match(struct device *dev, const struct device_driver *drv) 122 122 { 123 123 struct zorro_dev *z = to_zorro_dev(dev); 124 - struct zorro_driver *zorro_drv = to_zorro_driver(drv); 124 + const struct zorro_driver *zorro_drv = to_zorro_driver(drv); 125 125 const struct zorro_device_id *ids = zorro_drv->id_table; 126 126 127 127 if (!ids)
+1 -1
include/acpi/acpi_bus.h
··· 563 563 } 564 564 565 565 #define to_acpi_device(d) container_of(d, struct acpi_device, dev) 566 - #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) 566 + #define to_acpi_driver(d) container_of_const(d, struct acpi_driver, drv) 567 567 568 568 static inline struct acpi_device *acpi_dev_parent(struct acpi_device *adev) 569 569 {
+1 -1
include/linux/arm_ffa.h
··· 149 149 struct device_driver driver; 150 150 }; 151 151 152 - #define to_ffa_driver(d) container_of(d, struct ffa_driver, driver) 152 + #define to_ffa_driver(d) container_of_const(d, struct ffa_driver, driver) 153 153 154 154 static inline void ffa_dev_set_drvdata(struct ffa_device *fdev, void *data) 155 155 {
+1 -1
include/linux/auxiliary_bus.h
··· 212 212 return container_of(dev, struct auxiliary_device, dev); 213 213 } 214 214 215 - static inline struct auxiliary_driver *to_auxiliary_drv(struct device_driver *drv) 215 + static inline const struct auxiliary_driver *to_auxiliary_drv(const struct device_driver *drv) 216 216 { 217 217 return container_of(drv, struct auxiliary_driver, driver); 218 218 }
+1 -1
include/linux/cdx/cdx_bus.h
··· 211 211 }; 212 212 213 213 #define to_cdx_driver(_drv) \ 214 - container_of(_drv, struct cdx_driver, driver) 214 + container_of_const(_drv, struct cdx_driver, driver) 215 215 216 216 /* Macro to avoid include chaining to get THIS_MODULE */ 217 217 #define cdx_driver_register(drv) \
+11 -10
include/linux/device.h
··· 1031 1031 lockdep_assert_held(&dev->mutex); 1032 1032 } 1033 1033 1034 - static inline struct device_node *dev_of_node(struct device *dev) 1035 - { 1036 - if (!IS_ENABLED(CONFIG_OF) || !dev) 1037 - return NULL; 1038 - return dev->of_node; 1039 - } 1040 - 1041 1034 static inline bool dev_has_sync_state(struct device *dev) 1042 1035 { 1043 1036 if (!dev) ··· 1137 1144 int lock_device_hotplug_sysfs(void); 1138 1145 int device_offline(struct device *dev); 1139 1146 int device_online(struct device *dev); 1147 + 1140 1148 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode); 1141 1149 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode); 1142 - void device_set_of_node_from_dev(struct device *dev, const struct device *dev2); 1143 1150 void device_set_node(struct device *dev, struct fwnode_handle *fwnode); 1151 + void device_set_of_node_from_dev(struct device *dev, const struct device *dev2); 1152 + 1153 + static inline struct device_node *dev_of_node(struct device *dev) 1154 + { 1155 + if (!IS_ENABLED(CONFIG_OF) || !dev) 1156 + return NULL; 1157 + return dev->of_node; 1158 + } 1144 1159 1145 1160 static inline int dev_num_vf(struct device *dev) 1146 1161 { ··· 1177 1176 * Manual binding of a device to driver. See drivers/base/bus.c 1178 1177 * for information on use. 1179 1178 */ 1180 - int __must_check device_driver_attach(struct device_driver *drv, 1179 + int __must_check device_driver_attach(const struct device_driver *drv, 1181 1180 struct device *dev); 1182 1181 int __must_check device_bind_driver(struct device *dev); 1183 1182 void device_release_driver(struct device *dev); 1184 1183 int __must_check device_attach(struct device *dev); 1185 - int __must_check driver_attach(struct device_driver *drv); 1184 + int __must_check driver_attach(const struct device_driver *drv); 1186 1185 void device_initial_probe(struct device *dev); 1187 1186 int __must_check device_reprobe(struct device *dev); 1188 1187
+1 -1
include/linux/device/bus.h
··· 81 81 const struct attribute_group **dev_groups; 82 82 const struct attribute_group **drv_groups; 83 83 84 - int (*match)(struct device *dev, struct device_driver *drv); 84 + int (*match)(struct device *dev, const struct device_driver *drv); 85 85 int (*uevent)(const struct device *dev, struct kobj_uevent_env *env); 86 86 int (*probe)(struct device *dev); 87 87 void (*sync_state)(struct device *dev);
+9 -9
include/linux/device/driver.h
··· 146 146 #define DRIVER_ATTR_WO(_name) \ 147 147 struct driver_attribute driver_attr_##_name = __ATTR_WO(_name) 148 148 149 - int __must_check driver_create_file(struct device_driver *driver, 149 + int __must_check driver_create_file(const struct device_driver *driver, 150 150 const struct driver_attribute *attr); 151 - void driver_remove_file(struct device_driver *driver, 151 + void driver_remove_file(const struct device_driver *driver, 152 152 const struct driver_attribute *attr); 153 153 154 154 int driver_set_override(struct device *dev, const char **override, 155 155 const char *s, size_t len); 156 156 int __must_check driver_for_each_device(struct device_driver *drv, struct device *start, 157 157 void *data, int (*fn)(struct device *dev, void *)); 158 - struct device *driver_find_device(struct device_driver *drv, 158 + struct device *driver_find_device(const struct device_driver *drv, 159 159 struct device *start, const void *data, 160 160 int (*match)(struct device *dev, const void *data)); 161 161 ··· 165 165 * @drv: the driver we're iterating 166 166 * @name: name of the device to match 167 167 */ 168 - static inline struct device *driver_find_device_by_name(struct device_driver *drv, 168 + static inline struct device *driver_find_device_by_name(const struct device_driver *drv, 169 169 const char *name) 170 170 { 171 171 return driver_find_device(drv, NULL, name, device_match_name); ··· 178 178 * @np: of_node pointer to match. 179 179 */ 180 180 static inline struct device * 181 - driver_find_device_by_of_node(struct device_driver *drv, 181 + driver_find_device_by_of_node(const struct device_driver *drv, 182 182 const struct device_node *np) 183 183 { 184 184 return driver_find_device(drv, NULL, np, device_match_of_node); ··· 203 203 * @drv: the driver we're iterating 204 204 * @devt: devt pointer to match. 205 205 */ 206 - static inline struct device *driver_find_device_by_devt(struct device_driver *drv, 206 + static inline struct device *driver_find_device_by_devt(const struct device_driver *drv, 207 207 dev_t devt) 208 208 { 209 209 return driver_find_device(drv, NULL, &devt, device_match_devt); 210 210 } 211 211 212 - static inline struct device *driver_find_next_device(struct device_driver *drv, 212 + static inline struct device *driver_find_next_device(const struct device_driver *drv, 213 213 struct device *start) 214 214 { 215 215 return driver_find_device(drv, start, NULL, device_match_any); ··· 223 223 * @adev: ACPI_COMPANION device to match. 224 224 */ 225 225 static inline struct device * 226 - driver_find_device_by_acpi_dev(struct device_driver *drv, 226 + driver_find_device_by_acpi_dev(const struct device_driver *drv, 227 227 const struct acpi_device *adev) 228 228 { 229 229 return driver_find_device(drv, NULL, adev, device_match_acpi_dev); 230 230 } 231 231 #else 232 232 static inline struct device * 233 - driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev) 233 + driver_find_device_by_acpi_dev(const struct device_driver *drv, const void *adev) 234 234 { 235 235 return NULL; 236 236 }
+1 -1
include/linux/dfl.h
··· 71 71 }; 72 72 73 73 #define to_dfl_dev(d) container_of(d, struct dfl_device, dev) 74 - #define to_dfl_drv(d) container_of(d, struct dfl_driver, drv) 74 + #define to_dfl_drv(d) container_of_const(d, struct dfl_driver, drv) 75 75 76 76 /* 77 77 * use a macro to avoid include chaining to get THIS_MODULE.
+1 -1
include/linux/dio.h
··· 93 93 struct device_driver driver; 94 94 }; 95 95 96 - #define to_dio_driver(drv) container_of(drv, struct dio_driver, driver) 96 + #define to_dio_driver(drv) container_of_const(drv, struct dio_driver, driver) 97 97 98 98 /* DIO/DIO-II boards all have the following 8bit registers. 99 99 * These are offsets from the base of the device.
+1 -1
include/linux/eisa.h
··· 60 60 struct device_driver driver; 61 61 }; 62 62 63 - #define to_eisa_driver(drv) container_of(drv,struct eisa_driver, driver) 63 + #define to_eisa_driver(drv) container_of_const(drv,struct eisa_driver, driver) 64 64 65 65 /* These external functions are only available when EISA support is enabled. */ 66 66 #ifdef CONFIG_EISA
+1 -1
include/linux/fsi.h
··· 44 44 }; 45 45 46 46 #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev) 47 - #define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv) 47 + #define to_fsi_drv(drvp) container_of_const(drvp, struct fsi_driver, drv) 48 48 49 49 extern int fsi_driver_register(struct fsi_driver *fsi_drv); 50 50 extern void fsi_driver_unregister(struct fsi_driver *fsi_drv);
+1 -1
include/linux/fsl/mc.h
··· 56 56 }; 57 57 58 58 #define to_fsl_mc_driver(_drv) \ 59 - container_of(_drv, struct fsl_mc_driver, driver) 59 + container_of_const(_drv, struct fsl_mc_driver, driver) 60 60 61 61 /** 62 62 * enum fsl_mc_pool_type - Types of allocatable MC bus resources
+1 -1
include/linux/gameport.h
··· 58 58 59 59 bool ignore; 60 60 }; 61 - #define to_gameport_driver(d) container_of(d, struct gameport_driver, driver) 61 + #define to_gameport_driver(d) container_of_const(d, struct gameport_driver, driver) 62 62 63 63 int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode); 64 64 void gameport_close(struct gameport *gameport);
+1 -1
include/linux/greybus.h
··· 64 64 65 65 struct device_driver driver; 66 66 }; 67 - #define to_greybus_driver(d) container_of(d, struct greybus_driver, driver) 67 + #define to_greybus_driver(d) container_of_const(d, struct greybus_driver, driver) 68 68 69 69 static inline void greybus_set_drvdata(struct gb_bundle *bundle, void *data) 70 70 {
+1 -5
include/linux/hyperv.h
··· 1330 1330 1331 1331 1332 1332 #define device_to_hv_device(d) container_of_const(d, struct hv_device, device) 1333 - 1334 - static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d) 1335 - { 1336 - return container_of(d, struct hv_driver, driver); 1337 - } 1333 + #define drv_to_hv_drv(d) container_of_const(d, struct hv_driver, driver) 1338 1334 1339 1335 static inline void hv_set_drvdata(struct hv_device *dev, void *data) 1340 1336 {
+1 -1
include/linux/i2c.h
··· 303 303 304 304 u32 flags; 305 305 }; 306 - #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 306 + #define to_i2c_driver(d) container_of_const(d, struct i2c_driver, driver) 307 307 308 308 /** 309 309 * struct i2c_client - represent an I2C slave device
+1 -4
include/linux/i3c/device.h
··· 183 183 const struct i3c_device_id *id_table; 184 184 }; 185 185 186 - static inline struct i3c_driver *drv_to_i3cdrv(struct device_driver *drv) 187 - { 188 - return container_of(drv, struct i3c_driver, driver); 189 - } 186 + #define drv_to_i3cdrv(__drv) container_of_const(__drv, struct i3c_driver, driver) 190 187 191 188 struct device *i3cdev_to_dev(struct i3c_device *i3cdev); 192 189
+1 -1
include/linux/maple.h
··· 97 97 void maple_clear_dev(struct maple_device *mdev); 98 98 99 99 #define to_maple_dev(n) container_of(n, struct maple_device, dev) 100 - #define to_maple_driver(n) container_of(n, struct maple_driver, drv) 100 + #define to_maple_driver(n) container_of_const(n, struct maple_driver, drv) 101 101 102 102 #define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev) 103 103 #define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
+1 -4
include/linux/mcb.h
··· 94 94 void (*shutdown)(struct mcb_device *mdev); 95 95 }; 96 96 97 - static inline struct mcb_driver *to_mcb_driver(struct device_driver *drv) 98 - { 99 - return container_of(drv, struct mcb_driver, driver); 100 - } 97 + #define to_mcb_driver(__drv) container_of_const(__drv, struct mcb_driver, driver) 101 98 102 99 static inline void *mcb_get_drvdata(struct mcb_device *dev) 103 100 {
+6 -13
include/linux/mdio.h
··· 31 31 struct mii_bus *bus; 32 32 char modalias[MDIO_NAME_SIZE]; 33 33 34 - int (*bus_match)(struct device *dev, struct device_driver *drv); 34 + int (*bus_match)(struct device *dev, const struct device_driver *drv); 35 35 void (*device_free)(struct mdio_device *mdiodev); 36 36 void (*device_remove)(struct mdio_device *mdiodev); 37 37 ··· 57 57 }; 58 58 #define MDIO_DEVICE_FLAG_PHY 1 59 59 60 - static inline struct mdio_driver_common * 61 - to_mdio_common_driver(const struct device_driver *driver) 62 - { 63 - return container_of(driver, struct mdio_driver_common, driver); 64 - } 60 + #define to_mdio_common_driver(__drv_c) container_of_const(__drv_c, struct mdio_driver_common, \ 61 + driver) 65 62 66 63 /* struct mdio_driver: Generic MDIO driver */ 67 64 struct mdio_driver { ··· 77 80 void (*shutdown)(struct mdio_device *mdiodev); 78 81 }; 79 82 80 - static inline struct mdio_driver * 81 - to_mdio_driver(const struct device_driver *driver) 82 - { 83 - return container_of(to_mdio_common_driver(driver), struct mdio_driver, 84 - mdiodrv); 85 - } 83 + #define to_mdio_driver(__drv_m) container_of_const(to_mdio_common_driver(__drv_m), \ 84 + struct mdio_driver, mdiodrv) 86 85 87 86 /* device driver data */ 88 87 static inline void mdiodev_set_drvdata(struct mdio_device *mdio, void *data) ··· 98 105 void mdio_device_reset(struct mdio_device *mdiodev, int value); 99 106 int mdio_driver_register(struct mdio_driver *drv); 100 107 void mdio_driver_unregister(struct mdio_driver *drv); 101 - int mdio_device_bus_match(struct device *dev, struct device_driver *drv); 108 + int mdio_device_bus_match(struct device *dev, const struct device_driver *drv); 102 109 103 110 static inline void mdio_device_get(struct mdio_device *mdiodev) 104 111 {
+1 -1
include/linux/mhi.h
··· 528 528 struct device_driver driver; 529 529 }; 530 530 531 - #define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver) 531 + #define to_mhi_driver(drv) container_of_const(drv, struct mhi_driver, driver) 532 532 #define to_mhi_device(dev) container_of(dev, struct mhi_device, dev) 533 533 534 534 /**
+1 -1
include/linux/mhi_ep.h
··· 221 221 }; 222 222 223 223 #define to_mhi_ep_device(dev) container_of(dev, struct mhi_ep_device, dev) 224 - #define to_mhi_ep_driver(drv) container_of(drv, struct mhi_ep_driver, driver) 224 + #define to_mhi_ep_driver(drv) container_of_const(drv, struct mhi_ep_driver, driver) 225 225 226 226 /* 227 227 * module_mhi_ep_driver() - Helper macro for drivers that don't do
+2 -7
include/linux/moxtet.h
··· 61 61 struct device_driver driver; 62 62 }; 63 63 64 - static inline struct moxtet_driver * 65 - to_moxtet_driver(struct device_driver *drv) 66 - { 67 - if (!drv) 68 - return NULL; 69 - return container_of(drv, struct moxtet_driver, driver); 70 - } 64 + #define to_moxtet_driver(__drv) \ 65 + ( __drv ? container_of_const(__drv, struct moxtet_driver, driver) : NULL ) 71 66 72 67 extern int __moxtet_register_driver(struct module *owner, 73 68 struct moxtet_driver *mdrv);
+1 -5
include/linux/nd.h
··· 84 84 void (*notify)(struct device *dev, enum nvdimm_event event); 85 85 }; 86 86 87 - static inline struct nd_device_driver *to_nd_device_driver( 88 - struct device_driver *drv) 89 - { 90 - return container_of(drv, struct nd_device_driver, drv); 91 - }; 87 + #define to_nd_device_driver(__drv) container_of_const(__drv, struct nd_device_driver, drv) 92 88 93 89 /** 94 90 * struct nd_namespace_common - core infrastructure of a namespace
+1 -2
include/linux/pci-epf.h
··· 107 107 const struct pci_epf_device_id *id_table; 108 108 }; 109 109 110 - #define to_pci_epf_driver(drv) (container_of((drv), struct pci_epf_driver, \ 111 - driver)) 110 + #define to_pci_epf_driver(drv) container_of_const((drv), struct pci_epf_driver, driver) 112 111 113 112 /** 114 113 * struct pci_epf_bar - represents the BAR of EPF device
+2 -4
include/linux/pci.h
··· 959 959 bool driver_managed_dma; 960 960 }; 961 961 962 - static inline struct pci_driver *to_pci_driver(struct device_driver *drv) 963 - { 964 - return drv ? container_of(drv, struct pci_driver, driver) : NULL; 965 - } 962 + #define to_pci_driver(__drv) \ 963 + ( __drv ? container_of_const(__drv, struct pci_driver, driver) : NULL ) 966 964 967 965 /** 968 966 * PCI_DEVICE - macro used to describe a specific PCI device
+1 -1
include/linux/phy.h
··· 1187 1187 int (*led_polarity_set)(struct phy_device *dev, int index, 1188 1188 unsigned long modes); 1189 1189 }; 1190 - #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ 1190 + #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d), \ 1191 1191 struct phy_driver, mdiodrv) 1192 1192 1193 1193 #define PHY_ANY_ID "MATCH ANY PHY"
+7 -8
include/linux/platform_device.h
··· 237 237 int (*probe)(struct platform_device *); 238 238 239 239 /* 240 - * Traditionally the remove callback returned an int which however is 241 - * ignored by the driver core. This led to wrong expectations by driver 242 - * authors who thought returning an error code was a valid error 243 - * handling strategy. To convert to a callback returning void, new 244 - * drivers should implement .remove_new() until the conversion it done 245 - * that eventually makes .remove() return void. 240 + * .remove_new() is a relic from a prototype conversion of .remove(). 241 + * New drivers are supposed to implement .remove(). Once all drivers are 242 + * converted to not use .remove_new any more, it will be dropped. 246 243 */ 247 - int (*remove)(struct platform_device *); 248 - void (*remove_new)(struct platform_device *); 244 + union { 245 + void (*remove)(struct platform_device *); 246 + void (*remove_new)(struct platform_device *); 247 + }; 249 248 250 249 void (*shutdown)(struct platform_device *); 251 250 int (*suspend)(struct platform_device *, pm_message_t state);
+1 -1
include/linux/pnp.h
··· 383 383 struct device_driver driver; 384 384 }; 385 385 386 - #define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver) 386 + #define to_pnp_driver(drv) container_of_const(drv, struct pnp_driver, driver) 387 387 388 388 struct pnp_card_driver { 389 389 struct list_head global_list;
+1 -1
include/linux/rio.h
··· 465 465 struct device_driver driver; 466 466 }; 467 467 468 - #define to_rio_driver(drv) container_of(drv,struct rio_driver, driver) 468 + #define to_rio_driver(drv) container_of_const(drv,struct rio_driver, driver) 469 469 470 470 union rio_pw_msg { 471 471 struct {
+1 -1
include/linux/scmi_protocol.h
··· 945 945 struct scmi_handle *handle; 946 946 }; 947 947 948 - #define to_scmi_dev(d) container_of(d, struct scmi_device, dev) 948 + #define to_scmi_dev(d) container_of_const(d, struct scmi_device, dev) 949 949 950 950 struct scmi_device_id { 951 951 u8 protocol_id;
+1 -1
include/linux/serio.h
··· 80 80 81 81 struct device_driver driver; 82 82 }; 83 - #define to_serio_driver(d) container_of(d, struct serio_driver, driver) 83 + #define to_serio_driver(d) container_of_const(d, struct serio_driver, driver) 84 84 85 85 int serio_open(struct serio *serio, struct serio_driver *drv); 86 86 void serio_close(struct serio *serio);
+1 -1
include/linux/slimbus.h
··· 91 91 struct device_driver driver; 92 92 const struct slim_device_id *id_table; 93 93 }; 94 - #define to_slim_driver(d) container_of(d, struct slim_driver, driver) 94 + #define to_slim_driver(d) container_of_const(d, struct slim_driver, driver) 95 95 96 96 /** 97 97 * struct slim_val_inf - Slimbus value or information element
+1 -1
include/linux/soc/qcom/apr.h
··· 162 162 }; 163 163 164 164 typedef struct apr_driver gpr_driver_t; 165 - #define to_apr_driver(d) container_of(d, struct apr_driver, driver) 165 + #define to_apr_driver(d) container_of_const(d, struct apr_driver, driver) 166 166 167 167 /* 168 168 * use a macro to avoid include chaining to get THIS_MODULE
+1 -1
include/linux/soundwire/sdw_type.h
··· 13 13 return dev->type == &sdw_slave_type; 14 14 } 15 15 16 - #define drv_to_sdw_driver(_drv) container_of(_drv, struct sdw_driver, driver) 16 + #define drv_to_sdw_driver(_drv) container_of_const(_drv, struct sdw_driver, driver) 17 17 18 18 #define sdw_register_driver(drv) \ 19 19 __sdw_register_driver(drv, THIS_MODULE)
+2 -4
include/linux/spi/spi.h
··· 351 351 struct device_driver driver; 352 352 }; 353 353 354 - static inline struct spi_driver *to_spi_driver(struct device_driver *drv) 355 - { 356 - return drv ? container_of(drv, struct spi_driver, driver) : NULL; 357 - } 354 + #define to_spi_driver(__drv) \ 355 + ( __drv ? container_of_const(__drv, struct spi_driver, driver) : NULL ) 358 356 359 357 extern int __spi_register_driver(struct module *owner, struct spi_driver *sdrv); 360 358
+1 -1
include/linux/ssb/ssb.h
··· 325 325 326 326 struct device_driver drv; 327 327 }; 328 - #define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv) 328 + #define drv_to_ssb_drv(_drv) container_of_const(_drv, struct ssb_driver, drv) 329 329 330 330 extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner); 331 331 #define ssb_driver_register(drv) \
+1 -1
include/linux/tc.h
··· 108 108 struct device_driver driver; 109 109 }; 110 110 111 - #define to_tc_driver(drv) container_of(drv, struct tc_driver, driver) 111 + #define to_tc_driver(drv) container_of_const(drv, struct tc_driver, driver) 112 112 113 113 /* 114 114 * Return TURBOchannel clock frequency in Hz.
+1 -1
include/linux/tee_drv.h
··· 298 298 }; 299 299 300 300 #define to_tee_client_driver(d) \ 301 - container_of(d, struct tee_client_driver, driver) 301 + container_of_const(d, struct tee_client_driver, driver) 302 302 303 303 #endif /*__TEE_DRV_H*/
+1 -4
include/linux/virtio.h
··· 209 209 int (*restore)(struct virtio_device *dev); 210 210 }; 211 211 212 - static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv) 213 - { 214 - return container_of(drv, struct virtio_driver, driver); 215 - } 212 + #define drv_to_virtio(__drv) container_of_const(__drv, struct virtio_driver, driver) 216 213 217 214 /* use a macro to avoid include chaining to get THIS_MODULE */ 218 215 #define register_virtio_driver(drv) \
+1 -1
include/linux/zorro.h
··· 52 52 struct device_driver driver; 53 53 }; 54 54 55 - #define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver) 55 + #define to_zorro_driver(drv) container_of_const(drv, struct zorro_driver, driver) 56 56 57 57 58 58 #define zorro_for_each_dev(dev) \
+1 -1
include/scsi/scsi_transport_iscsi.h
··· 495 495 496 496 extern void iscsi_destroy_all_flashnode(struct Scsi_Host *shost); 497 497 extern int iscsi_flashnode_bus_match(struct device *dev, 498 - struct device_driver *drv); 498 + const struct device_driver *drv); 499 499 extern struct device * 500 500 iscsi_find_flashnode_sess(struct Scsi_Host *shost, void *data, 501 501 int (*fn)(struct device *dev, void *data));
+1 -4
include/sound/ac97/codec.h
··· 73 73 return container_of(d, struct ac97_codec_device, dev); 74 74 } 75 75 76 - static inline struct ac97_codec_driver *to_ac97_driver(struct device_driver *d) 77 - { 78 - return container_of(d, struct ac97_codec_driver, driver); 79 - } 76 + #define to_ac97_driver(__drv) container_of_const(__drv, struct ac97_codec_driver, driver) 80 77 81 78 #if IS_ENABLED(CONFIG_AC97_BUS_NEW) 82 79 int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv);
+1 -4
include/xen/xenbus.h
··· 124 124 void (*reclaim_memory)(struct xenbus_device *dev); 125 125 }; 126 126 127 - static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) 128 - { 129 - return container_of(drv, struct xenbus_driver, driver); 130 - } 127 + #define to_xenbus_driver(__drv) container_of_const(__drv, struct xenbus_driver, driver) 131 128 132 129 int __must_check __xenbus_register_frontend(struct xenbus_driver *drv, 133 130 struct module *owner,
+16 -1
lib/kobject_uevent.c
··· 433 433 len = strlen(env->envp[i]) + 1; 434 434 435 435 if (i != env->envp_idx - 1) { 436 + /* @env->envp[] contains pointers to @env->buf[] 437 + * with @env->buflen chars, and we are removing 438 + * variable MODALIAS here pointed by @env->envp[i] 439 + * with length @len as shown below: 440 + * 441 + * 0 @env->buf[] @env->buflen 442 + * --------------------------------------------- 443 + * ^ ^ ^ ^ 444 + * | |-> @len <-| target block | 445 + * @env->envp[0] @env->envp[i] @env->envp[i + 1] 446 + * 447 + * so the "target block" indicated above is moved 448 + * backward by @len, and its right size is 449 + * @env->buflen - (@env->envp[i + 1] - @env->envp[0]). 450 + */ 436 451 memmove(env->envp[i], env->envp[i + 1], 437 - env->buflen - len); 452 + env->buflen - (env->envp[i + 1] - env->envp[0])); 438 453 439 454 for (j = i; j < env->envp_idx - 1; j++) 440 455 env->envp[j] = env->envp[j + 1] - len;
+1 -1
net/iucv/iucv.c
··· 62 62 #define IUCV_IPNORPY 0x10 63 63 #define IUCV_IPALL 0x80 64 64 65 - static int iucv_bus_match(struct device *dev, struct device_driver *drv) 65 + static int iucv_bus_match(struct device *dev, const struct device_driver *drv) 66 66 { 67 67 return 0; 68 68 }
+1
rust/bindings/bindings_helper.h
··· 12 12 #include <linux/blkdev.h> 13 13 #include <linux/errname.h> 14 14 #include <linux/ethtool.h> 15 + #include <linux/firmware.h> 15 16 #include <linux/jiffies.h> 16 17 #include <linux/mdio.h> 17 18 #include <linux/phy.h>
+1
rust/helpers.c
··· 23 23 #include <kunit/test-bug.h> 24 24 #include <linux/bug.h> 25 25 #include <linux/build_bug.h> 26 + #include <linux/device.h> 26 27 #include <linux/err.h> 27 28 #include <linux/errname.h> 28 29 #include <linux/mutex.h>
+105
rust/kernel/device.rs
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + //! Generic devices that are part of the kernel's driver model. 4 + //! 5 + //! C header: [`include/linux/device.h`](srctree/include/linux/device.h) 6 + 7 + use crate::{ 8 + bindings, 9 + types::{ARef, Opaque}, 10 + }; 11 + use core::ptr; 12 + 13 + /// A reference-counted device. 14 + /// 15 + /// This structure represents the Rust abstraction for a C `struct device`. This implementation 16 + /// abstracts the usage of an already existing C `struct device` within Rust code that we get 17 + /// passed from the C side. 18 + /// 19 + /// An instance of this abstraction can be obtained temporarily or permanent. 20 + /// 21 + /// A temporary one is bound to the lifetime of the C `struct device` pointer used for creation. 22 + /// A permanent instance is always reference-counted and hence not restricted by any lifetime 23 + /// boundaries. 24 + /// 25 + /// For subsystems it is recommended to create a permanent instance to wrap into a subsystem 26 + /// specific device structure (e.g. `pci::Device`). This is useful for passing it to drivers in 27 + /// `T::probe()`, such that a driver can store the `ARef<Device>` (equivalent to storing a 28 + /// `struct device` pointer in a C driver) for arbitrary purposes, e.g. allocating DMA coherent 29 + /// memory. 30 + /// 31 + /// # Invariants 32 + /// 33 + /// A `Device` instance represents a valid `struct device` created by the C portion of the kernel. 34 + /// 35 + /// Instances of this type are always reference-counted, that is, a call to `get_device` ensures 36 + /// that the allocation remains valid at least until the matching call to `put_device`. 37 + /// 38 + /// `bindings::device::release` is valid to be called from any thread, hence `ARef<Device>` can be 39 + /// dropped from any thread. 40 + #[repr(transparent)] 41 + pub struct Device(Opaque<bindings::device>); 42 + 43 + impl Device { 44 + /// Creates a new reference-counted abstraction instance of an existing `struct device` pointer. 45 + /// 46 + /// # Safety 47 + /// 48 + /// Callers must ensure that `ptr` is valid, non-null, and has a non-zero reference count, 49 + /// i.e. it must be ensured that the reference count of the C `struct device` `ptr` points to 50 + /// can't drop to zero, for the duration of this function call. 51 + /// 52 + /// It must also be ensured that `bindings::device::release` can be called from any thread. 53 + /// While not officially documented, this should be the case for any `struct device`. 54 + pub unsafe fn from_raw(ptr: *mut bindings::device) -> ARef<Self> { 55 + // SAFETY: By the safety requirements, ptr is valid. 56 + // Initially increase the reference count by one to compensate for the final decrement once 57 + // this newly created `ARef<Device>` instance is dropped. 58 + unsafe { bindings::get_device(ptr) }; 59 + 60 + // CAST: `Self` is a `repr(transparent)` wrapper around `bindings::device`. 61 + let ptr = ptr.cast::<Self>(); 62 + 63 + // SAFETY: `ptr` is valid by the safety requirements of this function. By the above call to 64 + // `bindings::get_device` we also own a reference to the underlying `struct device`. 65 + unsafe { ARef::from_raw(ptr::NonNull::new_unchecked(ptr)) } 66 + } 67 + 68 + /// Obtain the raw `struct device *`. 69 + pub(crate) fn as_raw(&self) -> *mut bindings::device { 70 + self.0.get() 71 + } 72 + 73 + /// Convert a raw C `struct device` pointer to a `&'a Device`. 74 + /// 75 + /// # Safety 76 + /// 77 + /// Callers must ensure that `ptr` is valid, non-null, and has a non-zero reference count, 78 + /// i.e. it must be ensured that the reference count of the C `struct device` `ptr` points to 79 + /// can't drop to zero, for the duration of this function call and the entire duration when the 80 + /// returned reference exists. 81 + pub unsafe fn as_ref<'a>(ptr: *mut bindings::device) -> &'a Self { 82 + // SAFETY: Guaranteed by the safety requirements of the function. 83 + unsafe { &*ptr.cast() } 84 + } 85 + } 86 + 87 + // SAFETY: Instances of `Device` are always reference-counted. 88 + unsafe impl crate::types::AlwaysRefCounted for Device { 89 + fn inc_ref(&self) { 90 + // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero. 91 + unsafe { bindings::get_device(self.as_raw()) }; 92 + } 93 + 94 + unsafe fn dec_ref(obj: ptr::NonNull<Self>) { 95 + // SAFETY: The safety requirements guarantee that the refcount is non-zero. 96 + unsafe { bindings::put_device(obj.cast().as_ptr()) } 97 + } 98 + } 99 + 100 + // SAFETY: As by the type invariant `Device` can be sent to any thread. 101 + unsafe impl Send for Device {} 102 + 103 + // SAFETY: `Device` can be shared among threads because all immutable methods are protected by the 104 + // synchronization in `struct device`. 105 + unsafe impl Sync for Device {}
+117
rust/kernel/firmware.rs
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + //! Firmware abstraction 4 + //! 5 + //! C header: [`include/linux/firmware.h`](srctree/include/linux/firmware.h") 6 + 7 + use crate::{bindings, device::Device, error::Error, error::Result, str::CStr}; 8 + use core::ptr::NonNull; 9 + 10 + /// # Invariants 11 + /// 12 + /// One of the following: `bindings::request_firmware`, `bindings::firmware_request_nowarn`, 13 + /// `bindings::firmware_request_platform`, `bindings::request_firmware_direct`. 14 + struct FwFunc( 15 + unsafe extern "C" fn(*mut *const bindings::firmware, *const i8, *mut bindings::device) -> i32, 16 + ); 17 + 18 + impl FwFunc { 19 + fn request() -> Self { 20 + Self(bindings::request_firmware) 21 + } 22 + 23 + fn request_nowarn() -> Self { 24 + Self(bindings::firmware_request_nowarn) 25 + } 26 + } 27 + 28 + /// Abstraction around a C `struct firmware`. 29 + /// 30 + /// This is a simple abstraction around the C firmware API. Just like with the C API, firmware can 31 + /// be requested. Once requested the abstraction provides direct access to the firmware buffer as 32 + /// `&[u8]`. The firmware is released once [`Firmware`] is dropped. 33 + /// 34 + /// # Invariants 35 + /// 36 + /// The pointer is valid, and has ownership over the instance of `struct firmware`. 37 + /// 38 + /// The `Firmware`'s backing buffer is not modified. 39 + /// 40 + /// # Examples 41 + /// 42 + /// ```no_run 43 + /// # use kernel::{c_str, device::Device, firmware::Firmware}; 44 + /// 45 + /// # fn no_run() -> Result<(), Error> { 46 + /// # // SAFETY: *NOT* safe, just for the example to get an `ARef<Device>` instance 47 + /// # let dev = unsafe { Device::from_raw(core::ptr::null_mut()) }; 48 + /// 49 + /// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev)?; 50 + /// let blob = fw.data(); 51 + /// 52 + /// # Ok(()) 53 + /// # } 54 + /// ``` 55 + pub struct Firmware(NonNull<bindings::firmware>); 56 + 57 + impl Firmware { 58 + fn request_internal(name: &CStr, dev: &Device, func: FwFunc) -> Result<Self> { 59 + let mut fw: *mut bindings::firmware = core::ptr::null_mut(); 60 + let pfw: *mut *mut bindings::firmware = &mut fw; 61 + 62 + // SAFETY: `pfw` is a valid pointer to a NULL initialized `bindings::firmware` pointer. 63 + // `name` and `dev` are valid as by their type invariants. 64 + let ret = unsafe { func.0(pfw as _, name.as_char_ptr(), dev.as_raw()) }; 65 + if ret != 0 { 66 + return Err(Error::from_errno(ret)); 67 + } 68 + 69 + // SAFETY: `func` not bailing out with a non-zero error code, guarantees that `fw` is a 70 + // valid pointer to `bindings::firmware`. 71 + Ok(Firmware(unsafe { NonNull::new_unchecked(fw) })) 72 + } 73 + 74 + /// Send a firmware request and wait for it. See also `bindings::request_firmware`. 75 + pub fn request(name: &CStr, dev: &Device) -> Result<Self> { 76 + Self::request_internal(name, dev, FwFunc::request()) 77 + } 78 + 79 + /// Send a request for an optional firmware module. See also 80 + /// `bindings::firmware_request_nowarn`. 81 + pub fn request_nowarn(name: &CStr, dev: &Device) -> Result<Self> { 82 + Self::request_internal(name, dev, FwFunc::request_nowarn()) 83 + } 84 + 85 + fn as_raw(&self) -> *mut bindings::firmware { 86 + self.0.as_ptr() 87 + } 88 + 89 + /// Returns the size of the requested firmware in bytes. 90 + pub fn size(&self) -> usize { 91 + // SAFETY: `self.as_raw()` is valid by the type invariant. 92 + unsafe { (*self.as_raw()).size } 93 + } 94 + 95 + /// Returns the requested firmware as `&[u8]`. 96 + pub fn data(&self) -> &[u8] { 97 + // SAFETY: `self.as_raw()` is valid by the type invariant. Additionally, 98 + // `bindings::firmware` guarantees, if successfully requested, that 99 + // `bindings::firmware::data` has a size of `bindings::firmware::size` bytes. 100 + unsafe { core::slice::from_raw_parts((*self.as_raw()).data, self.size()) } 101 + } 102 + } 103 + 104 + impl Drop for Firmware { 105 + fn drop(&mut self) { 106 + // SAFETY: `self.as_raw()` is valid by the type invariant. 107 + unsafe { bindings::release_firmware(self.as_raw()) }; 108 + } 109 + } 110 + 111 + // SAFETY: `Firmware` only holds a pointer to a C `struct firmware`, which is safe to be used from 112 + // any thread. 113 + unsafe impl Send for Firmware {} 114 + 115 + // SAFETY: `Firmware` only holds a pointer to a C `struct firmware`, references to which are safe to 116 + // be used from any thread. 117 + unsafe impl Sync for Firmware {}
+3
rust/kernel/lib.rs
··· 30 30 #[cfg(CONFIG_BLOCK)] 31 31 pub mod block; 32 32 mod build_assert; 33 + pub mod device; 33 34 pub mod error; 35 + #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)] 36 + pub mod firmware; 34 37 pub mod init; 35 38 pub mod ioctl; 36 39 #[cfg(CONFIG_KUNIT)]
+1
samples/kobject/kobject-example.c
··· 140 140 141 141 module_init(example_init); 142 142 module_exit(example_exit); 143 + MODULE_DESCRIPTION("Sample kobject implementation"); 143 144 MODULE_LICENSE("GPL v2"); 144 145 MODULE_AUTHOR("Greg Kroah-Hartman <greg@kroah.com>");
+1
samples/kobject/kset-example.c
··· 284 284 285 285 module_init(example_init); 286 286 module_exit(example_exit); 287 + MODULE_DESCRIPTION("Sample kset and ktype implementation"); 287 288 MODULE_LICENSE("GPL v2"); 288 289 MODULE_AUTHOR("Greg Kroah-Hartman <greg@kroah.com>");
+2 -4
samples/qmi/qmi_sample_client.c
··· 511 511 return ret; 512 512 } 513 513 514 - static int qmi_sample_remove(struct platform_device *pdev) 514 + static void qmi_sample_remove(struct platform_device *pdev) 515 515 { 516 516 struct qmi_sample *sample = platform_get_drvdata(pdev); 517 517 ··· 520 520 debugfs_remove(sample->de_dir); 521 521 522 522 qmi_handle_release(&sample->qmi); 523 - 524 - return 0; 525 523 } 526 524 527 525 static struct platform_driver qmi_sample_driver = { 528 526 .probe = qmi_sample_probe, 529 - .remove = qmi_sample_remove, 527 + .remove_new = qmi_sample_remove, 530 528 .driver = { 531 529 .name = "qmi_sample_client", 532 530 },
+2 -2
sound/ac97/bus.c
··· 469 469 }; 470 470 ATTRIBUTE_GROUPS(ac97_dev); 471 471 472 - static int ac97_bus_match(struct device *dev, struct device_driver *drv) 472 + static int ac97_bus_match(struct device *dev, const struct device_driver *drv) 473 473 { 474 474 struct ac97_codec_device *adev = to_ac97_device(dev); 475 - struct ac97_codec_driver *adrv = to_ac97_driver(drv); 475 + const struct ac97_codec_driver *adrv = to_ac97_driver(drv); 476 476 const struct ac97_id *id = adrv->id_table; 477 477 int i = 0; 478 478
+2 -2
sound/core/seq_device.c
··· 40 40 /* 41 41 * bus definition 42 42 */ 43 - static int snd_seq_bus_match(struct device *dev, struct device_driver *drv) 43 + static int snd_seq_bus_match(struct device *dev, const struct device_driver *drv) 44 44 { 45 45 struct snd_seq_device *sdev = to_seq_dev(dev); 46 46 struct snd_seq_driver *sdrv = to_seq_drv(drv); ··· 234 234 put_device(&dev->dev); 235 235 return err; 236 236 } 237 - 237 + 238 238 if (result) 239 239 *result = dev; 240 240
+1 -1
sound/hda/hda_bus_type.c
··· 46 46 return 0; 47 47 } 48 48 49 - static int hda_bus_match(struct device *dev, struct device_driver *drv) 49 + static int hda_bus_match(struct device *dev, const struct device_driver *drv) 50 50 { 51 51 struct hdac_device *hdev = dev_to_hdac_dev(dev); 52 52 struct hdac_driver *hdrv = drv_to_hdac_driver(drv);
+2 -2
sound/soc/sof/sof-client.c
··· 357 357 358 358 int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state) 359 359 { 360 - struct auxiliary_driver *adrv; 360 + const struct auxiliary_driver *adrv; 361 361 struct sof_client_dev *cdev; 362 362 363 363 mutex_lock(&sdev->ipc_client_mutex); ··· 380 380 381 381 int sof_resume_clients(struct snd_sof_dev *sdev) 382 382 { 383 - struct auxiliary_driver *adrv; 383 + const struct auxiliary_driver *adrv; 384 384 struct sof_client_dev *cdev; 385 385 386 386 mutex_lock(&sdev->ipc_client_mutex);