driver core: have match() callback in struct bus_type take a const *
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jul 2024 12:07:37 +0000 (14:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jul 2024 13:16:54 +0000 (15:16 +0200)
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>
163 files changed:
arch/arm/common/locomo.c
arch/arm/include/asm/hardware/locomo.h
arch/parisc/include/asm/parisc-device.h
arch/parisc/kernel/drivers.c
arch/powerpc/include/asm/ps3.h
arch/powerpc/include/asm/vio.h
arch/powerpc/platforms/ps3/system-bus.c
arch/powerpc/platforms/pseries/ibmebus.c
arch/powerpc/platforms/pseries/vio.c
arch/s390/include/asm/ccwdev.h
arch/sparc/include/asm/vio.h
arch/sparc/kernel/vio.c
drivers/acpi/bus.c
drivers/amba/bus.c
drivers/base/auxiliary.c
drivers/base/base.h
drivers/base/cpu.c
drivers/base/isa.c
drivers/base/platform.c
drivers/bcma/main.c
drivers/bus/fsl-mc/fsl-mc-bus.c
drivers/bus/mhi/ep/main.c
drivers/bus/mhi/host/init.c
drivers/bus/mips_cdmm.c
drivers/bus/moxtet.c
drivers/bus/sunxi-rsb.c
drivers/cdx/cdx.c
drivers/cxl/core/port.c
drivers/cxl/cxl.h
drivers/dax/bus.c
drivers/dma/idxd/bus.c
drivers/eisa/eisa-bus.c
drivers/firewire/core-device.c
drivers/firmware/arm_ffa/bus.c
drivers/firmware/arm_scmi/bus.c
drivers/firmware/google/coreboot_table.c
drivers/fpga/dfl.c
drivers/fsi/fsi-core.c
drivers/gpio/gpiolib.c
drivers/gpu/drm/display/drm_dp_aux_bus.c
drivers/gpu/drm/drm_mipi_dsi.c
drivers/gpu/host1x/bus.c
drivers/greybus/core.c
drivers/hid/hid-core.c
drivers/hid/intel-ish-hid/ishtp/bus.c
drivers/hsi/hsi_core.c
drivers/hv/vmbus_drv.c
drivers/hwtracing/intel_th/core.c
drivers/hwtracing/intel_th/intel_th.h
drivers/i2c/i2c-core-base.c
drivers/i3c/master.c
drivers/input/gameport/gameport.c
drivers/input/rmi4/rmi_bus.c
drivers/input/rmi4/rmi_bus.h
drivers/input/rmi4/rmi_driver.c
drivers/input/rmi4/rmi_driver.h
drivers/input/serio/serio.c
drivers/ipack/ipack.c
drivers/macintosh/macio_asic.c
drivers/mcb/mcb-core.c
drivers/media/pci/bt8xx/bttv-gpio.c
drivers/media/pci/bt8xx/bttv.h
drivers/memstick/core/memstick.c
drivers/mfd/mcp-core.c
drivers/misc/mei/bus.c
drivers/misc/tifm_core.c
drivers/mmc/core/sdio_bus.c
drivers/most/core.c
drivers/net/phy/mdio_bus.c
drivers/net/phy/mdio_device.c
drivers/net/phy/phy_device.c
drivers/ntb/ntb_transport.c
drivers/nvdimm/bus.c
drivers/nvmem/layouts.c
drivers/pci/endpoint/pci-epf-core.c
drivers/pci/pci-driver.c
drivers/pcmcia/ds.c
drivers/peci/core.c
drivers/peci/internal.h
drivers/platform/surface/aggregator/bus.c
drivers/platform/x86/wmi.c
drivers/pnp/driver.c
drivers/rapidio/rio-driver.c
drivers/rpmsg/rpmsg_core.c
drivers/rpmsg/rpmsg_internal.h
drivers/s390/cio/css.c
drivers/s390/cio/css.h
drivers/s390/cio/device.c
drivers/s390/crypto/ap_bus.c
drivers/s390/crypto/ap_bus.h
drivers/scsi/fcoe/fcoe_sysfs.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/scsi_transport_iscsi.c
drivers/sh/maple/maple.c
drivers/siox/siox-core.c
drivers/slimbus/core.c
drivers/soc/qcom/apr.c
drivers/soundwire/bus_type.c
drivers/spi/spi.c
drivers/spmi/spmi.c
drivers/ssb/main.c
drivers/staging/fieldbus/anybuss/anybuss-client.h
drivers/staging/fieldbus/anybuss/host.c
drivers/staging/greybus/gbphy.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_bus.c
drivers/staging/vme_user/vme.c
drivers/tc/tc-driver.c
drivers/tee/tee_core.c
drivers/thunderbolt/domain.c
drivers/tty/serdev/core.c
drivers/tty/serial/serial_base_bus.c
drivers/usb/common/ulpi.c
drivers/usb/core/driver.c
drivers/usb/gadget/udc/core.c
drivers/usb/serial/bus.c
drivers/usb/typec/bus.c
drivers/vdpa/vdpa.c
drivers/vfio/mdev/mdev_driver.c
drivers/virtio/virtio.c
drivers/xen/xenbus/xenbus.h
drivers/xen/xenbus/xenbus_probe.c
include/acpi/acpi_bus.h
include/linux/arm_ffa.h
include/linux/cdx/cdx_bus.h
include/linux/device/bus.h
include/linux/dfl.h
include/linux/eisa.h
include/linux/fsi.h
include/linux/fsl/mc.h
include/linux/gameport.h
include/linux/greybus.h
include/linux/hyperv.h
include/linux/i2c.h
include/linux/i3c/device.h
include/linux/maple.h
include/linux/mcb.h
include/linux/mdio.h
include/linux/mhi.h
include/linux/mhi_ep.h
include/linux/moxtet.h
include/linux/nd.h
include/linux/pci-epf.h
include/linux/pci.h
include/linux/phy.h
include/linux/pnp.h
include/linux/rio.h
include/linux/scmi_protocol.h
include/linux/serio.h
include/linux/slimbus.h
include/linux/soc/qcom/apr.h
include/linux/soundwire/sdw_type.h
include/linux/spi/spi.h
include/linux/ssb/ssb.h
include/linux/tc.h
include/linux/tee_drv.h
include/linux/virtio.h
include/scsi/scsi_transport_iscsi.h
include/sound/ac97/codec.h
include/xen/xenbus.h
net/iucv/iucv.c
sound/ac97/bus.c
sound/core/seq_device.c
sound/hda/hda_bus_type.c

index 6d0c9f7..06b0e5f 100644 (file)
@@ -816,10 +816,10 @@ EXPORT_SYMBOL(locomo_frontlight_set);
  *     We model this as a regular bus type, and hang devices directly
  *     off this.
  */
-static int locomo_match(struct device *_dev, struct device_driver *_drv)
+static int locomo_match(struct device *_dev, const struct device_driver *_drv)
 {
        struct locomo_dev *dev = LOCOMO_DEV(_dev);
-       struct locomo_driver *drv = LOCOMO_DRV(_drv);
+       const struct locomo_driver *drv = LOCOMO_DRV(_drv);
 
        return dev->devid == drv->devid;
 }
index 9fd9ad5..3190e1e 100644 (file)
@@ -189,7 +189,7 @@ struct locomo_driver {
        void (*remove)(struct locomo_dev *);
 };
 
-#define LOCOMO_DRV(_d) container_of((_d), struct locomo_driver, drv)
+#define LOCOMO_DRV(_d) container_of_const((_d), struct locomo_driver, drv)
 
 #define LOCOMO_DRIVER_NAME(_ldev) ((_ldev)->dev.driver->name)
 
index 7ddd7f4..9e74cef 100644 (file)
@@ -41,7 +41,7 @@ struct parisc_driver {
 
 
 #define to_parisc_device(d)    container_of(d, struct parisc_device, dev)
-#define to_parisc_driver(d)    container_of(d, struct parisc_driver, drv)
+#define to_parisc_driver(d)    container_of_const(d, struct parisc_driver, drv)
 #define parisc_parent(d)       to_parisc_device(d->dev.parent)
 
 static inline const char *parisc_pathname(struct parisc_device *d)
index ac19d68..1e793f7 100644 (file)
@@ -97,7 +97,7 @@ static int for_each_padev(int (*fn)(struct device *, void *), void * data)
  * @driver: the PA-RISC driver to try
  * @dev: the PA-RISC device to try
  */
-static int match_device(struct parisc_driver *driver, struct parisc_device *dev)
+static int match_device(const struct parisc_driver *driver, struct parisc_device *dev)
 {
        const struct parisc_device_id *ids;
 
@@ -548,7 +548,7 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
        return dev;
 }
 
-static int parisc_generic_match(struct device *dev, struct device_driver *drv)
+static int parisc_generic_match(struct device *dev, const struct device_driver *drv)
 {
        return match_device(to_parisc_driver(drv), to_parisc_device(dev));
 }
index d13d8fd..987e23a 100644 (file)
@@ -390,11 +390,7 @@ int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
 int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
 void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
 
-static inline struct ps3_system_bus_driver *ps3_drv_to_system_bus_drv(
-       struct device_driver *_drv)
-{
-       return container_of(_drv, struct ps3_system_bus_driver, core);
-}
+#define ps3_drv_to_system_bus_drv(_drv) container_of_const(_drv, struct ps3_system_bus_driver, core)
 static inline struct ps3_system_bus_device *ps3_dev_to_system_bus_dev(
        const struct device *_dev)
 {
index 6faf2a9..7c44415 100644 (file)
@@ -156,11 +156,7 @@ static inline int vio_enable_interrupts(struct vio_dev *dev)
 }
 #endif
 
-static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
-{
-       return container_of(drv, struct vio_driver, driver);
-}
-
+#define to_vio_driver(__drv)   container_of_const(__drv, struct vio_driver, driver)
 #define to_vio_dev(__dev)      container_of_const(__dev, struct vio_dev, dev)
 
 #endif /* __KERNEL__ */
index 56dc6b2..b9a7d9b 100644 (file)
@@ -333,10 +333,10 @@ int ps3_mmio_region_init(struct ps3_system_bus_device *dev,
 EXPORT_SYMBOL_GPL(ps3_mmio_region_init);
 
 static int ps3_system_bus_match(struct device *_dev,
-       struct device_driver *_drv)
+       const struct device_driver *_drv)
 {
        int result;
-       struct ps3_system_bus_driver *drv = ps3_drv_to_system_bus_drv(_drv);
+       const struct ps3_system_bus_driver *drv = ps3_drv_to_system_bus_drv(_drv);
        struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 
        if (!dev->match_sub_id)
index b401282..3436b0a 100644 (file)
@@ -339,7 +339,7 @@ static struct attribute *ibmbus_bus_attrs[] = {
 };
 ATTRIBUTE_GROUPS(ibmbus_bus);
 
-static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
+static int ibmebus_bus_bus_match(struct device *dev, const struct device_driver *drv)
 {
        const struct of_device_id *matches = drv->of_match_table;
 
index 36d1c7d..ac1d2d2 100644 (file)
@@ -1576,10 +1576,10 @@ void vio_unregister_device(struct vio_dev *viodev)
 }
 EXPORT_SYMBOL(vio_unregister_device);
 
-static int vio_bus_match(struct device *dev, struct device_driver *drv)
+static int vio_bus_match(struct device *dev, const struct device_driver *drv)
 {
        const struct vio_dev *vio_dev = to_vio_dev(dev);
-       struct vio_driver *vio_drv = to_vio_driver(drv);
+       const struct vio_driver *vio_drv = to_vio_driver(drv);
        const struct vio_device_id *ids = vio_drv->id_table;
 
        return (ids != NULL) && (vio_match_device(ids, vio_dev) != NULL);
@@ -1689,7 +1689,7 @@ struct vio_dev *vio_find_node(struct device_node *vnode)
        /* construct the kobject name from the device node */
        if (of_node_is_type(vnode_parent, "vdevice")) {
                const __be32 *prop;
-               
+
                prop = of_get_property(vnode, "reg", NULL);
                if (!prop)
                        goto out;
index 436365f..e3afcec 100644 (file)
@@ -210,7 +210,7 @@ extern void ccw_device_get_id(struct ccw_device *, struct ccw_dev_id *);
 #define get_ccwdev_lock(x) (x)->ccwlock
 
 #define to_ccwdev(n) container_of(n, struct ccw_device, dev)
-#define to_ccwdrv(n) container_of(n, struct ccw_driver, driver)
+#define to_ccwdrv(n) container_of_const(n, struct ccw_driver, driver)
 
 extern struct ccw_device *ccw_device_create_console(struct ccw_driver *);
 extern void ccw_device_destroy_console(struct ccw_device *);
index 587fb78..0ca8c34 100644 (file)
@@ -483,11 +483,7 @@ int __vio_register_driver(struct vio_driver *drv, struct module *owner,
        __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
 void vio_unregister_driver(struct vio_driver *drv);
 
-static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
-{
-       return container_of(drv, struct vio_driver, driver);
-}
-
+#define to_vio_driver(__drv)   container_of_const(__drv, struct vio_driver, driver)
 #define to_vio_dev(__dev)      container_of_const(__dev, struct vio_dev, dev)
 
 int vio_ldc_send(struct vio_driver_state *vio, void *data, int len);
index 846a55f..07933d7 100644 (file)
@@ -54,10 +54,10 @@ static int vio_hotplug(const struct device *dev, struct kobj_uevent_env *env)
        return 0;
 }
 
-static int vio_bus_match(struct device *dev, struct device_driver *drv)
+static int vio_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct vio_dev *vio_dev = to_vio_dev(dev);
-       struct vio_driver *vio_drv = to_vio_driver(drv);
+       const struct vio_driver *vio_drv = to_vio_driver(drv);
        const struct vio_device_id *matches = vio_drv->id_table;
 
        if (!matches)
index 787eca8..d3e1457 100644 (file)
@@ -1045,10 +1045,10 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver);
                               ACPI Bus operations
    -------------------------------------------------------------------------- */
 
-static int acpi_bus_match(struct device *dev, struct device_driver *drv)
+static int acpi_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct acpi_device *acpi_dev = to_acpi_device(dev);
-       struct acpi_driver *acpi_drv = to_acpi_driver(drv);
+       const struct acpi_driver *acpi_drv = to_acpi_driver(drv);
 
        return acpi_dev->flags.match_driver
                && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
index aba3aa9..34bc880 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/iommu.h>
 #include <linux/dma-map-ops.h>
 
-#define to_amba_driver(d)      container_of(d, struct amba_driver, drv)
+#define to_amba_driver(d)      container_of_const(d, struct amba_driver, drv)
 
 /* called on periphid match and class 0x9 coresight device. */
 static int
@@ -205,10 +205,10 @@ err_out:
        return ret;
 }
 
-static int amba_match(struct device *dev, struct device_driver *drv)
+static int amba_match(struct device *dev, const struct device_driver *drv)
 {
        struct amba_device *pcdev = to_amba_device(dev);
-       struct amba_driver *pcdrv = to_amba_driver(drv);
+       const struct amba_driver *pcdrv = to_amba_driver(drv);
 
        mutex_lock(&pcdev->periphid_lock);
        if (!pcdev->periphid) {
index 5832e31..95408b7 100644 (file)
@@ -177,7 +177,7 @@ static const struct auxiliary_device_id *auxiliary_match_id(const struct auxilia
        return NULL;
 }
 
-static int auxiliary_match(struct device *dev, struct device_driver *drv)
+static int auxiliary_match(struct device *dev, const struct device_driver *drv)
 {
        struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
        const struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
index 8bef47a..0886f55 100644 (file)
@@ -164,8 +164,7 @@ void device_set_deferred_probe_reason(const struct device *dev, struct va_format
 static inline int driver_match_device(const struct device_driver *drv,
                                      struct device *dev)
 {
-       /* cast will be removed in the future when match can handle a const pointer properly. */
-       return drv->bus->match ? drv->bus->match(dev, (struct device_driver *)drv) : 1;
+       return drv->bus->match ? drv->bus->match(dev, drv) : 1;
 }
 
 static inline void dev_sync_state(struct device *dev)
index c61ecb0..4901fbf 100644 (file)
@@ -26,7 +26,7 @@
 
 static DEFINE_PER_CPU(struct device *, cpu_sys_devices);
 
-static int cpu_subsys_match(struct device *dev, struct device_driver *drv)
+static int cpu_subsys_match(struct device *dev, const struct device_driver *drv)
 {
        /* ACPI style match is the only one that may succeed. */
        if (acpi_driver_match_device(dev, drv))
index e23d0b4..bfd9215 100644 (file)
@@ -23,7 +23,7 @@ struct isa_dev {
 
 #define to_isa_dev(x) container_of((x), struct isa_dev, dev)
 
-static int isa_bus_match(struct device *dev, struct device_driver *driver)
+static int isa_bus_match(struct device *dev, const struct device_driver *driver)
 {
        struct isa_driver *isa_driver = to_isa_driver(driver);
 
index a688447..8a511fe 100644 (file)
@@ -1332,7 +1332,7 @@ __ATTRIBUTE_GROUPS(platform_dev);
  * and compare it against the name of the driver. Return whether they match
  * or not.
  */
-static int platform_match(struct device *dev, struct device_driver *drv)
+static int platform_match(struct device *dev, const struct device_driver *drv)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct platform_driver *pdrv = to_platform_driver(drv);
index 6b5d349..6ecfc82 100644 (file)
@@ -26,7 +26,7 @@ static unsigned int bcma_bus_next_num;
 /* bcma_buses_mutex locks the bcma_bus_next_num */
 static DEFINE_MUTEX(bcma_buses_mutex);
 
-static int bcma_bus_match(struct device *dev, struct device_driver *drv);
+static int bcma_bus_match(struct device *dev, const struct device_driver *drv);
 static int bcma_device_probe(struct device *dev);
 static void bcma_device_remove(struct device *dev);
 static int bcma_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
@@ -584,10 +584,10 @@ void bcma_driver_unregister(struct bcma_driver *drv)
 }
 EXPORT_SYMBOL_GPL(bcma_driver_unregister);
 
-static int bcma_bus_match(struct device *dev, struct device_driver *drv)
+static int bcma_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct bcma_device *core = container_of(dev, struct bcma_device, dev);
-       struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
+       const struct bcma_driver *adrv = container_of_const(drv, struct bcma_driver, drv);
        const struct bcma_device_id *cid = &core->id;
        const struct bcma_device_id *did;
 
index 78b96cd..dd68b81 100644 (file)
@@ -80,11 +80,11 @@ static phys_addr_t mc_portal_base_phys_addr;
  *
  * Returns 1 on success, 0 otherwise.
  */
-static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
+static int fsl_mc_bus_match(struct device *dev, const struct device_driver *drv)
 {
        const struct fsl_mc_device_id *id;
        struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
-       struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
+       const struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
        bool found = false;
 
        /* When driver_override is set, only bind to the matching driver */
index f8f674a..b193c2d 100644 (file)
@@ -1694,10 +1694,10 @@ static int mhi_ep_uevent(const struct device *dev, struct kobj_uevent_env *env)
                                        mhi_dev->name);
 }
 
-static int mhi_ep_match(struct device *dev, struct device_driver *drv)
+static int mhi_ep_match(struct device *dev, const struct device_driver *drv)
 {
        struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev);
-       struct mhi_ep_driver *mhi_drv = to_mhi_ep_driver(drv);
+       const struct mhi_ep_driver *mhi_drv = to_mhi_ep_driver(drv);
        const struct mhi_device_id *id;
 
        /*
index 173f799..ce7d2e6 100644 (file)
@@ -1442,10 +1442,10 @@ static int mhi_uevent(const struct device *dev, struct kobj_uevent_env *env)
                                        mhi_dev->name);
 }
 
-static int mhi_match(struct device *dev, struct device_driver *drv)
+static int mhi_match(struct device *dev, const struct device_driver *drv)
 {
        struct mhi_device *mhi_dev = to_mhi_device(dev);
-       struct mhi_driver *mhi_drv = to_mhi_driver(drv);
+       const struct mhi_driver *mhi_drv = to_mhi_driver(drv);
        const struct mhi_device_id *id;
 
        /*
index 8baf14b..12dd32f 100644 (file)
@@ -37,7 +37,7 @@
 /* Each block of device registers is 64 bytes */
 #define CDMM_DRB_SIZE          64
 
-#define to_mips_cdmm_driver(d) container_of(d, struct mips_cdmm_driver, drv)
+#define to_mips_cdmm_driver(d) container_of_const(d, struct mips_cdmm_driver, drv)
 
 /* Default physical base address */
 static phys_addr_t mips_cdmm_default_base;
@@ -59,10 +59,10 @@ mips_cdmm_lookup(const struct mips_cdmm_device_id *table,
        return ret ? table : NULL;
 }
 
-static int mips_cdmm_match(struct device *dev, struct device_driver *drv)
+static int mips_cdmm_match(struct device *dev, const struct device_driver *drv)
 {
        struct mips_cdmm_device *cdev = to_mips_cdmm_device(dev);
-       struct mips_cdmm_driver *cdrv = to_mips_cdmm_driver(drv);
+       const struct mips_cdmm_driver *cdrv = to_mips_cdmm_driver(drv);
 
        return mips_cdmm_lookup(cdrv->id_table, cdev) != NULL;
 }
index 641c1a6..8412406 100644 (file)
@@ -83,10 +83,10 @@ static const struct attribute_group *moxtet_dev_groups[] = {
        NULL,
 };
 
-static int moxtet_match(struct device *dev, struct device_driver *drv)
+static int moxtet_match(struct device *dev, const struct device_driver *drv)
 {
        struct moxtet_device *mdev = to_moxtet_device(dev);
-       struct moxtet_driver *tdrv = to_moxtet_driver(drv);
+       const struct moxtet_driver *tdrv = to_moxtet_driver(drv);
        const enum turris_mox_module_id *t;
 
        if (of_driver_match_device(dev, drv))
index 1e29ba7..a2a7576 100644 (file)
@@ -130,7 +130,7 @@ struct sunxi_rsb {
 /* bus / slave device related functions */
 static const struct bus_type sunxi_rsb_bus;
 
-static int sunxi_rsb_device_match(struct device *dev, struct device_driver *drv)
+static int sunxi_rsb_device_match(struct device *dev, const struct device_driver *drv)
 {
        return of_driver_match_device(dev, drv);
 }
index 236d381..07371cb 100644 (file)
@@ -262,10 +262,10 @@ EXPORT_SYMBOL_GPL(cdx_clear_master);
  *
  * Return: true on success, false otherwise.
  */
-static int cdx_bus_match(struct device *dev, struct device_driver *drv)
+static int cdx_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct cdx_device *cdx_dev = to_cdx_device(dev);
-       struct cdx_driver *cdx_drv = to_cdx_driver(drv);
+       const struct cdx_driver *cdx_drv = to_cdx_driver(drv);
        const struct cdx_device_id *found_id = NULL;
        const struct cdx_device_id *ids;
 
index 887ed6e..cb73005 100644 (file)
@@ -2082,7 +2082,7 @@ static int cxl_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
                              cxl_device_id(dev));
 }
 
-static int cxl_bus_match(struct device *dev, struct device_driver *drv)
+static int cxl_bus_match(struct device *dev, const struct device_driver *drv)
 {
        return cxl_device_id(dev) == to_cxl_drv(drv)->id;
 }
index 603c012..65c91e1 100644 (file)
@@ -823,10 +823,7 @@ struct cxl_driver {
        int id;
 };
 
-static inline struct cxl_driver *to_cxl_drv(struct device_driver *drv)
-{
-       return container_of(drv, struct cxl_driver, drv);
-}
+#define to_cxl_drv(__drv)      container_of_const(__drv, struct cxl_driver, drv)
 
 int __cxl_driver_register(struct cxl_driver *cxl_drv, struct module *owner,
                          const char *modname);
index 3ef9550..fde29e0 100644 (file)
@@ -39,12 +39,9 @@ static int dax_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
        return add_uevent_var(env, "MODALIAS=" DAX_DEVICE_MODALIAS_FMT, 0);
 }
 
-static struct dax_device_driver *to_dax_drv(struct device_driver *drv)
-{
-       return container_of(drv, struct dax_device_driver, drv);
-}
+#define to_dax_drv(__drv)      container_of_const(__drv, struct dax_device_driver, drv)
 
-static struct dax_id *__dax_match_id(struct dax_device_driver *dax_drv,
+static struct dax_id *__dax_match_id(const struct dax_device_driver *dax_drv,
                const char *dev_name)
 {
        struct dax_id *dax_id;
@@ -57,7 +54,7 @@ static struct dax_id *__dax_match_id(struct dax_device_driver *dax_drv,
        return NULL;
 }
 
-static int dax_match_id(struct dax_device_driver *dax_drv, struct device *dev)
+static int dax_match_id(const struct dax_device_driver *dax_drv, struct device *dev)
 {
        int match;
 
@@ -68,7 +65,7 @@ static int dax_match_id(struct dax_device_driver *dax_drv, struct device *dev)
        return match;
 }
 
-static int dax_match_type(struct dax_device_driver *dax_drv, struct device *dev)
+static int dax_match_type(const struct dax_device_driver *dax_drv, struct device *dev)
 {
        enum dax_driver_type type = DAXDRV_DEVICE_TYPE;
        struct dev_dax *dev_dax = to_dev_dax(dev);
@@ -156,7 +153,7 @@ static struct attribute *dax_drv_attrs[] = {
 };
 ATTRIBUTE_GROUPS(dax_drv);
 
-static int dax_bus_match(struct device *dev, struct device_driver *drv);
+static int dax_bus_match(struct device *dev, const struct device_driver *drv);
 
 /*
  * Static dax regions are regions created by an external subsystem
@@ -250,9 +247,9 @@ static const struct bus_type dax_bus_type = {
        .drv_groups = dax_drv_groups,
 };
 
-static int dax_bus_match(struct device *dev, struct device_driver *drv)
+static int dax_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct dax_device_driver *dax_drv = to_dax_drv(drv);
+       const struct dax_device_driver *dax_drv = to_dax_drv(drv);
 
        if (dax_match_id(dax_drv, dev))
                return 1;
index b83b27e..e647a68 100644 (file)
@@ -33,10 +33,10 @@ void idxd_driver_unregister(struct idxd_device_driver *idxd_drv)
 EXPORT_SYMBOL_GPL(idxd_driver_unregister);
 
 static int idxd_config_bus_match(struct device *dev,
-                                struct device_driver *drv)
+                                const struct device_driver *drv)
 {
-       struct idxd_device_driver *idxd_drv =
-               container_of(drv, struct idxd_device_driver, drv);
+       const struct idxd_device_driver *idxd_drv =
+               container_of_const(drv, struct idxd_device_driver, drv);
        struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev);
        int i = 0;
 
index 33f0ba1..cb586a3 100644 (file)
@@ -105,10 +105,10 @@ static char __init *decode_eisa_sig(unsigned long addr)
        return sig_str;
 }
 
-static int eisa_bus_match(struct device *dev, struct device_driver *drv)
+static int eisa_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct eisa_device *edev = to_eisa_device(dev);
-       struct eisa_driver *edrv = to_eisa_driver(drv);
+       const struct eisa_driver *edrv = to_eisa_driver(drv);
        const struct eisa_device_id *eids = edrv->id_table;
 
        if (!eids)
index e6cdb90..00e9a13 100644 (file)
@@ -190,10 +190,10 @@ static bool match_ids(const struct ieee1394_device_id *id_table, int *id)
 }
 
 static const struct ieee1394_device_id *unit_match(struct device *dev,
-                                                  struct device_driver *drv)
+                                                  const struct device_driver *drv)
 {
        const struct ieee1394_device_id *id_table =
-                       container_of(drv, struct fw_driver, driver)->id_table;
+                       container_of_const(drv, struct fw_driver, driver)->id_table;
        int id[] = {0, 0, 0, 0};
 
        get_modalias_ids(fw_unit(dev), id);
@@ -207,7 +207,7 @@ static const struct ieee1394_device_id *unit_match(struct device *dev,
 
 static bool is_fw_unit(const struct device *dev);
 
-static int fw_unit_match(struct device *dev, struct device_driver *drv)
+static int fw_unit_match(struct device *dev, const struct device_driver *drv)
 {
        /* We only allow binding to fw_units. */
        return is_fw_unit(dev) && unit_match(dev, drv) != NULL;
index 2f557e9..62b0b8b 100644 (file)
@@ -19,7 +19,7 @@
 
 static DEFINE_IDA(ffa_bus_id);
 
-static int ffa_device_match(struct device *dev, struct device_driver *drv)
+static int ffa_device_match(struct device *dev, const struct device_driver *drv)
 {
        const struct ffa_device_id *id_table;
        struct ffa_device *ffa_dev;
index 77c78be..96b2e5f 100644 (file)
@@ -207,7 +207,7 @@ scmi_protocol_table_unregister(const struct scmi_device_id *id_table)
 }
 
 static const struct scmi_device_id *
-scmi_dev_match_id(struct scmi_device *scmi_dev, struct scmi_driver *scmi_drv)
+scmi_dev_match_id(struct scmi_device *scmi_dev, const struct scmi_driver *scmi_drv)
 {
        const struct scmi_device_id *id = scmi_drv->id_table;
 
@@ -225,9 +225,9 @@ scmi_dev_match_id(struct scmi_device *scmi_dev, struct scmi_driver *scmi_drv)
        return NULL;
 }
 
-static int scmi_dev_match(struct device *dev, struct device_driver *drv)
+static int scmi_dev_match(struct device *dev, const struct device_driver *drv)
 {
-       struct scmi_driver *scmi_drv = to_scmi_driver(drv);
+       const struct scmi_driver *scmi_drv = to_scmi_driver(drv);
        struct scmi_device *scmi_dev = to_scmi_dev(dev);
        const struct scmi_device_id *id;
 
index fa7752f..c179c4e 100644 (file)
 #include "coreboot_table.h"
 
 #define CB_DEV(d) container_of(d, struct coreboot_device, dev)
-#define CB_DRV(d) container_of(d, struct coreboot_driver, drv)
+#define CB_DRV(d) container_of_const(d, struct coreboot_driver, drv)
 
-static int coreboot_bus_match(struct device *dev, struct device_driver *drv)
+static int coreboot_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct coreboot_device *device = CB_DEV(dev);
-       struct coreboot_driver *driver = CB_DRV(drv);
+       const struct coreboot_driver *driver = CB_DRV(drv);
        const struct coreboot_device_id *id;
 
        if (!driver->id_table)
index 094ee97..c406b94 100644 (file)
@@ -257,10 +257,10 @@ dfl_match_one_device(const struct dfl_device_id *id, struct dfl_device *ddev)
        return NULL;
 }
 
-static int dfl_bus_match(struct device *dev, struct device_driver *drv)
+static int dfl_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct dfl_device *ddev = to_dfl_dev(dev);
-       struct dfl_driver *ddrv = to_dfl_drv(drv);
+       const struct dfl_driver *ddrv = to_dfl_drv(drv);
        const struct dfl_device_id *id_entry;
 
        id_entry = ddrv->id_table;
index 097d5a7..46ac5a8 100644 (file)
@@ -1361,10 +1361,10 @@ EXPORT_SYMBOL_GPL(fsi_master_unregister);
 
 /* FSI core & Linux bus type definitions */
 
-static int fsi_bus_match(struct device *dev, struct device_driver *drv)
+static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct fsi_device *fsi_dev = to_fsi_dev(dev);
-       struct fsi_driver *fsi_drv = to_fsi_drv(drv);
+       const struct fsi_driver *fsi_drv = to_fsi_drv(drv);
        const struct fsi_device_id *id;
 
        if (!fsi_drv->id_table)
index fa62367..8c1c7cd 100644 (file)
@@ -53,7 +53,7 @@ static DEFINE_IDA(gpio_ida);
 static dev_t gpio_devt;
 #define GPIO_DEV_MAX 256 /* 256 GPIO chip devices supported */
 
-static int gpio_bus_match(struct device *dev, struct device_driver *drv)
+static int gpio_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct fwnode_handle *fwnode = dev_fwnode(dev);
 
index 5afc26b..d810529 100644 (file)
@@ -36,7 +36,7 @@ struct dp_aux_ep_device_with_data {
  *
  * Return: True if this driver matches this device; false otherwise.
  */
-static int dp_aux_ep_match(struct device *dev, struct device_driver *drv)
+static int dp_aux_ep_match(struct device *dev, const struct device_driver *drv)
 {
        return !!of_match_device(drv->of_match_table, dev);
 }
index 795001b..ddd5127 100644 (file)
@@ -48,7 +48,7 @@
  * subset of the MIPI DCS command set.
  */
 
-static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv)
+static int mipi_dsi_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
 
index 7c52757..8e09d6d 100644 (file)
@@ -333,7 +333,7 @@ static int host1x_del_client(struct host1x *host1x,
        return -ENODEV;
 }
 
-static int host1x_device_match(struct device *dev, struct device_driver *drv)
+static int host1x_device_match(struct device *dev, const struct device_driver *drv)
 {
        return strcmp(dev_name(dev), drv->name) == 0;
 }
index 95c09d4..c556956 100644 (file)
@@ -90,9 +90,9 @@ greybus_match_id(struct gb_bundle *bundle, const struct greybus_bundle_id *id)
        return NULL;
 }
 
-static int greybus_match_device(struct device *dev, struct device_driver *drv)
+static int greybus_match_device(struct device *dev, const struct device_driver *drv)
 {
-       struct greybus_driver *driver = to_greybus_driver(drv);
+       const struct greybus_driver *driver = to_greybus_driver(drv);
        struct gb_bundle *bundle;
        const struct greybus_bundle_id *id;
 
index 74efda2..d7a1f81 100644 (file)
@@ -2562,7 +2562,7 @@ const struct hid_device_id *hid_match_device(struct hid_device *hdev,
 }
 EXPORT_SYMBOL_GPL(hid_match_device);
 
-static int hid_bus_match(struct device *dev, struct device_driver *drv)
+static int hid_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct hid_driver *hdrv = to_hid_driver(drv);
        struct hid_device *hdev = to_hid_device(dev);
index 03d5601..4a91577 100644 (file)
@@ -236,7 +236,7 @@ static int ishtp_cl_device_probe(struct device *dev)
  *
  * Return: 1 if dev & drv matches, 0 otherwise.
  */
-static int ishtp_cl_bus_match(struct device *dev, struct device_driver *drv)
+static int ishtp_cl_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
        struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv);
index e3beeac..8113cb9 100644 (file)
@@ -37,7 +37,7 @@ static int hsi_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
        return 0;
 }
 
-static int hsi_bus_match(struct device *dev, struct device_driver *driver)
+static int hsi_bus_match(struct device *dev, const struct device_driver *driver)
 {
        if (of_driver_match_device(dev, driver))
                return true;
index 12a707a..c857dc3 100644 (file)
@@ -685,7 +685,7 @@ static const struct hv_vmbus_device_id vmbus_device_null;
  * Return a matching hv_vmbus_device_id pointer.
  * If there is no match, return NULL.
  */
-static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
+static const struct hv_vmbus_device_id *hv_vmbus_get_id(const struct hv_driver *drv,
                                                        struct hv_device *dev)
 {
        const guid_t *guid = &dev->dev_type;
@@ -696,7 +696,7 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
                return NULL;
 
        /* Look at the dynamic ids first, before the static ones */
-       id = hv_vmbus_dynid_match(drv, guid);
+       id = hv_vmbus_dynid_match((struct hv_driver *)drv, guid);
        if (!id)
                id = hv_vmbus_dev_match(drv->id_table, guid);
 
@@ -809,9 +809,9 @@ ATTRIBUTE_GROUPS(vmbus_drv);
 /*
  * vmbus_match - Attempt to match the specified device to the specified driver
  */
-static int vmbus_match(struct device *device, struct device_driver *driver)
+static int vmbus_match(struct device *device, const struct device_driver *driver)
 {
-       struct hv_driver *drv = drv_to_hv_drv(driver);
+       const struct hv_driver *drv = drv_to_hv_drv(driver);
        struct hv_device *hv_dev = device_to_hv_device(device);
 
        /* The hv_sock driver handles all hv_sock offers. */
index a121dc5..d729933 100644 (file)
@@ -26,9 +26,9 @@ module_param(host_mode, bool, 0444);
 
 static DEFINE_IDA(intel_th_ida);
 
-static int intel_th_match(struct device *dev, struct device_driver *driver)
+static int intel_th_match(struct device *dev, const struct device_driver *driver)
 {
-       struct intel_th_driver *thdrv = to_intel_th_driver(driver);
+       const struct intel_th_driver *thdrv = to_intel_th_driver(driver);
        struct intel_th_device *thdev = to_intel_th_device(dev);
 
        if (thdev->type == INTEL_TH_SWITCH &&
index 6cbba73..3b87cd5 100644 (file)
@@ -189,7 +189,7 @@ struct intel_th_driver {
 };
 
 #define to_intel_th_driver(_d)                                 \
-       container_of((_d), struct intel_th_driver, driver)
+       container_of_const((_d), struct intel_th_driver, driver)
 
 #define to_intel_th_driver_or_null(_d)         \
        ((_d) ? to_intel_th_driver(_d) : NULL)
index db0d1ac..0b1be95 100644 (file)
@@ -136,10 +136,10 @@ const void *i2c_get_match_data(const struct i2c_client *client)
 }
 EXPORT_SYMBOL(i2c_get_match_data);
 
-static int i2c_device_match(struct device *dev, struct device_driver *drv)
+static int i2c_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct i2c_client       *client = i2c_verify_client(dev);
-       struct i2c_driver       *driver;
+       const struct i2c_driver *driver;
 
 
        /* Attempt an OF style match */
index 3b4d6a8..00a3e9d 100644 (file)
@@ -301,10 +301,10 @@ static const struct device_type i3c_device_type = {
        .uevent = i3c_device_uevent,
 };
 
-static int i3c_device_match(struct device *dev, struct device_driver *drv)
+static int i3c_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct i3c_device *i3cdev;
-       struct i3c_driver *i3cdrv;
+       const struct i3c_driver *i3cdrv;
 
        if (dev->type != &i3c_device_type)
                return 0;
index cfcc81c..e77dd07 100644 (file)
@@ -806,9 +806,9 @@ start_over:
 }
 EXPORT_SYMBOL(gameport_unregister_driver);
 
-static int gameport_bus_match(struct device *dev, struct device_driver *drv)
+static int gameport_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct gameport_driver *gameport_drv = to_gameport_driver(drv);
+       const struct gameport_driver *gameport_drv = to_gameport_driver(drv);
 
        return !gameport_drv->ignore;
 }
index 3430302..3aee048 100644 (file)
@@ -144,9 +144,9 @@ bool rmi_is_function_device(struct device *dev)
        return dev->type == &rmi_function_type;
 }
 
-static int rmi_function_match(struct device *dev, struct device_driver *drv)
+static int rmi_function_match(struct device *dev, const struct device_driver *drv)
 {
-       struct rmi_function_handler *handler = to_rmi_function_handler(drv);
+       const struct rmi_function_handler *handler = to_rmi_function_handler(drv);
        struct rmi_function *fn = to_rmi_function(dev);
 
        return fn->fd.function_number == handler->func;
@@ -333,7 +333,7 @@ EXPORT_SYMBOL_GPL(rmi_unregister_function_handler);
 
 /* Bus specific stuff */
 
-static int rmi_bus_match(struct device *dev, struct device_driver *drv)
+static int rmi_bus_match(struct device *dev, const struct device_driver *drv)
 {
        bool physical = rmi_is_physical_device(dev);
 
index ea46ad9..d4d0d82 100644 (file)
@@ -87,7 +87,7 @@ struct rmi_function_handler {
 };
 
 #define to_rmi_function_handler(d) \
-               container_of(d, struct rmi_function_handler, driver)
+               container_of_const(d, struct rmi_function_handler, driver)
 
 int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
                                                 struct module *, const char *);
index ef9ea29..2168b6c 100644 (file)
@@ -1258,7 +1258,7 @@ static struct rmi_driver rmi_physical_driver = {
        .set_input_params = rmi_driver_set_input_params,
 };
 
-bool rmi_is_physical_driver(struct device_driver *drv)
+bool rmi_is_physical_driver(const struct device_driver *drv)
 {
        return drv == &rmi_physical_driver.driver;
 }
index 1c6c608..3bfe901 100644 (file)
@@ -84,7 +84,7 @@ int rmi_register_desc_calc_reg_offset(
 bool rmi_register_desc_has_subpacket(const struct rmi_register_desc_item *item,
                        u8 subpacket);
 
-bool rmi_is_physical_driver(struct device_driver *);
+bool rmi_is_physical_driver(const struct device_driver *);
 int rmi_register_physical_driver(void);
 void rmi_unregister_physical_driver(void);
 void rmi_free_function_list(struct rmi_device *rmi_dev);
index a8838b5..36bf2c5 100644 (file)
@@ -877,10 +877,10 @@ static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
        serio_continue_rx(serio);
 }
 
-static int serio_bus_match(struct device *dev, struct device_driver *drv)
+static int serio_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct serio *serio = to_serio_port(dev);
-       struct serio_driver *serio_drv = to_serio_driver(drv);
+       const struct serio_driver *serio_drv = to_serio_driver(drv);
 
        if (serio->manual_bind || serio_drv->manual_bind)
                return 0;
index 866bf48..57d232c 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/ipack.h>
 
 #define to_ipack_dev(device) container_of(device, struct ipack_device, dev)
-#define to_ipack_driver(drv) container_of(drv, struct ipack_driver, driver)
+#define to_ipack_driver(drv) container_of_const(drv, struct ipack_driver, driver)
 
 static DEFINE_IDA(ipack_ida);
 
@@ -49,10 +49,10 @@ ipack_match_id(const struct ipack_device_id *ids, struct ipack_device *idev)
        return NULL;
 }
 
-static int ipack_bus_match(struct device *dev, struct device_driver *drv)
+static int ipack_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct ipack_device *idev = to_ipack_dev(dev);
-       struct ipack_driver *idrv = to_ipack_driver(drv);
+       const struct ipack_driver *idrv = to_ipack_driver(drv);
        const struct ipack_device_id *found_id;
 
        found_id = ipack_match_id(idrv->id_table, idev);
index 565f1e2..1362620 100644 (file)
@@ -36,7 +36,7 @@
 
 static struct macio_chip      *macio_on_hold;
 
-static int macio_bus_match(struct device *dev, struct device_driver *drv) 
+static int macio_bus_match(struct device *dev, const struct device_driver *drv)
 {
        const struct of_device_id * matches = drv->of_match_table;
 
index 267045b..91bbd94 100644 (file)
@@ -28,9 +28,9 @@ static const struct mcb_device_id *mcb_match_id(const struct mcb_device_id *ids,
        return NULL;
 }
 
-static int mcb_match(struct device *dev, struct device_driver *drv)
+static int mcb_match(struct device *dev, const struct device_driver *drv)
 {
-       struct mcb_driver *mdrv = to_mcb_driver(drv);
+       const struct mcb_driver *mdrv = to_mcb_driver(drv);
        struct mcb_device *mdev = to_mcb_device(dev);
        const struct mcb_device_id *found_id;
 
index 6b7fea5..59a6f16 100644 (file)
@@ -28,9 +28,9 @@
 /* ----------------------------------------------------------------------- */
 /* internal: the bttv "bus"                                                */
 
-static int bttv_sub_bus_match(struct device *dev, struct device_driver *drv)
+static int bttv_sub_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct bttv_sub_driver *sub = to_bttv_sub_drv(drv);
+       const struct bttv_sub_driver *sub = to_bttv_sub_drv(drv);
        int len = strlen(sub->wanted);
 
        if (0 == strncmp(dev_name(dev), sub->wanted, len))
index eed7eeb..97bbed9 100644 (file)
@@ -341,7 +341,7 @@ struct bttv_sub_driver {
        int                    (*probe)(struct bttv_sub_device *sub);
        void                   (*remove)(struct bttv_sub_device *sub);
 };
-#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
+#define to_bttv_sub_drv(x) container_of_const((x), struct bttv_sub_driver, drv)
 
 int bttv_sub_register(struct bttv_sub_driver *drv, char *wanted);
 int bttv_sub_unregister(struct bttv_sub_driver *drv);
index 23fea51..9a3a784 100644 (file)
@@ -38,13 +38,12 @@ static int memstick_dev_match(struct memstick_dev *card,
        return 0;
 }
 
-static int memstick_bus_match(struct device *dev, struct device_driver *drv)
+static int memstick_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct memstick_dev *card = container_of(dev, struct memstick_dev,
                                                 dev);
-       struct memstick_driver *ms_drv = container_of(drv,
-                                                     struct memstick_driver,
-                                                     driver);
+       const struct memstick_driver *ms_drv = container_of_const(drv, struct memstick_driver,
+                                                                 driver);
        struct memstick_device_id *ids = ms_drv->id_table;
 
        if (ids) {
index 16ca233..be08eae 100644 (file)
@@ -20,7 +20,7 @@
 #define to_mcp(d)              container_of(d, struct mcp, attached_device)
 #define to_mcp_driver(d)       container_of(d, struct mcp_driver, drv)
 
-static int mcp_bus_match(struct device *dev, struct device_driver *drv)
+static int mcp_bus_match(struct device *dev, const struct device_driver *drv)
 {
        return 1;
 }
index 99393f6..5576146 100644 (file)
@@ -19,7 +19,7 @@
 #include "mei_dev.h"
 #include "client.h"
 
-#define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver)
+#define to_mei_cl_driver(d) container_of_const(d, struct mei_cl_driver, driver)
 
 /**
  * __mei_cl_send - internal client send (write)
@@ -1124,7 +1124,7 @@ struct mei_cl_device_id *mei_cl_device_find(const struct mei_cl_device *cldev,
  *
  * Return:  1 if matching device was found 0 otherwise
  */
-static int mei_cl_device_match(struct device *dev, struct device_driver *drv)
+static int mei_cl_device_match(struct device *dev, const struct device_driver *drv)
 {
        const struct mei_cl_device *cldev = to_mei_cl_device(dev);
        const struct mei_cl_driver *cldrv = to_mei_cl_driver(drv);
index fd9c3cb..12355d3 100644 (file)
@@ -38,11 +38,11 @@ static int tifm_dev_match(struct tifm_dev *sock, struct tifm_device_id *id)
        return 0;
 }
 
-static int tifm_bus_match(struct device *dev, struct device_driver *drv)
+static int tifm_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
-       struct tifm_driver *fm_drv = container_of(drv, struct tifm_driver,
-                                                 driver);
+       const struct tifm_driver *fm_drv = container_of_const(drv, struct tifm_driver,
+                                                             driver);
        struct tifm_device_id *ids = fm_drv->id_table;
 
        if (ids) {
index c5fdfe2..b66b637 100644 (file)
@@ -26,7 +26,7 @@
 #include "sdio_cis.h"
 #include "sdio_bus.h"
 
-#define to_sdio_driver(d)      container_of(d, struct sdio_driver, drv)
+#define to_sdio_driver(d)      container_of_const(d, struct sdio_driver, drv)
 
 /* show configuration fields */
 #define sdio_config_attr(field, format_string, args...)                        \
@@ -91,7 +91,7 @@ static const struct sdio_device_id *sdio_match_one(struct sdio_func *func,
 }
 
 static const struct sdio_device_id *sdio_match_device(struct sdio_func *func,
-       struct sdio_driver *sdrv)
+       const struct sdio_driver *sdrv)
 {
        const struct sdio_device_id *ids;
 
@@ -108,10 +108,10 @@ static const struct sdio_device_id *sdio_match_device(struct sdio_func *func,
        return NULL;
 }
 
-static int sdio_bus_match(struct device *dev, struct device_driver *drv)
+static int sdio_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct sdio_func *func = dev_to_sdio_func(dev);
-       struct sdio_driver *sdrv = to_sdio_driver(drv);
+       const struct sdio_driver *sdrv = to_sdio_driver(drv);
 
        if (sdio_match_device(func, sdrv))
                return 1;
@@ -129,7 +129,7 @@ sdio_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
                        "SDIO_CLASS=%02X", func->class))
                return -ENOMEM;
 
-       if (add_uevent_var(env, 
+       if (add_uevent_var(env,
                        "SDIO_ID=%04X:%04X", func->vendor, func->device))
                return -ENOMEM;
 
index f13d0e1..304f0b4 100644 (file)
@@ -491,7 +491,7 @@ static int print_links(struct device *dev, void *data)
        return 0;
 }
 
-static int most_match(struct device *dev, struct device_driver *drv)
+static int most_match(struct device *dev, const struct device_driver *drv)
 {
        if (!strcmp(dev_name(dev), "most"))
                return 0;
index 8b9ead7..7e2f101 100644 (file)
@@ -1375,9 +1375,9 @@ EXPORT_SYMBOL_GPL(mdiobus_c45_modify_changed);
  *   require calling the devices own match function, since different classes
  *   of MDIO devices have different match criteria.
  */
-static int mdio_bus_match(struct device *dev, struct device_driver *drv)
+static int mdio_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct mdio_driver *mdiodrv = to_mdio_driver(drv);
+       const struct mdio_driver *mdiodrv = to_mdio_driver(drv);
        struct mdio_device *mdio = to_mdio_device(dev);
 
        /* Both the driver and device must type-match */
index 73f6539..e747ee6 100644 (file)
@@ -35,10 +35,10 @@ static void mdio_device_release(struct device *dev)
        kfree(to_mdio_device(dev));
 }
 
-int mdio_device_bus_match(struct device *dev, struct device_driver *drv)
+int mdio_device_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct mdio_device *mdiodev = to_mdio_device(dev);
-       struct mdio_driver *mdiodrv = to_mdio_driver(drv);
+       const struct mdio_driver *mdiodrv = to_mdio_driver(drv);
 
        if (mdiodrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY)
                return 0;
index 6c6ec94..fc63299 100644 (file)
@@ -533,10 +533,10 @@ static int phy_scan_fixups(struct phy_device *phydev)
        return 0;
 }
 
-static int phy_bus_match(struct device *dev, struct device_driver *drv)
+static int phy_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct phy_device *phydev = to_phy_device(dev);
-       struct phy_driver *phydrv = to_phy_driver(drv);
+       const struct phy_driver *phydrv = to_phy_driver(drv);
        const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
        int i;
 
index f9e7847..77e55de 100644 (file)
@@ -284,7 +284,7 @@ static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset);
 
 
 static int ntb_transport_bus_match(struct device *dev,
-                                  struct device_driver *drv)
+                                  const struct device_driver *drv)
 {
        return !strncmp(dev_name(dev), drv->name, strlen(drv->name));
 }
index 101c425..2237715 100644 (file)
@@ -272,7 +272,7 @@ long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
 }
 EXPORT_SYMBOL_GPL(nvdimm_clear_poison);
 
-static int nvdimm_bus_match(struct device *dev, struct device_driver *drv);
+static int nvdimm_bus_match(struct device *dev, const struct device_driver *drv);
 
 static const struct bus_type nvdimm_bus_type = {
        .name = "nd",
@@ -468,9 +468,9 @@ static struct nd_device_driver nd_bus_driver = {
        },
 };
 
-static int nvdimm_bus_match(struct device *dev, struct device_driver *drv)
+static int nvdimm_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct nd_device_driver *nd_drv = to_nd_device_driver(drv);
+       const struct nd_device_driver *nd_drv = to_nd_device_driver(drv);
 
        if (is_nvdimm_bus(dev) && nd_drv == &nd_bus_driver)
                return true;
index 64dc701..77a4119 100644 (file)
 #include "internals.h"
 
 #define to_nvmem_layout_driver(drv) \
-       (container_of((drv), struct nvmem_layout_driver, driver))
+       (container_of_const((drv), struct nvmem_layout_driver, driver))
 #define to_nvmem_layout_device(_dev) \
        container_of((_dev), struct nvmem_layout, dev)
 
-static int nvmem_layout_bus_match(struct device *dev, struct device_driver *drv)
+static int nvmem_layout_bus_match(struct device *dev, const struct device_driver *drv)
 {
        return of_driver_match_device(dev, drv);
 }
index 323f2a6..8fa2797 100644 (file)
@@ -488,10 +488,10 @@ pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf)
        return NULL;
 }
 
-static int pci_epf_device_match(struct device *dev, struct device_driver *drv)
+static int pci_epf_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct pci_epf *epf = to_pci_epf(dev);
-       struct pci_epf_driver *driver = to_pci_epf_driver(drv);
+       const struct pci_epf_driver *driver = to_pci_epf_driver(drv);
 
        if (driver->id_table)
                return !!pci_epf_match_id(driver->id_table, epf);
index af2996d..f412ef7 100644 (file)
@@ -1503,7 +1503,7 @@ EXPORT_SYMBOL(pci_dev_driver);
  * system is in its list of supported devices. Returns the matching
  * pci_device_id structure or %NULL if there is no match.
  */
-static int pci_bus_match(struct device *dev, struct device_driver *drv)
+static int pci_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct pci_dev *pci_dev = to_pci_dev(dev);
        struct pci_driver *pci_drv;
@@ -1512,7 +1512,7 @@ static int pci_bus_match(struct device *dev, struct device_driver *drv)
        if (!pci_dev->match_driver)
                return 0;
 
-       pci_drv = to_pci_driver(drv);
+       pci_drv = (struct pci_driver *)to_pci_driver(drv);
        found_id = pci_match_device(pci_drv, pci_dev);
        if (found_id)
                return 1;
@@ -1688,10 +1688,10 @@ struct bus_type pci_bus_type = {
 EXPORT_SYMBOL(pci_bus_type);
 
 #ifdef CONFIG_PCIEPORTBUS
-static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
+static int pcie_port_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct pcie_device *pciedev;
-       struct pcie_port_service_driver *driver;
+       const struct pcie_port_service_driver *driver;
 
        if (drv->bus != &pcie_port_bus_type || dev->bus != &pcie_port_bus_type)
                return 0;
index d3cfd35..da6f66f 100644 (file)
@@ -900,7 +900,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
 }
 
 
-static int pcmcia_bus_match(struct device *dev, struct device_driver *drv)
+static int pcmcia_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
        struct pcmcia_driver *p_drv = to_pcmcia_drv(drv);
index 8f8bda2..289f081 100644 (file)
@@ -173,10 +173,10 @@ peci_bus_match_device_id(const struct peci_device_id *id, struct peci_device *de
        return NULL;
 }
 
-static int peci_bus_device_match(struct device *dev, struct device_driver *drv)
+static int peci_bus_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct peci_device *device = to_peci_device(dev);
-       struct peci_driver *peci_drv = to_peci_driver(drv);
+       const struct peci_driver *peci_drv = to_peci_driver(drv);
 
        if (dev->type != &peci_device_type)
                return 0;
index 506bafc..d388dfd 100644 (file)
@@ -98,10 +98,7 @@ struct peci_driver {
        const struct peci_device_id *id_table;
 };
 
-static inline struct peci_driver *to_peci_driver(struct device_driver *d)
-{
-       return container_of(d, struct peci_driver, driver);
-}
+#define to_peci_driver(__drv)  container_of_const(__drv, struct peci_driver, driver)
 
 int __peci_driver_register(struct peci_driver *driver, struct module *owner,
                           const char *mod_name);
index 118caa6..af8d573 100644 (file)
@@ -306,9 +306,9 @@ const void *ssam_device_get_match_data(const struct ssam_device *dev)
 }
 EXPORT_SYMBOL_GPL(ssam_device_get_match_data);
 
-static int ssam_bus_match(struct device *dev, struct device_driver *drv)
+static int ssam_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct ssam_device_driver *sdrv = to_ssam_device_driver(drv);
+       const struct ssam_device_driver *sdrv = to_ssam_device_driver(drv);
        struct ssam_device *sdev = to_ssam_device(dev);
 
        if (!is_ssam_device(dev))
index d21f3fa..389e787 100644 (file)
@@ -727,10 +727,7 @@ char *wmi_get_acpi_device_uid(const char *guid_string)
 }
 EXPORT_SYMBOL_GPL(wmi_get_acpi_device_uid);
 
-static inline struct wmi_driver *drv_to_wdrv(struct device_driver *drv)
-{
-       return container_of(drv, struct wmi_driver, driver);
-}
+#define drv_to_wdrv(__drv)     container_of_const(__drv, struct wmi_driver, driver)
 
 /*
  * sysfs interface
@@ -848,9 +845,9 @@ static void wmi_dev_release(struct device *dev)
        kfree(wblock);
 }
 
-static int wmi_dev_match(struct device *dev, struct device_driver *driver)
+static int wmi_dev_match(struct device *dev, const struct device_driver *driver)
 {
-       struct wmi_driver *wmi_driver = drv_to_wdrv(driver);
+       const struct wmi_driver *wmi_driver = drv_to_wdrv(driver);
        struct wmi_block *wblock = dev_to_wblock(dev);
        const struct wmi_device_id *id = wmi_driver->id_table;
 
index 3483e52..7de7aab 100644 (file)
@@ -41,7 +41,7 @@ int compare_pnp_id(struct pnp_id *pos, const char *id)
        return 0;
 }
 
-static const struct pnp_device_id *match_device(struct pnp_driver *drv,
+static const struct pnp_device_id *match_device(const struct pnp_driver *drv,
                                                struct pnp_dev *dev)
 {
        const struct pnp_device_id *drv_id = drv->id_table;
@@ -150,10 +150,10 @@ static void pnp_device_shutdown(struct device *dev)
                drv->shutdown(pnp_dev);
 }
 
-static int pnp_bus_match(struct device *dev, struct device_driver *drv)
+static int pnp_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct pnp_dev *pnp_dev = to_pnp_dev(dev);
-       struct pnp_driver *pnp_drv = to_pnp_driver(drv);
+       const struct pnp_driver *pnp_drv = to_pnp_driver(drv);
 
        if (match_device(pnp_drv, pnp_dev) == NULL)
                return 0;
index 1b3b4c2..238250e 100644 (file)
@@ -186,10 +186,10 @@ EXPORT_SYMBOL_GPL(rio_attach_device);
  *  there is a matching &struct rio_device_id or 0 if there is
  *  no match.
  */
-static int rio_match_bus(struct device *dev, struct device_driver *drv)
+static int rio_match_bus(struct device *dev, const struct device_driver *drv)
 {
        struct rio_dev *rdev = to_rio_dev(dev);
-       struct rio_driver *rdrv = to_rio_driver(drv);
+       const struct rio_driver *rdrv = to_rio_driver(drv);
        const struct rio_device_id *id = rdrv->id_table;
        const struct rio_device_id *found_id;
 
index 0fa0826..712c06c 100644 (file)
@@ -493,10 +493,10 @@ static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
 }
 
 /* match rpmsg channel and rpmsg driver */
-static int rpmsg_dev_match(struct device *dev, struct device_driver *drv)
+static int rpmsg_dev_match(struct device *dev, const struct device_driver *drv)
 {
        struct rpmsg_device *rpdev = to_rpmsg_device(dev);
-       struct rpmsg_driver *rpdrv = to_rpmsg_driver(drv);
+       const struct rpmsg_driver *rpdrv = to_rpmsg_driver(drv);
        const struct rpmsg_device_id *ids = rpdrv->id_table;
        unsigned int i;
 
index a3ba768..42c7007 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/poll.h>
 
 #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev)
-#define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv)
+#define to_rpmsg_driver(d) container_of_const(d, struct rpmsg_driver, drv)
 
 extern const struct class rpmsg_class;
 
index 781f849..53b68f8 100644 (file)
@@ -1354,10 +1354,10 @@ int sch_is_pseudo_sch(struct subchannel *sch)
        return sch == to_css(sch->dev.parent)->pseudo_subchannel;
 }
 
-static int css_bus_match(struct device *dev, struct device_driver *drv)
+static int css_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct subchannel *sch = to_subchannel(dev);
-       struct css_driver *driver = to_cssdriver(drv);
+       const struct css_driver *driver = to_cssdriver(drv);
        struct css_device_id *id;
 
        /* When driver_override is set, only bind to the matching driver */
index c2b1755..a65a27d 100644 (file)
@@ -103,7 +103,7 @@ struct css_driver {
        int (*settle)(void);
 };
 
-#define to_cssdriver(n) container_of(n, struct css_driver, drv)
+#define to_cssdriver(n) container_of_const(n, struct css_driver, drv)
 
 extern int css_driver_register(struct css_driver *);
 extern void css_driver_unregister(struct css_driver *);
index 920f550..b0f2324 100644 (file)
@@ -58,10 +58,10 @@ static const struct bus_type ccw_bus_type;
  * subsystem driver and one channel system per machine, but
  * we still use the abstraction. T.R. says it's a good idea. */
 static int
-ccw_bus_match (struct device * dev, struct device_driver * drv)
+ccw_bus_match (struct device * dev, const struct device_driver * drv)
 {
        struct ccw_device *cdev = to_ccwdev(dev);
-       struct ccw_driver *cdrv = to_ccwdrv(drv);
+       const struct ccw_driver *cdrv = to_ccwdrv(drv);
        const struct ccw_device_id *ids = cdrv->ids, *found;
 
        if (!ids)
index 898865b..0998b17 100644 (file)
@@ -552,9 +552,9 @@ static void ap_poll_thread_stop(void)
  *
  * AP bus driver registration/unregistration.
  */
-static int ap_bus_match(struct device *dev, struct device_driver *drv)
+static int ap_bus_match(struct device *dev, const struct device_driver *drv)
 {
-       struct ap_driver *ap_drv = to_ap_drv(drv);
+       const struct ap_driver *ap_drv = to_ap_drv(drv);
        struct ap_device_id *id;
 
        /*
index fdbc6fd..0b275c7 100644 (file)
@@ -158,7 +158,7 @@ struct ap_driver {
                                 struct ap_config_info *old_config_info);
 };
 
-#define to_ap_drv(x) container_of((x), struct ap_driver, driver)
+#define to_ap_drv(x) container_of_const((x), struct ap_driver, driver)
 
 int ap_driver_register(struct ap_driver *, struct module *, char *);
 void ap_driver_unregister(struct ap_driver *);
index 453665a..7d3b904 100644 (file)
@@ -600,7 +600,7 @@ static const struct attribute_group *fcoe_fcf_attr_groups[] = {
 static const struct bus_type fcoe_bus_type;
 
 static int fcoe_bus_match(struct device *dev,
-                         struct device_driver *drv)
+                         const struct device_driver *drv)
 {
        if (dev->bus == &fcoe_bus_type)
                return 1;
index b5aae4e..32f94db 100644 (file)
@@ -528,7 +528,7 @@ static struct class sdev_class = {
 };
 
 /* all probing is done in the individual ->probe routines */
-static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
+static int scsi_bus_match(struct device *dev, const struct device_driver *gendrv)
 {
        struct scsi_device *sdp;
 
@@ -661,7 +661,7 @@ static int scsi_sdev_check_buf_bit(const char *buf)
                        return 1;
                else if (buf[0] == '0')
                        return 0;
-               else 
+               else
                        return -EINVAL;
        } else
                return -EINVAL;
@@ -886,7 +886,7 @@ store_queue_type_field(struct device *dev, struct device_attribute *attr,
 
        if (!sdev->tagged_supported)
                return -EINVAL;
-               
+
        sdev_printk(KERN_INFO, sdev,
                    "ignoring write to deprecated queue_type attribute");
        return count;
index 93e1978..fde7de3 100644 (file)
@@ -1204,7 +1204,7 @@ static const struct device_type iscsi_flashnode_conn_dev_type = {
 static const struct bus_type iscsi_flashnode_bus;
 
 int iscsi_flashnode_bus_match(struct device *dev,
-                                    struct device_driver *drv)
+                             const struct device_driver *drv)
 {
        if (dev->bus == &iscsi_flashnode_bus)
                return 1;
index 1601800..6dc0549 100644 (file)
@@ -747,9 +747,9 @@ static int maple_get_dma_buffer(void)
 }
 
 static int maple_match_bus_driver(struct device *devptr,
-                                 struct device_driver *drvptr)
+                                 const struct device_driver *drvptr)
 {
-       struct maple_driver *maple_drv = to_maple_driver(drvptr);
+       const struct maple_driver *maple_drv = to_maple_driver(drvptr);
        struct maple_device *maple_dev = to_maple_dev(devptr);
 
        /* Trap empty port case */
index 24a4592..f98f5a2 100644 (file)
@@ -503,7 +503,7 @@ static const struct device_type siox_device_type = {
        .release = siox_device_release,
 };
 
-static int siox_match(struct device *dev, struct device_driver *drv)
+static int siox_match(struct device *dev, const struct device_driver *drv)
 {
        if (dev->type != &siox_device_type)
                return 0;
index 41e62de..65e5515 100644 (file)
@@ -30,10 +30,10 @@ static const struct slim_device_id *slim_match(const struct slim_device_id *id,
        return NULL;
 }
 
-static int slim_device_match(struct device *dev, struct device_driver *drv)
+static int slim_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct slim_device *sbdev = to_slim_device(dev);
-       struct slim_driver *sbdrv = to_slim_driver(drv);
+       const struct slim_driver *sbdrv = to_slim_driver(drv);
 
        /* Attempt an OF style match first */
        if (of_driver_match_device(dev, drv))
index 50749e8..4fbff3a 100644 (file)
@@ -338,10 +338,10 @@ static void apr_rxwq(struct work_struct *work)
        }
 }
 
-static int apr_device_match(struct device *dev, struct device_driver *drv)
+static int apr_device_match(struct device *dev, const struct device_driver *drv)
 {
        struct apr_device *adev = to_apr_device(dev);
-       struct apr_driver *adrv = to_apr_driver(drv);
+       const struct apr_driver *adrv = to_apr_driver(drv);
        const struct apr_device_id *id = adrv->id_table;
 
        /* Attempt an OF style match first */
index c32faac..d928258 100644 (file)
@@ -19,7 +19,7 @@
  * struct sdw_device_id.
  */
 static const struct sdw_device_id *
-sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)
+sdw_get_device_id(struct sdw_slave *slave, const struct sdw_driver *drv)
 {
        const struct sdw_device_id *id;
 
@@ -35,10 +35,10 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)
        return NULL;
 }
 
-static int sdw_bus_match(struct device *dev, struct device_driver *ddrv)
+static int sdw_bus_match(struct device *dev, const struct device_driver *ddrv)
 {
        struct sdw_slave *slave;
-       struct sdw_driver *drv;
+       const struct sdw_driver *drv;
        int ret = 0;
 
        if (is_sdw_slave(dev)) {
index 9bc9fd1..38a8570 100644 (file)
@@ -371,7 +371,7 @@ const void *spi_get_device_match_data(const struct spi_device *sdev)
 }
 EXPORT_SYMBOL_GPL(spi_get_device_match_data);
 
-static int spi_match_device(struct device *dev, struct device_driver *drv)
+static int spi_match_device(struct device *dev, const struct device_driver *drv)
 {
        const struct spi_device *spi = to_spi_device(dev);
        const struct spi_driver *sdrv = to_spi_driver(drv);
index 667085c..fb0101d 100644 (file)
@@ -43,7 +43,7 @@ static const struct device_type spmi_ctrl_type = {
        .release        = spmi_ctrl_release,
 };
 
-static int spmi_device_match(struct device *dev, struct device_driver *drv)
+static int spmi_device_match(struct device *dev, const struct device_driver *drv)
 {
        if (of_driver_match_device(dev, drv))
                return 1;
index 4da8848..aa6165e 100644 (file)
@@ -323,10 +323,10 @@ static int ssb_match_devid(const struct ssb_device_id *tabid,
        return 1;
 }
 
-static int ssb_bus_match(struct device *dev, struct device_driver *drv)
+static int ssb_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct ssb_device *ssb_dev = dev_to_ssb_dev(dev);
-       struct ssb_driver *ssb_drv = drv_to_ssb_drv(drv);
+       const struct ssb_driver *ssb_drv = drv_to_ssb_drv(drv);
        const struct ssb_device_id *id;
 
        for (id = ssb_drv->id_table;
index a219688..c21c4be 100644 (file)
@@ -44,11 +44,7 @@ static inline struct anybuss_client *to_anybuss_client(struct device *dev)
        return container_of(dev, struct anybuss_client, dev);
 }
 
-static inline struct anybuss_client_driver *
-to_anybuss_client_driver(struct device_driver *drv)
-{
-       return container_of(drv, struct anybuss_client_driver, driver);
-}
+#define to_anybuss_client_driver(__drv) container_of_const(__drv, struct anybuss_client_driver, driver)
 
 static inline void *
 anybuss_get_drvdata(const struct anybuss_client *client)
index 410e6f8..4f2b2fc 100644 (file)
@@ -1166,9 +1166,9 @@ EXPORT_SYMBOL_GPL(anybuss_recv_msg);
 /* ------------------------ bus functions ------------------------ */
 
 static int anybus_bus_match(struct device *dev,
-                           struct device_driver *drv)
+                           const struct device_driver *drv)
 {
-       struct anybuss_client_driver *adrv =
+       const struct anybuss_client_driver *adrv =
                to_anybuss_client_driver(drv);
        struct anybuss_client *adev =
                to_anybuss_client(dev);
index d827f03..fe4f76d 100644 (file)
@@ -117,7 +117,7 @@ gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
        return NULL;
 }
 
-static int gbphy_dev_match(struct device *dev, struct device_driver *drv)
+static int gbphy_dev_match(struct device *dev, const struct device_driver *drv)
 {
        struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
        struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
index 3f87b93..41ece91 100644 (file)
@@ -14,7 +14,7 @@
 #include "vchiq_arm.h"
 #include "vchiq_bus.h"
 
-static int vchiq_bus_type_match(struct device *dev, struct device_driver *drv)
+static int vchiq_bus_type_match(struct device *dev, const struct device_driver *drv)
 {
        if (dev->bus == &vchiq_bus_type &&
            strcmp(dev_name(dev), drv->name) == 0)
index 0cd370a..9a09146 100644 (file)
@@ -1931,7 +1931,7 @@ EXPORT_SYMBOL(vme_unregister_driver);
 
 /* - Bus Registration ------------------------------------------------------ */
 
-static int vme_bus_match(struct device *dev, struct device_driver *drv)
+static int vme_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct vme_driver *vme_drv;
 
index 1c9d983..2f6d147 100644 (file)
@@ -56,7 +56,7 @@ EXPORT_SYMBOL(tc_unregister_driver);
  * system is in its list of supported devices.  Returns the matching
  * tc_device_id structure or %NULL if there is no match.
  */
-static const struct tc_device_id *tc_match_device(struct tc_driver *tdrv,
+static const struct tc_device_id *tc_match_device(const struct tc_driver *tdrv,
                                                  struct tc_dev *tdev)
 {
        const struct tc_device_id *id = tdrv->id_table;
@@ -82,10 +82,10 @@ static const struct tc_device_id *tc_match_device(struct tc_driver *tdrv,
  * system is in its list of supported devices.  Returns 1 if there
  * is a match or 0 otherwise.
  */
-static int tc_bus_match(struct device *dev, struct device_driver *drv)
+static int tc_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct tc_dev *tdev = to_tc_dev(dev);
-       struct tc_driver *tdrv = to_tc_driver(drv);
+       const struct tc_driver *tdrv = to_tc_driver(drv);
        const struct tc_device_id *id;
 
        id = tc_match_device(tdrv, tdev);
index 82ad095..d52e879 100644 (file)
@@ -1201,7 +1201,7 @@ int tee_client_cancel_req(struct tee_context *ctx,
 }
 
 static int tee_client_device_match(struct device *dev,
-                                  struct device_driver *drv)
+                                  const struct device_driver *drv)
 {
        const struct tee_client_device_id *id_table;
        struct tee_client_device *tee_device;
index 0023017..144d023 100644 (file)
@@ -45,9 +45,9 @@ static bool match_service_id(const struct tb_service_id *id,
 }
 
 static const struct tb_service_id *__tb_service_match(struct device *dev,
-                                                     struct device_driver *drv)
+                                                     const struct device_driver *drv)
 {
-       struct tb_service_driver *driver;
+       const struct tb_service_driver *driver;
        const struct tb_service_id *ids;
        struct tb_service *svc;
 
@@ -55,7 +55,7 @@ static const struct tb_service_id *__tb_service_match(struct device *dev,
        if (!svc)
                return NULL;
 
-       driver = container_of(drv, struct tb_service_driver, driver);
+       driver = container_of_const(drv, struct tb_service_driver, driver);
        if (!driver->id_table)
                return NULL;
 
@@ -67,7 +67,7 @@ static const struct tb_service_id *__tb_service_match(struct device *dev,
        return NULL;
 }
 
-static int tb_service_match(struct device *dev, struct device_driver *drv)
+static int tb_service_match(struct device *dev, const struct device_driver *drv)
 {
        return !!__tb_service_match(dev, drv);
 }
index 613cb35..8913cdd 100644 (file)
@@ -85,7 +85,7 @@ static const struct device_type serdev_ctrl_type = {
        .release        = serdev_ctrl_release,
 };
 
-static int serdev_device_match(struct device *dev, struct device_driver *drv)
+static int serdev_device_match(struct device *dev, const struct device_driver *drv)
 {
        if (!is_serdev_device(dev))
                return 0;
index 73c6ee5..e0d15da 100644 (file)
@@ -29,7 +29,7 @@ static const struct device_type serial_port_type = {
        .name = "port",
 };
 
-static int serial_base_match(struct device *dev, struct device_driver *drv)
+static int serial_base_match(struct device *dev, const struct device_driver *drv)
 {
        if (dev->type == &serial_ctrl_type &&
            str_has_prefix(drv->name, serial_ctrl_type.name))
index 0886b19..4a2ee44 100644 (file)
@@ -34,7 +34,7 @@ EXPORT_SYMBOL_GPL(ulpi_write);
 
 /* -------------------------------------------------------------------------- */
 
-static int ulpi_match(struct device *dev, struct device_driver *driver)
+static int ulpi_match(struct device *dev, const struct device_driver *driver)
 {
        struct ulpi_driver *drv = to_ulpi_driver(driver);
        struct ulpi *ulpi = to_ulpi_dev(dev);
index e02ba15..8e9bafc 100644 (file)
@@ -855,7 +855,7 @@ bool usb_driver_applicable(struct usb_device *udev,
        return false;
 }
 
-static int usb_device_match(struct device *dev, struct device_driver *drv)
+static int usb_device_match(struct device *dev, const struct device_driver *drv)
 {
        /* devices and interfaces are handled separately */
        if (is_usb_device(dev)) {
index 2dfae7a..b0a6137 100644 (file)
@@ -1568,7 +1568,7 @@ EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
 
 /* ------------------------------------------------------------------------- */
 
-static int gadget_match_driver(struct device *dev, struct device_driver *drv)
+static int gadget_match_driver(struct device *dev, const struct device_driver *drv)
 {
        struct usb_gadget *gadget = dev_to_usb_gadget(dev);
        struct usb_udc *udc = gadget->udc;
index 6c812d0..d200e2c 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/usb/serial.h>
 
 static int usb_serial_device_match(struct device *dev,
-                                               struct device_driver *drv)
+                                  const struct device_driver *drv)
 {
        const struct usb_serial_port *port = to_usb_serial_port(dev);
        struct usb_serial_driver *driver = to_usb_serial_driver(drv);
index 6ea103e..aa87925 100644 (file)
@@ -447,7 +447,7 @@ static struct attribute *typec_attrs[] = {
 };
 ATTRIBUTE_GROUPS(typec);
 
-static int typec_match(struct device *dev, struct device_driver *driver)
+static int typec_match(struct device *dev, const struct device_driver *driver)
 {
        struct typec_altmode_driver *drv = to_altmode_driver(driver);
        struct typec_altmode *altmode = to_typec_altmode(dev);
index 8d39194..3813ec4 100644 (file)
@@ -65,7 +65,7 @@ static void vdpa_dev_remove(struct device *d)
                drv->remove(vdev);
 }
 
-static int vdpa_dev_match(struct device *dev, struct device_driver *drv)
+static int vdpa_dev_match(struct device *dev, const struct device_driver *drv)
 {
        struct vdpa_device *vdev = dev_to_vdpa(dev);
 
index b983229..ad5b834 100644 (file)
@@ -31,7 +31,7 @@ static void mdev_remove(struct device *dev)
                drv->remove(to_mdev_device(dev));
 }
 
-static int mdev_match(struct device *dev, struct device_driver *drv)
+static int mdev_match(struct device *dev, const struct device_driver *drv)
 {
        /*
         * No drivers automatically match. Drivers are only bound by explicit
index b968b2a..bc0218f 100644 (file)
@@ -82,7 +82,7 @@ static inline int virtio_id_match(const struct virtio_device *dev,
 
 /* This looks through all the IDs a driver claims to support.  If any of them
  * match, we return 1 and the kernel will call virtio_dev_probe(). */
-static int virtio_dev_match(struct device *_dv, struct device_driver *_dr)
+static int virtio_dev_match(struct device *_dv, const struct device_driver *_dr)
 {
        unsigned int i;
        struct virtio_device *dev = dev_to_virtio(_dv);
index 2754bdf..13821e7 100644 (file)
@@ -104,7 +104,7 @@ void xb_deinit_comms(void);
 int xs_watch_msg(struct xs_watch_event *event);
 void xs_request_exit(struct xb_req_data *req);
 
-int xenbus_match(struct device *_dev, struct device_driver *_drv);
+int xenbus_match(struct device *_dev, const struct device_driver *_drv);
 int xenbus_dev_probe(struct device *_dev);
 void xenbus_dev_remove(struct device *_dev);
 int xenbus_register_driver_common(struct xenbus_driver *drv,
index 1a9ded0..9f097f1 100644 (file)
@@ -94,9 +94,9 @@ match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
        return NULL;
 }
 
-int xenbus_match(struct device *_dev, struct device_driver *_drv)
+int xenbus_match(struct device *_dev, const struct device_driver *_drv)
 {
-       struct xenbus_driver *drv = to_xenbus_driver(_drv);
+       const struct xenbus_driver *drv = to_xenbus_driver(_drv);
 
        if (!drv->ids)
                return 0;
index 1a4dfd7..08d27a1 100644 (file)
@@ -562,7 +562,7 @@ static inline void *acpi_driver_data(struct acpi_device *d)
 }
 
 #define to_acpi_device(d)      container_of(d, struct acpi_device, dev)
-#define to_acpi_driver(d)      container_of(d, struct acpi_driver, drv)
+#define to_acpi_driver(d)      container_of_const(d, struct acpi_driver, drv)
 
 static inline struct acpi_device *acpi_dev_parent(struct acpi_device *adev)
 {
index c82d567..ae70704 100644 (file)
@@ -149,7 +149,7 @@ struct ffa_driver {
        struct device_driver driver;
 };
 
-#define to_ffa_driver(d) container_of(d, struct ffa_driver, driver)
+#define to_ffa_driver(d) container_of_const(d, struct ffa_driver, driver)
 
 static inline void ffa_dev_set_drvdata(struct ffa_device *fdev, void *data)
 {
index b57118a..79bb80e 100644 (file)
@@ -211,7 +211,7 @@ struct cdx_driver {
 };
 
 #define to_cdx_driver(_drv) \
-       container_of(_drv, struct cdx_driver, driver)
+       container_of_const(_drv, struct cdx_driver, driver)
 
 /* Macro to avoid include chaining to get THIS_MODULE */
 #define cdx_driver_register(drv) \
index 5ef4ec1..807831d 100644 (file)
@@ -81,7 +81,7 @@ struct bus_type {
        const struct attribute_group **dev_groups;
        const struct attribute_group **drv_groups;
 
-       int (*match)(struct device *dev, struct device_driver *drv);
+       int (*match)(struct device *dev, const struct device_driver *drv);
        int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
        int (*probe)(struct device *dev);
        void (*sync_state)(struct device *dev);
index 0a7a00a..1f02db0 100644 (file)
@@ -71,7 +71,7 @@ struct dfl_driver {
 };
 
 #define to_dfl_dev(d) container_of(d, struct dfl_device, dev)
-#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
+#define to_dfl_drv(d) container_of_const(d, struct dfl_driver, drv)
 
 /*
  * use a macro to avoid include chaining to get THIS_MODULE.
index b012e30..f98200c 100644 (file)
@@ -60,7 +60,7 @@ struct eisa_driver {
        struct device_driver         driver;
 };
 
-#define to_eisa_driver(drv) container_of(drv,struct eisa_driver, driver)
+#define to_eisa_driver(drv) container_of_const(drv,struct eisa_driver, driver)
 
 /* These external functions are only available when EISA support is enabled. */
 #ifdef CONFIG_EISA
index 3df8c54..8c5eef8 100644 (file)
@@ -44,7 +44,7 @@ struct fsi_driver {
 };
 
 #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)
-#define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv)
+#define to_fsi_drv(drvp) container_of_const(drvp, struct fsi_driver, drv)
 
 extern int fsi_driver_register(struct fsi_driver *fsi_drv);
 extern void fsi_driver_unregister(struct fsi_driver *fsi_drv);
index a1b3de8..083c860 100644 (file)
@@ -56,7 +56,7 @@ struct fsl_mc_driver {
 };
 
 #define to_fsl_mc_driver(_drv) \
-       container_of(_drv, struct fsl_mc_driver, driver)
+       container_of_const(_drv, struct fsl_mc_driver, driver)
 
 /**
  * enum fsl_mc_pool_type - Types of allocatable MC bus resources
index 07e3701..86d62fd 100644 (file)
@@ -58,7 +58,7 @@ struct gameport_driver {
 
        bool ignore;
 };
-#define to_gameport_driver(d)  container_of(d, struct gameport_driver, driver)
+#define to_gameport_driver(d)  container_of_const(d, struct gameport_driver, driver)
 
 int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode);
 void gameport_close(struct gameport *gameport);
index 634c951..4d58e27 100644 (file)
@@ -64,7 +64,7 @@ struct greybus_driver {
 
        struct device_driver driver;
 };
-#define to_greybus_driver(d) container_of(d, struct greybus_driver, driver)
+#define to_greybus_driver(d) container_of_const(d, struct greybus_driver, driver)
 
 static inline void greybus_set_drvdata(struct gb_bundle *bundle, void *data)
 {
index 5e39baa..22c22fb 100644 (file)
@@ -1330,11 +1330,7 @@ struct hv_device {
 
 
 #define device_to_hv_device(d) container_of_const(d, struct hv_device, device)
-
-static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
-{
-       return container_of(d, struct hv_driver, driver);
-}
+#define drv_to_hv_drv(d)       container_of_const(d, struct hv_driver, driver)
 
 static inline void hv_set_drvdata(struct hv_device *dev, void *data)
 {
index 9709537..cde3de3 100644 (file)
@@ -304,7 +304,7 @@ struct i2c_driver {
 
        u32 flags;
 };
-#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
+#define to_i2c_driver(d) container_of_const(d, struct i2c_driver, driver)
 
 /**
  * struct i2c_client - represent an I2C slave device
index e119f11..0a8a44a 100644 (file)
@@ -183,10 +183,7 @@ struct i3c_driver {
        const struct i3c_device_id *id_table;
 };
 
-static inline struct i3c_driver *drv_to_i3cdrv(struct device_driver *drv)
-{
-       return container_of(drv, struct i3c_driver, driver);
-}
+#define drv_to_i3cdrv(__drv)   container_of_const(__drv, struct i3c_driver, driver)
 
 struct device *i3cdev_to_dev(struct i3c_device *i3cdev);
 
index 9aae44e..3be4e56 100644 (file)
@@ -97,7 +97,7 @@ int maple_add_packet(struct maple_device *mdev, u32 function,
 void maple_clear_dev(struct maple_device *mdev);
 
 #define to_maple_dev(n) container_of(n, struct maple_device, dev)
-#define to_maple_driver(n) container_of(n, struct maple_driver, drv)
+#define to_maple_driver(n) container_of_const(n, struct maple_driver, drv)
 
 #define maple_get_drvdata(d)           dev_get_drvdata(&(d)->dev)
 #define maple_set_drvdata(d,p)         dev_set_drvdata(&(d)->dev, (p))
index 0b971b2..4ab2691 100644 (file)
@@ -94,10 +94,7 @@ struct mcb_driver {
        void (*shutdown)(struct mcb_device *mdev);
 };
 
-static inline struct mcb_driver *to_mcb_driver(struct device_driver *drv)
-{
-       return container_of(drv, struct mcb_driver, driver);
-}
+#define to_mcb_driver(__drv)   container_of_const(__drv, struct mcb_driver, driver)
 
 static inline void *mcb_get_drvdata(struct mcb_device *dev)
 {
index 68f8d2e..efeca5b 100644 (file)
@@ -31,7 +31,7 @@ struct mdio_device {
        struct mii_bus *bus;
        char modalias[MDIO_NAME_SIZE];
 
-       int (*bus_match)(struct device *dev, struct device_driver *drv);
+       int (*bus_match)(struct device *dev, const struct device_driver *drv);
        void (*device_free)(struct mdio_device *mdiodev);
        void (*device_remove)(struct mdio_device *mdiodev);
 
@@ -57,11 +57,8 @@ struct mdio_driver_common {
 };
 #define MDIO_DEVICE_FLAG_PHY           1
 
-static inline struct mdio_driver_common *
-to_mdio_common_driver(const struct device_driver *driver)
-{
-       return container_of(driver, struct mdio_driver_common, driver);
-}
+#define to_mdio_common_driver(__drv_c) container_of_const(__drv_c, struct mdio_driver_common,  \
+                                                          driver)
 
 /* struct mdio_driver: Generic MDIO driver */
 struct mdio_driver {
@@ -80,12 +77,8 @@ struct mdio_driver {
        void (*shutdown)(struct mdio_device *mdiodev);
 };
 
-static inline struct mdio_driver *
-to_mdio_driver(const struct device_driver *driver)
-{
-       return container_of(to_mdio_common_driver(driver), struct mdio_driver,
-                           mdiodrv);
-}
+#define to_mdio_driver(__drv_m)        container_of_const(to_mdio_common_driver(__drv_m),      \
+                                                  struct mdio_driver, mdiodrv)
 
 /* device driver data */
 static inline void mdiodev_set_drvdata(struct mdio_device *mdio, void *data)
@@ -105,7 +98,7 @@ void mdio_device_remove(struct mdio_device *mdiodev);
 void mdio_device_reset(struct mdio_device *mdiodev, int value);
 int mdio_driver_register(struct mdio_driver *drv);
 void mdio_driver_unregister(struct mdio_driver *drv);
-int mdio_device_bus_match(struct device *dev, struct device_driver *drv);
+int mdio_device_bus_match(struct device *dev, const struct device_driver *drv);
 
 static inline void mdio_device_get(struct mdio_device *mdiodev)
 {
index b573f15..ce1f9d7 100644 (file)
@@ -526,7 +526,7 @@ struct mhi_driver {
        struct device_driver driver;
 };
 
-#define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver)
+#define to_mhi_driver(drv) container_of_const(drv, struct mhi_driver, driver)
 #define to_mhi_device(dev) container_of(dev, struct mhi_device, dev)
 
 /**
index 11bf321..7b40fc8 100644 (file)
@@ -221,7 +221,7 @@ struct mhi_ep_driver {
 };
 
 #define to_mhi_ep_device(dev) container_of(dev, struct mhi_ep_device, dev)
-#define to_mhi_ep_driver(drv) container_of(drv, struct mhi_ep_driver, driver)
+#define to_mhi_ep_driver(drv) container_of_const(drv, struct mhi_ep_driver, driver)
 
 /*
  * module_mhi_ep_driver() - Helper macro for drivers that don't do
index ac57769..dfa4800 100644 (file)
@@ -61,13 +61,8 @@ struct moxtet_driver {
        struct device_driver            driver;
 };
 
-static inline struct moxtet_driver *
-to_moxtet_driver(struct device_driver *drv)
-{
-       if (!drv)
-               return NULL;
-       return container_of(drv, struct moxtet_driver, driver);
-}
+#define to_moxtet_driver(__drv)        \
+       ( __drv ? container_of_const(__drv, struct moxtet_driver, driver) : NULL )
 
 extern int __moxtet_register_driver(struct module *owner,
                                    struct moxtet_driver *mdrv);
index b9771ba..fa099e2 100644 (file)
@@ -84,11 +84,7 @@ struct nd_device_driver {
        void (*notify)(struct device *dev, enum nvdimm_event event);
 };
 
-static inline struct nd_device_driver *to_nd_device_driver(
-               struct device_driver *drv)
-{
-       return container_of(drv, struct nd_device_driver, drv);
-};
+#define to_nd_device_driver(__drv)     container_of_const(__drv, struct nd_device_driver, drv)
 
 /**
  * struct nd_namespace_common - core infrastructure of a namespace
index adee6a1..980a3c9 100644 (file)
@@ -105,8 +105,7 @@ struct pci_epf_driver {
        const struct pci_epf_device_id  *id_table;
 };
 
-#define to_pci_epf_driver(drv) (container_of((drv), struct pci_epf_driver, \
-                               driver))
+#define to_pci_epf_driver(drv) container_of_const((drv), struct pci_epf_driver, driver)
 
 /**
  * struct pci_epf_bar - represents the BAR of EPF device
index cafc5ab..aa1c328 100644 (file)
@@ -958,10 +958,8 @@ struct pci_driver {
        bool driver_managed_dma;
 };
 
-static inline struct pci_driver *to_pci_driver(struct device_driver *drv)
-{
-    return drv ? container_of(drv, struct pci_driver, driver) : NULL;
-}
+#define to_pci_driver(__drv)   \
+       ( __drv ? container_of_const(__drv, struct pci_driver, driver) : NULL )
 
 /**
  * PCI_DEVICE - macro used to describe a specific PCI device
index e6e8330..8237d50 100644 (file)
@@ -1179,7 +1179,7 @@ struct phy_driver {
        int (*led_polarity_set)(struct phy_device *dev, int index,
                                unsigned long modes);
 };
-#define to_phy_driver(d) container_of(to_mdio_common_driver(d),                \
+#define to_phy_driver(d) container_of_const(to_mdio_common_driver(d),          \
                                      struct phy_driver, mdiodrv)
 
 #define PHY_ANY_ID "MATCH ANY PHY"
index 7f2ff95..b7a7158 100644 (file)
@@ -383,7 +383,7 @@ struct pnp_driver {
        struct device_driver driver;
 };
 
-#define        to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
+#define        to_pnp_driver(drv) container_of_const(drv, struct pnp_driver, driver)
 
 struct pnp_card_driver {
        struct list_head global_list;
index 2cd6372..3c29f40 100644 (file)
@@ -465,7 +465,7 @@ struct rio_driver {
        struct device_driver driver;
 };
 
-#define        to_rio_driver(drv) container_of(drv,struct rio_driver, driver)
+#define        to_rio_driver(drv) container_of_const(drv,struct rio_driver, driver)
 
 union rio_pw_msg {
        struct {
index 3a9bb5b..688466a 100644 (file)
@@ -945,7 +945,7 @@ struct scmi_device {
        struct scmi_handle *handle;
 };
 
-#define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
+#define to_scmi_dev(d) container_of_const(d, struct scmi_device, dev)
 
 struct scmi_device_id {
        u8 protocol_id;
index 7ca41af..bf2191f 100644 (file)
@@ -80,7 +80,7 @@ struct serio_driver {
 
        struct device_driver driver;
 };
-#define to_serio_driver(d)     container_of(d, struct serio_driver, driver)
+#define to_serio_driver(d)     container_of_const(d, struct serio_driver, driver)
 
 int serio_open(struct serio *serio, struct serio_driver *drv);
 void serio_close(struct serio *serio);
index 3042385..a4608d9 100644 (file)
@@ -91,7 +91,7 @@ struct slim_driver {
        struct device_driver            driver;
        const struct slim_device_id     *id_table;
 };
-#define to_slim_driver(d) container_of(d, struct slim_driver, driver)
+#define to_slim_driver(d) container_of_const(d, struct slim_driver, driver)
 
 /**
  * struct slim_val_inf - Slimbus value or information element
index 7161a31..a532d1e 100644 (file)
@@ -162,7 +162,7 @@ struct apr_driver {
 };
 
 typedef struct apr_driver gpr_driver_t;
-#define to_apr_driver(d) container_of(d, struct apr_driver, driver)
+#define to_apr_driver(d) container_of_const(d, struct apr_driver, driver)
 
 /*
  * use a macro to avoid include chaining to get THIS_MODULE
index 693320b..d405935 100644 (file)
@@ -13,7 +13,7 @@ static inline int is_sdw_slave(const struct device *dev)
        return dev->type == &sdw_slave_type;
 }
 
-#define drv_to_sdw_driver(_drv) container_of(_drv, struct sdw_driver, driver)
+#define drv_to_sdw_driver(_drv) container_of_const(_drv, struct sdw_driver, driver)
 
 #define sdw_register_driver(drv) \
        __sdw_register_driver(drv, THIS_MODULE)
index e8e1e79..3fc5596 100644 (file)
@@ -351,10 +351,8 @@ struct spi_driver {
        struct device_driver    driver;
 };
 
-static inline struct spi_driver *to_spi_driver(struct device_driver *drv)
-{
-       return drv ? container_of(drv, struct spi_driver, driver) : NULL;
-}
+#define to_spi_driver(__drv)   \
+       ( __drv ? container_of_const(__drv, struct spi_driver, driver) : NULL )
 
 extern int __spi_register_driver(struct module *owner, struct spi_driver *sdrv);
 
index a225738..e1fb11e 100644 (file)
@@ -325,7 +325,7 @@ struct ssb_driver {
 
        struct device_driver drv;
 };
-#define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
+#define drv_to_ssb_drv(_drv) container_of_const(_drv, struct ssb_driver, drv)
 
 extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
 #define ssb_driver_register(drv) \
index 1638660..8416bae 100644 (file)
@@ -108,7 +108,7 @@ struct tc_driver {
        struct device_driver driver;
 };
 
-#define to_tc_driver(drv) container_of(drv, struct tc_driver, driver)
+#define to_tc_driver(drv) container_of_const(drv, struct tc_driver, driver)
 
 /*
  * Return TURBOchannel clock frequency in Hz.
index 786b9ae..a54c203 100644 (file)
@@ -298,6 +298,6 @@ struct tee_client_driver {
 };
 
 #define to_tee_client_driver(d) \
-               container_of(d, struct tee_client_driver, driver)
+               container_of_const(d, struct tee_client_driver, driver)
 
 #endif /*__TEE_DRV_H*/
index 96fea92..ecc5cb7 100644 (file)
@@ -209,10 +209,7 @@ struct virtio_driver {
        int (*restore)(struct virtio_device *dev);
 };
 
-static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv)
-{
-       return container_of(drv, struct virtio_driver, driver);
-}
+#define drv_to_virtio(__drv)   container_of_const(__drv, struct virtio_driver, driver)
 
 /* use a macro to avoid include chaining to get THIS_MODULE */
 #define register_virtio_driver(drv) \
index fb3399e..bd12436 100644 (file)
@@ -495,7 +495,7 @@ iscsi_destroy_flashnode_sess(struct iscsi_bus_flash_session *fnode_sess);
 
 extern void iscsi_destroy_all_flashnode(struct Scsi_Host *shost);
 extern int iscsi_flashnode_bus_match(struct device *dev,
-                                    struct device_driver *drv);
+                                    const struct device_driver *drv);
 extern struct device *
 iscsi_find_flashnode_sess(struct Scsi_Host *shost, void *data,
                          int (*fn)(struct device *dev, void *data));
index 2fc641c..882b849 100644 (file)
@@ -73,10 +73,7 @@ static inline struct ac97_codec_device *to_ac97_device(struct device *d)
        return container_of(d, struct ac97_codec_device, dev);
 }
 
-static inline struct ac97_codec_driver *to_ac97_driver(struct device_driver *d)
-{
-       return container_of(d, struct ac97_codec_driver, driver);
-}
+#define to_ac97_driver(__drv) container_of_const(__drv, struct ac97_codec_driver, driver)
 
 #if IS_ENABLED(CONFIG_AC97_BUS_NEW)
 int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv);
index ac22cf0..3f90bdd 100644 (file)
@@ -124,10 +124,7 @@ struct xenbus_driver {
        void (*reclaim_memory)(struct xenbus_device *dev);
 };
 
-static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
-{
-       return container_of(drv, struct xenbus_driver, driver);
-}
+#define to_xenbus_driver(__drv)        container_of_const(__drv, struct xenbus_driver, driver)
 
 int __must_check __xenbus_register_frontend(struct xenbus_driver *drv,
                                            struct module *owner,
index b7bf34a..1e42e13 100644 (file)
@@ -62,7 +62,7 @@
 #define IUCV_IPNORPY   0x10
 #define IUCV_IPALL     0x80
 
-static int iucv_bus_match(struct device *dev, struct device_driver *drv)
+static int iucv_bus_match(struct device *dev, const struct device_driver *drv)
 {
        return 0;
 }
index 40e88d7..96d4d7e 100644 (file)
@@ -469,10 +469,10 @@ static struct attribute *ac97_dev_attrs[] = {
 };
 ATTRIBUTE_GROUPS(ac97_dev);
 
-static int ac97_bus_match(struct device *dev, struct device_driver *drv)
+static int ac97_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct ac97_codec_device *adev = to_ac97_device(dev);
-       struct ac97_codec_driver *adrv = to_ac97_driver(drv);
+       const struct ac97_codec_driver *adrv = to_ac97_driver(drv);
        const struct ac97_id *id = adrv->id_table;
        int i = 0;
 
index 654d620..4492be5 100644 (file)
@@ -40,7 +40,7 @@ MODULE_LICENSE("GPL");
 /*
  * bus definition
  */
-static int snd_seq_bus_match(struct device *dev, struct device_driver *drv)
+static int snd_seq_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct snd_seq_device *sdev = to_seq_dev(dev);
        struct snd_seq_driver *sdrv = to_seq_drv(drv);
@@ -234,7 +234,7 @@ int snd_seq_device_new(struct snd_card *card, int device, const char *id,
                put_device(&dev->dev);
                return err;
        }
-       
+
        if (result)
                *result = dev;
 
index cce2c30..7545ace 100644 (file)
@@ -46,7 +46,7 @@ static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
                return 0;
 }
 
-static int hda_bus_match(struct device *dev, struct device_driver *drv)
+static int hda_bus_match(struct device *dev, const struct device_driver *drv)
 {
        struct hdac_device *hdev = dev_to_hdac_dev(dev);
        struct hdac_driver *hdrv = drv_to_hdac_driver(drv);