Commit cf41015e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

driver core: class: make class_find_device*() options const

The class_find_device*() functions do not modify the struct class or the
struct device passed into it, so mark them as const * to enforce that.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230313181843.1207845-7-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 69df024e
...@@ -402,7 +402,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device); ...@@ -402,7 +402,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
* @match is allowed to do anything including calling back into class * @match is allowed to do anything including calling back into class
* code. There's no locking restriction. * code. There's no locking restriction.
*/ */
struct device *class_find_device(struct class *class, struct device *start, struct device *class_find_device(const struct class *class, const struct device *start,
const void *data, const void *data,
int (*match)(struct device *, const void *)) int (*match)(struct device *, const void *))
{ {
......
...@@ -112,8 +112,8 @@ extern void class_dev_iter_exit(struct class_dev_iter *iter); ...@@ -112,8 +112,8 @@ extern void class_dev_iter_exit(struct class_dev_iter *iter);
extern int class_for_each_device(const struct class *class, const struct device *start, extern int class_for_each_device(const struct class *class, const struct device *start,
void *data, void *data,
int (*fn)(struct device *dev, void *data)); int (*fn)(struct device *dev, void *data));
extern struct device *class_find_device(struct class *class, extern struct device *class_find_device(const struct class *class,
struct device *start, const void *data, const struct device *start, const void *data,
int (*match)(struct device *, const void *)); int (*match)(struct device *, const void *));
/** /**
...@@ -122,7 +122,7 @@ extern struct device *class_find_device(struct class *class, ...@@ -122,7 +122,7 @@ extern struct device *class_find_device(struct class *class,
* @class: class type * @class: class type
* @name: name of the device to match * @name: name of the device to match
*/ */
static inline struct device *class_find_device_by_name(struct class *class, static inline struct device *class_find_device_by_name(const struct class *class,
const char *name) const char *name)
{ {
return class_find_device(class, NULL, name, device_match_name); return class_find_device(class, NULL, name, device_match_name);
...@@ -134,8 +134,8 @@ static inline struct device *class_find_device_by_name(struct class *class, ...@@ -134,8 +134,8 @@ static inline struct device *class_find_device_by_name(struct class *class,
* @class: class type * @class: class type
* @np: of_node of the device to match. * @np: of_node of the device to match.
*/ */
static inline struct device * static inline struct device *class_find_device_by_of_node(const struct class *class,
class_find_device_by_of_node(struct class *class, const struct device_node *np) const struct device_node *np)
{ {
return class_find_device(class, NULL, np, device_match_of_node); return class_find_device(class, NULL, np, device_match_of_node);
} }
...@@ -146,8 +146,7 @@ class_find_device_by_of_node(struct class *class, const struct device_node *np) ...@@ -146,8 +146,7 @@ class_find_device_by_of_node(struct class *class, const struct device_node *np)
* @class: class type * @class: class type
* @fwnode: fwnode of the device to match. * @fwnode: fwnode of the device to match.
*/ */
static inline struct device * static inline struct device *class_find_device_by_fwnode(const struct class *class,
class_find_device_by_fwnode(struct class *class,
const struct fwnode_handle *fwnode) const struct fwnode_handle *fwnode)
{ {
return class_find_device(class, NULL, fwnode, device_match_fwnode); return class_find_device(class, NULL, fwnode, device_match_fwnode);
...@@ -159,7 +158,7 @@ class_find_device_by_fwnode(struct class *class, ...@@ -159,7 +158,7 @@ class_find_device_by_fwnode(struct class *class,
* @class: class type * @class: class type
* @devt: device type of the device to match. * @devt: device type of the device to match.
*/ */
static inline struct device *class_find_device_by_devt(struct class *class, static inline struct device *class_find_device_by_devt(const struct class *class,
dev_t devt) dev_t devt)
{ {
return class_find_device(class, NULL, &devt, device_match_devt); return class_find_device(class, NULL, &devt, device_match_devt);
...@@ -173,14 +172,14 @@ struct acpi_device; ...@@ -173,14 +172,14 @@ struct acpi_device;
* @class: class type * @class: class type
* @adev: ACPI_COMPANION device to match. * @adev: ACPI_COMPANION device to match.
*/ */
static inline struct device * static inline struct device *class_find_device_by_acpi_dev(const struct class *class,
class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev) const struct acpi_device *adev)
{ {
return class_find_device(class, NULL, adev, device_match_acpi_dev); return class_find_device(class, NULL, adev, device_match_acpi_dev);
} }
#else #else
static inline struct device * static inline struct device *class_find_device_by_acpi_dev(const struct class *class,
class_find_device_by_acpi_dev(struct class *class, const void *adev) const void *adev)
{ {
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment