mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
drivers/base: Introduce device_match_t for device finding APIs
There are several drivers/base APIs for finding a specific device, and they currently use the following good type for the @match parameter: int (*match)(struct device *dev, const void *data) Since these operations do not modify the caller-provided @*data, this type is worthy of a dedicated typedef: typedef int (*device_match_t)(struct device *dev, const void *data) Advantages of using device_match_t: - Shorter API declarations and definitions - Prevent further APIs from using a bad type for @match So introduce device_match_t and apply it to the existing (bus|class|driver|auxiliary)_find_device() APIs. Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Link: https://lore.kernel.org/r/20240813-dev_match_api-v3-1-6c6878a99b9f@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f0e5311aa8
commit
b45ed06f46
@@ -126,6 +126,9 @@ struct bus_attribute {
|
||||
int __must_check bus_create_file(const struct bus_type *bus, struct bus_attribute *attr);
|
||||
void bus_remove_file(const struct bus_type *bus, struct bus_attribute *attr);
|
||||
|
||||
/* Matching function type for drivers/base APIs to find a specific device */
|
||||
typedef int (*device_match_t)(struct device *dev, const void *data);
|
||||
|
||||
/* Generic device matching functions that all busses can use to match with */
|
||||
int device_match_name(struct device *dev, const void *name);
|
||||
int device_match_of_node(struct device *dev, const void *np);
|
||||
@@ -139,8 +142,7 @@ int device_match_any(struct device *dev, const void *unused);
|
||||
int bus_for_each_dev(const struct bus_type *bus, struct device *start, void *data,
|
||||
int (*fn)(struct device *dev, void *data));
|
||||
struct device *bus_find_device(const struct bus_type *bus, struct device *start,
|
||||
const void *data,
|
||||
int (*match)(struct device *dev, const void *data));
|
||||
const void *data, device_match_t match);
|
||||
/**
|
||||
* bus_find_device_by_name - device iterator for locating a particular device
|
||||
* of a specific name.
|
||||
|
||||
Reference in New Issue
Block a user