Skip to content

Commit f8fb469

Browse files
committed
driver core: make driver_find_device() take a const *
The function driver_find_device() does not modify the struct device_driver structure directly, so it is safe to be marked as a constant pointer type. As that is fixed up, also change the function signature on the inline functions that call this, which are: driver_find_device_by_name() driver_find_device_by_of_node() driver_find_device_by_devt() driver_find_next_device() driver_find_device_by_acpi_dev() Cc: "Rafael J. Wysocki" <[email protected]> Link: https://lore.kernel.org/r/2024070849-broken-front-9eb5@gregkh Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ab7a880 commit f8fb469

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/base/driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
148148
* if it does. If the callback returns non-zero, this function will
149149
* return to the caller and not iterate over any more devices.
150150
*/
151-
struct device *driver_find_device(struct device_driver *drv,
151+
struct device *driver_find_device(const struct device_driver *drv,
152152
struct device *start, const void *data,
153153
int (*match)(struct device *dev, const void *data))
154154
{

include/linux/device/driver.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int driver_set_override(struct device *dev, const char **override,
155155
const char *s, size_t len);
156156
int __must_check driver_for_each_device(struct device_driver *drv, struct device *start,
157157
void *data, int (*fn)(struct device *dev, void *));
158-
struct device *driver_find_device(struct device_driver *drv,
158+
struct device *driver_find_device(const struct device_driver *drv,
159159
struct device *start, const void *data,
160160
int (*match)(struct device *dev, const void *data));
161161

@@ -165,7 +165,7 @@ struct device *driver_find_device(struct device_driver *drv,
165165
* @drv: the driver we're iterating
166166
* @name: name of the device to match
167167
*/
168-
static inline struct device *driver_find_device_by_name(struct device_driver *drv,
168+
static inline struct device *driver_find_device_by_name(const struct device_driver *drv,
169169
const char *name)
170170
{
171171
return driver_find_device(drv, NULL, name, device_match_name);
@@ -178,7 +178,7 @@ static inline struct device *driver_find_device_by_name(struct device_driver *dr
178178
* @np: of_node pointer to match.
179179
*/
180180
static inline struct device *
181-
driver_find_device_by_of_node(struct device_driver *drv,
181+
driver_find_device_by_of_node(const struct device_driver *drv,
182182
const struct device_node *np)
183183
{
184184
return driver_find_device(drv, NULL, np, device_match_of_node);
@@ -203,13 +203,13 @@ driver_find_device_by_fwnode(struct device_driver *drv,
203203
* @drv: the driver we're iterating
204204
* @devt: devt pointer to match.
205205
*/
206-
static inline struct device *driver_find_device_by_devt(struct device_driver *drv,
206+
static inline struct device *driver_find_device_by_devt(const struct device_driver *drv,
207207
dev_t devt)
208208
{
209209
return driver_find_device(drv, NULL, &devt, device_match_devt);
210210
}
211211

212-
static inline struct device *driver_find_next_device(struct device_driver *drv,
212+
static inline struct device *driver_find_next_device(const struct device_driver *drv,
213213
struct device *start)
214214
{
215215
return driver_find_device(drv, start, NULL, device_match_any);
@@ -223,14 +223,14 @@ static inline struct device *driver_find_next_device(struct device_driver *drv,
223223
* @adev: ACPI_COMPANION device to match.
224224
*/
225225
static inline struct device *
226-
driver_find_device_by_acpi_dev(struct device_driver *drv,
226+
driver_find_device_by_acpi_dev(const struct device_driver *drv,
227227
const struct acpi_device *adev)
228228
{
229229
return driver_find_device(drv, NULL, adev, device_match_acpi_dev);
230230
}
231231
#else
232232
static inline struct device *
233-
driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
233+
driver_find_device_by_acpi_dev(const struct device_driver *drv, const void *adev)
234234
{
235235
return NULL;
236236
}

0 commit comments

Comments
 (0)