144-add-removed-syscon_regmap_lookup_by_pdevname.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From: Adrian Schmutzler <[email protected]>
  2. Date: Fri, 03 Apr 2020 19:50:03 +0200
  3. Subject: add removed helper syscon_regmap_lookup_by_pdevname
  4. The helper syscon_regmap_lookup_by_pdevname has been removed in 29d14b668d2f
  5. ("mfd: Remove unused helper syscon_regmap_lookup_by_pdevname") due to lack
  6. of users.
  7. Thus, we have to maintain it locally.
  8. This patch includes a fix due to changes in driver_find_device;
  9. kernel commit: 92ce7e83b4e5 ("driver_find_device: Unify the match function
  10. with class_find_device()")
  11. Signed-off-by: Adrian Schmutzler <[email protected]>
  12. --- a/drivers/mfd/syscon.c
  13. +++ b/drivers/mfd/syscon.c
  14. @@ -209,6 +209,27 @@ struct regmap *syscon_regmap_lookup_by_c
  15. }
  16. EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
  17. +static int syscon_match_pdevname(struct device *dev, const void *data)
  18. +{
  19. + return !strcmp(dev_name(dev), (const char *)data);
  20. +}
  21. +
  22. +struct regmap *syscon_regmap_lookup_by_pdevname(const char *s)
  23. +{
  24. + struct device *dev;
  25. + struct syscon *syscon;
  26. +
  27. + dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s,
  28. + syscon_match_pdevname);
  29. + if (!dev)
  30. + return ERR_PTR(-EPROBE_DEFER);
  31. +
  32. + syscon = dev_get_drvdata(dev);
  33. +
  34. + return syscon->regmap;
  35. +}
  36. +EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_pdevname);
  37. +
  38. struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
  39. const char *property)
  40. {
  41. --- a/include/linux/mfd/syscon.h
  42. +++ b/include/linux/mfd/syscon.h
  43. @@ -20,6 +20,7 @@ struct device_node;
  44. extern struct regmap *device_node_to_regmap(struct device_node *np);
  45. extern struct regmap *syscon_node_to_regmap(struct device_node *np);
  46. extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
  47. +extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s);
  48. extern struct regmap *syscon_regmap_lookup_by_phandle(
  49. struct device_node *np,
  50. const char *property);
  51. @@ -46,6 +47,11 @@ static inline struct regmap *syscon_regm
  52. {
  53. return ERR_PTR(-ENOTSUPP);
  54. }
  55. +
  56. +static inline struct regmap *syscon_regmap_lookup_by_pdevname(const char *s)
  57. +{
  58. + return ERR_PTR(-ENOTSUPP);
  59. +}
  60. static inline struct regmap *syscon_regmap_lookup_by_phandle(
  61. struct device_node *np,