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

Configure Feed

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

driver core: make [device_]driver_attach take a const *

Change device_driver_attach() and driver_attach() to take a const * to
struct device driver as neither of them modify the structure at all.

Also, for some odd reason, drivers/dma/idxd/compat.c had a duplicate
external reference to device_driver_attach(), so remove that to fix up
the build, it should never have had that there in the first place.

Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Petr Tesarik <petr.tesarik.ext@huawei.com>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: dmaengine@vger.kernel.org
Link: https://lore.kernel.org/r/2024061401-rasping-manger-c385@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+10 -9
+3 -2
drivers/base/base.h
··· 161 161 void driver_detach(const struct device_driver *drv); 162 162 void driver_deferred_probe_del(struct device *dev); 163 163 void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf); 164 - static inline int driver_match_device(struct device_driver *drv, 164 + static inline int driver_match_device(const struct device_driver *drv, 165 165 struct device *dev) 166 166 { 167 - return drv->bus->match ? drv->bus->match(dev, drv) : 1; 167 + /* cast will be removed in the future when match can handle a const pointer properly. */ 168 + return drv->bus->match ? drv->bus->match(dev, (struct device_driver *)drv) : 1; 168 169 } 169 170 170 171 static inline void dev_sync_state(struct device *dev)
+5 -4
drivers/base/dd.c
··· 1118 1118 * Manually attach driver to a device. Will acquire both @dev lock and 1119 1119 * @dev->parent lock if needed. Returns 0 on success, -ERR on failure. 1120 1120 */ 1121 - int device_driver_attach(struct device_driver *drv, struct device *dev) 1121 + int device_driver_attach(const struct device_driver *drv, struct device *dev) 1122 1122 { 1123 1123 int ret; 1124 1124 ··· 1154 1154 1155 1155 static int __driver_attach(struct device *dev, void *data) 1156 1156 { 1157 - struct device_driver *drv = data; 1157 + const struct device_driver *drv = data; 1158 1158 bool async = false; 1159 1159 int ret; 1160 1160 ··· 1227 1227 * returns 0 and the @dev->driver is set, we've found a 1228 1228 * compatible pair. 1229 1229 */ 1230 - int driver_attach(struct device_driver *drv) 1230 + int driver_attach(const struct device_driver *drv) 1231 1231 { 1232 - return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); 1232 + /* The (void *) will be put back to const * in __driver_attach() */ 1233 + return bus_for_each_dev(drv->bus, NULL, (void *)drv, __driver_attach); 1233 1234 } 1234 1235 EXPORT_SYMBOL_GPL(driver_attach); 1235 1236
-1
drivers/dma/idxd/compat.c
··· 7 7 #include <linux/device/bus.h> 8 8 #include "idxd.h" 9 9 10 - extern int device_driver_attach(struct device_driver *drv, struct device *dev); 11 10 extern void device_driver_detach(struct device *dev); 12 11 13 12 #define DRIVER_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \
+2 -2
include/linux/device.h
··· 1177 1177 * Manual binding of a device to driver. See drivers/base/bus.c 1178 1178 * for information on use. 1179 1179 */ 1180 - int __must_check device_driver_attach(struct device_driver *drv, 1180 + int __must_check device_driver_attach(const struct device_driver *drv, 1181 1181 struct device *dev); 1182 1182 int __must_check device_bind_driver(struct device *dev); 1183 1183 void device_release_driver(struct device *dev); 1184 1184 int __must_check device_attach(struct device *dev); 1185 - int __must_check driver_attach(struct device_driver *drv); 1185 + int __must_check driver_attach(const struct device_driver *drv); 1186 1186 void device_initial_probe(struct device *dev); 1187 1187 int __must_check device_reprobe(struct device *dev); 1188 1188