diff options
author | Heikki Krogerus <heikki.krogerus@linux.intel.com> | 2022-10-19 17:55:52 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-10-22 14:22:51 +0300 |
commit | a84436a987e7f4ee8eeb62a8a5abcfc60b356d16 (patch) | |
tree | d24fcd5392f261e70d3a6f7569623cb630c28682 /drivers/usb/typec | |
parent | d182bf156c4cb8b08ce4a75e82b3357b14a4382d (diff) | |
download | linux-a84436a987e7f4ee8eeb62a8a5abcfc60b356d16.tar.xz |
usb: typec: retimer: Use device type for matching
Device name is not reliable so using the type instead in
retimer_fwnode_match().
This will also introduce is_typec_retimer() helper, and
remove the static keyword from the retimer device type. That
will make it accessible also in the main typec class.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20221019145552.32493-1-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/typec')
-rw-r--r-- | drivers/usb/typec/retimer.c | 16 | ||||
-rw-r--r-- | drivers/usb/typec/retimer.h | 4 |
2 files changed, 6 insertions, 14 deletions
diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c index ee94dbbe4745..3a4146ea6e7c 100644 --- a/drivers/usb/typec/retimer.c +++ b/drivers/usb/typec/retimer.c @@ -17,21 +17,9 @@ #include "class.h" #include "retimer.h" -static bool dev_name_ends_with(struct device *dev, const char *suffix) -{ - const char *name = dev_name(dev); - const int name_len = strlen(name); - const int suffix_len = strlen(suffix); - - if (suffix_len > name_len) - return false; - - return strcmp(name + (name_len - suffix_len), suffix) == 0; -} - static int retimer_fwnode_match(struct device *dev, const void *fwnode) { - return device_match_fwnode(dev, fwnode) && dev_name_ends_with(dev, "-retimer"); + return is_typec_retimer(dev) && device_match_fwnode(dev, fwnode); } static void *typec_retimer_match(struct fwnode_handle *fwnode, const char *id, void *data) @@ -97,7 +85,7 @@ static void typec_retimer_release(struct device *dev) kfree(to_typec_retimer(dev)); } -static const struct device_type typec_retimer_dev_type = { +const struct device_type typec_retimer_dev_type = { .name = "typec_retimer", .release = typec_retimer_release, }; diff --git a/drivers/usb/typec/retimer.h b/drivers/usb/typec/retimer.h index fa15951d4846..e34bd23323be 100644 --- a/drivers/usb/typec/retimer.h +++ b/drivers/usb/typec/retimer.h @@ -12,4 +12,8 @@ struct typec_retimer { #define to_typec_retimer(_dev_) container_of(_dev_, struct typec_retimer, dev) +const struct device_type typec_retimer_dev_type; + +#define is_typec_retimer(dev) ((dev)->type == &typec_retimer_dev_type) + #endif /* __USB_TYPEC_RETIMER__ */ |