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

Configure Feed

Select the types of activity you want to include in your feed.

driver core: have match() callback in struct bus_type take a const *

In the match() callback, the struct device_driver * should not be
changed, so change the function callback to be a const *. This is one
step of many towards making the driver core safe to have struct
device_driver in read-only memory.

Because the match() callback is in all busses, all busses are modified
to handle this properly. This does entail switching some container_of()
calls to container_of_const() to properly handle the constant *.

For some busses, like PCI and USB and HV, the const * is cast away in
the match callback as those busses do want to modify those structures at
this point in time (they have a local lock in the driver structure.)
That will have to be changed in the future if they wish to have their
struct device * in read-only-memory.

Cc: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Alex Elder <elder@kernel.org>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Link: https://lore.kernel.org/r/2024070136-wrongdoer-busily-01e8@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+268 -338
+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 }
+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/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
··· 1045 1045 ACPI Bus operations 1046 1046 -------------------------------------------------------------------------- */ 1047 1047 1048 - static int acpi_bus_match(struct device *dev, struct device_driver *drv) 1048 + static int acpi_bus_match(struct device *dev, const struct device_driver *drv) 1049 1049 { 1050 1050 struct acpi_device *acpi_dev = to_acpi_device(dev); 1051 - struct acpi_driver *acpi_drv = to_acpi_driver(drv); 1051 + const struct acpi_driver *acpi_drv = to_acpi_driver(drv); 1052 1052 1053 1053 return acpi_dev->flags.match_driver 1054 1054 && !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) {
+1 -1
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 183 const struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
+1 -2
drivers/base/base.h
··· 164 164 static inline int driver_match_device(const struct device_driver *drv, 165 165 struct device *dev) 166 166 { 167 - /* cast will be removed in the future when match can handle a const pointer properly. */ 168 - return drv->bus->match ? drv->bus->match(dev, (struct device_driver *)drv) : 1; 167 + return drv->bus->match ? drv->bus->match(dev, drv) : 1; 169 168 } 170 169 171 170 static inline void dev_sync_state(struct device *dev)
+1 -1
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))
+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
+1 -1
drivers/base/platform.c
··· 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);
+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
··· 823 823 int id; 824 824 }; 825 825 826 - static inline struct cxl_driver *to_cxl_drv(struct device_driver *drv) 827 - { 828 - return container_of(drv, struct cxl_driver, drv); 829 - } 826 + #define to_cxl_drv(__drv) container_of_const(__drv, struct cxl_driver, drv) 830 827 831 828 int __cxl_driver_register(struct cxl_driver *cxl_drv, struct module *owner, 832 829 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;
+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
+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)
+1 -1
drivers/gpio/gpiolib.c
··· 53 53 static dev_t gpio_devt; 54 54 #define GPIO_DEV_MAX 256 /* 256 GPIO chip devices supported */ 55 55 56 - static int gpio_bus_match(struct device *dev, struct device_driver *drv) 56 + static int gpio_bus_match(struct device *dev, const struct device_driver *drv) 57 57 { 58 58 struct fwnode_handle *fwnode = dev_fwnode(dev); 59 59
+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
+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 -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
··· 2562 2562 } 2563 2563 EXPORT_SYMBOL_GPL(hid_match_device); 2564 2564 2565 - static int hid_bus_match(struct device *dev, struct device_driver *drv) 2565 + static int hid_bus_match(struct device *dev, const struct device_driver *drv) 2566 2566 { 2567 2567 struct hid_driver *hdrv = to_hid_driver(drv); 2568 2568 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);
+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/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 }
+3 -3
drivers/nvdimm/bus.c
··· 272 272 } 273 273 EXPORT_SYMBOL_GPL(nvdimm_clear_poison); 274 274 275 - static int nvdimm_bus_match(struct device *dev, struct device_driver *drv); 275 + static int nvdimm_bus_match(struct device *dev, const struct device_driver *drv); 276 276 277 277 static const struct bus_type nvdimm_bus_type = { 278 278 .name = "nd", ··· 468 468 }, 469 469 }; 470 470 471 - static int nvdimm_bus_match(struct device *dev, struct device_driver *drv) 471 + static int nvdimm_bus_match(struct device *dev, const struct device_driver *drv) 472 472 { 473 - struct nd_device_driver *nd_drv = to_nd_device_driver(drv); 473 + const struct nd_device_driver *nd_drv = to_nd_device_driver(drv); 474 474 475 475 if (is_nvdimm_bus(dev) && nd_drv == &nd_bus_driver) 476 476 return true;
+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 }
+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
··· 173 173 return NULL; 174 174 } 175 175 176 - static int peci_bus_device_match(struct device *dev, struct device_driver *drv) 176 + static int peci_bus_device_match(struct device *dev, const struct device_driver *drv) 177 177 { 178 178 struct peci_device *device = to_peci_device(dev); 179 - struct peci_driver *peci_drv = to_peci_driver(drv); 179 + const struct peci_driver *peci_drv = to_peci_driver(drv); 180 180 181 181 if (dev->type != &peci_device_type) 182 182 return 0;
+1 -4
drivers/peci/internal.h
··· 98 98 const struct peci_device_id *id_table; 99 99 }; 100 100 101 - static inline struct peci_driver *to_peci_driver(struct device_driver *d) 102 - { 103 - return container_of(d, struct peci_driver, driver); 104 - } 101 + #define to_peci_driver(__drv) container_of_const(__drv, struct peci_driver, driver) 105 102 106 103 int __peci_driver_register(struct peci_driver *driver, struct module *owner, 107 104 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 ··· 845 848 kfree(wblock); 846 849 } 847 850 848 - static int wmi_dev_match(struct device *dev, struct device_driver *driver) 851 + static int wmi_dev_match(struct device *dev, const struct device_driver *driver) 849 852 { 850 - struct wmi_driver *wmi_driver = drv_to_wdrv(driver); 853 + const struct wmi_driver *wmi_driver = drv_to_wdrv(driver); 851 854 struct wmi_block *wblock = dev_to_wblock(dev); 852 855 const struct wmi_device_id *id = wmi_driver->id_table; 853 856
+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 -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 -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
··· 855 855 return false; 856 856 } 857 857 858 - static int usb_device_match(struct device *dev, struct device_driver *drv) 858 + static int usb_device_match(struct device *dev, const struct device_driver *drv) 859 859 { 860 860 /* devices and interfaces are handled separately */ 861 861 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;
+1 -1
include/acpi/acpi_bus.h
··· 562 562 } 563 563 564 564 #define to_acpi_device(d) container_of(d, struct acpi_device, dev) 565 - #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) 565 + #define to_acpi_driver(d) container_of_const(d, struct acpi_driver, drv) 566 566 567 567 static inline struct acpi_device *acpi_dev_parent(struct acpi_device *adev) 568 568 {
+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/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) \
+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);
+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/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
··· 304 304 305 305 u32 flags; 306 306 }; 307 - #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 307 + #define to_i2c_driver(d) container_of_const(d, struct i2c_driver, driver) 308 308 309 309 /** 310 310 * 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
··· 526 526 struct device_driver driver; 527 527 }; 528 528 529 - #define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver) 529 + #define to_mhi_driver(drv) container_of_const(drv, struct mhi_driver, driver) 530 530 #define to_mhi_device(dev) container_of(dev, struct mhi_device, dev) 531 531 532 532 /**
+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
··· 105 105 const struct pci_epf_device_id *id_table; 106 106 }; 107 107 108 - #define to_pci_epf_driver(drv) (container_of((drv), struct pci_epf_driver, \ 109 - driver)) 108 + #define to_pci_epf_driver(drv) container_of_const((drv), struct pci_epf_driver, driver) 110 109 111 110 /** 112 111 * struct pci_epf_bar - represents the BAR of EPF device
+2 -4
include/linux/pci.h
··· 958 958 bool driver_managed_dma; 959 959 }; 960 960 961 - static inline struct pci_driver *to_pci_driver(struct device_driver *drv) 962 - { 963 - return drv ? container_of(drv, struct pci_driver, driver) : NULL; 964 - } 961 + #define to_pci_driver(__drv) \ 962 + ( __drv ? container_of_const(__drv, struct pci_driver, driver) : NULL ) 965 963 966 964 /** 967 965 * PCI_DEVICE - macro used to describe a specific PCI device
+1 -1
include/linux/phy.h
··· 1179 1179 int (*led_polarity_set)(struct phy_device *dev, int index, 1180 1180 unsigned long modes); 1181 1181 }; 1182 - #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ 1182 + #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d), \ 1183 1183 struct phy_driver, mdiodrv) 1184 1184 1185 1185 #define PHY_ANY_ID "MATCH ANY PHY"
+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/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,
+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 }
+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);