0009-gpio-sch-use-gpiochip-data-pointer.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From cf3d1330c71d47c4cdb9268f68d2ee5931890d93 Mon Sep 17 00:00:00 2001
  2. From: Linus Walleij <linus.walleij@linaro.org>
  3. Date: Mon, 7 Dec 2015 14:21:49 +0100
  4. Subject: [PATCH 09/18] gpio: sch: use gpiochip data pointer
  5. This makes the driver use the data pointer added to the gpio_chip
  6. to store a pointer to the state container instead of relying on
  7. container_of().
  8. Cc: Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com>
  9. Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
  10. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  11. ---
  12. drivers/gpio/gpio-sch.c | 14 ++++++--------
  13. 1 file changed, 6 insertions(+), 8 deletions(-)
  14. diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
  15. index b72906f5b999..23907fc080a3 100644
  16. --- a/drivers/gpio/gpio-sch.c
  17. +++ b/drivers/gpio/gpio-sch.c
  18. @@ -41,8 +41,6 @@ struct sch_gpio {
  19. unsigned short resume_base;
  20. };
  21. -#define to_sch_gpio(gc) container_of(gc, struct sch_gpio, chip)
  22. -
  23. static unsigned sch_gpio_offset(struct sch_gpio *sch, unsigned gpio,
  24. unsigned reg)
  25. {
  26. @@ -65,7 +63,7 @@ static unsigned sch_gpio_bit(struct sch_gpio *sch, unsigned gpio)
  27. static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg)
  28. {
  29. - struct sch_gpio *sch = to_sch_gpio(gc);
  30. + struct sch_gpio *sch = gpiochip_get_data(gc);
  31. unsigned short offset, bit;
  32. u8 reg_val;
  33. @@ -80,7 +78,7 @@ static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg)
  34. static void sch_gpio_reg_set(struct gpio_chip *gc, unsigned gpio, unsigned reg,
  35. int val)
  36. {
  37. - struct sch_gpio *sch = to_sch_gpio(gc);
  38. + struct sch_gpio *sch = gpiochip_get_data(gc);
  39. unsigned short offset, bit;
  40. u8 reg_val;
  41. @@ -97,7 +95,7 @@ static void sch_gpio_reg_set(struct gpio_chip *gc, unsigned gpio, unsigned reg,
  42. static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num)
  43. {
  44. - struct sch_gpio *sch = to_sch_gpio(gc);
  45. + struct sch_gpio *sch = gpiochip_get_data(gc);
  46. spin_lock(&sch->lock);
  47. sch_gpio_reg_set(gc, gpio_num, GIO, 1);
  48. @@ -112,7 +110,7 @@ static int sch_gpio_get(struct gpio_chip *gc, unsigned gpio_num)
  49. static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val)
  50. {
  51. - struct sch_gpio *sch = to_sch_gpio(gc);
  52. + struct sch_gpio *sch = gpiochip_get_data(gc);
  53. spin_lock(&sch->lock);
  54. sch_gpio_reg_set(gc, gpio_num, GLV, val);
  55. @@ -122,7 +120,7 @@ static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val)
  56. static int sch_gpio_direction_out(struct gpio_chip *gc, unsigned gpio_num,
  57. int val)
  58. {
  59. - struct sch_gpio *sch = to_sch_gpio(gc);
  60. + struct sch_gpio *sch = gpiochip_get_data(gc);
  61. spin_lock(&sch->lock);
  62. sch_gpio_reg_set(gc, gpio_num, GIO, 0);
  63. @@ -217,7 +215,7 @@ static int sch_gpio_probe(struct platform_device *pdev)
  64. platform_set_drvdata(pdev, sch);
  65. - return gpiochip_add(&sch->chip);
  66. + return gpiochip_add_data(&sch->chip, sch);
  67. }
  68. static int sch_gpio_remove(struct platform_device *pdev)
  69. --
  70. 2.16.4