Commit e09313ce authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

gpio: mockup: change the signature of unlocked get/set helpers

The unlocked variants only get called from places where we already have
the pointer to the underlying gpio_mockup_chip structure, so take it
as parameter instead of struct gpio_chip.
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 83336668
...@@ -83,10 +83,9 @@ static int gpio_mockup_range_ngpio(unsigned int index) ...@@ -83,10 +83,9 @@ static int gpio_mockup_range_ngpio(unsigned int index)
return gpio_mockup_ranges[index * 2 + 1]; return gpio_mockup_ranges[index * 2 + 1];
} }
static int __gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) static int __gpio_mockup_get(struct gpio_mockup_chip *chip,
unsigned int offset)
{ {
struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
return chip->lines[offset].value; return chip->lines[offset].value;
} }
...@@ -96,7 +95,7 @@ static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) ...@@ -96,7 +95,7 @@ static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset)
int val; int val;
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
val = __gpio_mockup_get(gc, offset); val = __gpio_mockup_get(chip, offset);
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
return val; return val;
...@@ -110,7 +109,7 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc, ...@@ -110,7 +109,7 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc,
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
for_each_set_bit(bit, mask, gc->ngpio) { for_each_set_bit(bit, mask, gc->ngpio) {
val = __gpio_mockup_get(gc, bit); val = __gpio_mockup_get(chip, bit);
__assign_bit(bit, bits, val); __assign_bit(bit, bits, val);
} }
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
...@@ -118,11 +117,9 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc, ...@@ -118,11 +117,9 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc,
return 0; return 0;
} }
static void __gpio_mockup_set(struct gpio_chip *gc, static void __gpio_mockup_set(struct gpio_mockup_chip *chip,
unsigned int offset, int value) unsigned int offset, int value)
{ {
struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
chip->lines[offset].value = !!value; chip->lines[offset].value = !!value;
} }
...@@ -132,7 +129,7 @@ static void gpio_mockup_set(struct gpio_chip *gc, ...@@ -132,7 +129,7 @@ static void gpio_mockup_set(struct gpio_chip *gc,
struct gpio_mockup_chip *chip = gpiochip_get_data(gc); struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
__gpio_mockup_set(gc, offset, value); __gpio_mockup_set(chip, offset, value);
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
} }
...@@ -144,7 +141,7 @@ static void gpio_mockup_set_multiple(struct gpio_chip *gc, ...@@ -144,7 +141,7 @@ static void gpio_mockup_set_multiple(struct gpio_chip *gc,
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
for_each_set_bit(bit, mask, gc->ngpio) for_each_set_bit(bit, mask, gc->ngpio)
__gpio_mockup_set(gc, bit, test_bit(bit, bits)); __gpio_mockup_set(chip, bit, test_bit(bit, bits));
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
} }
...@@ -155,7 +152,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc, ...@@ -155,7 +152,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT; chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
__gpio_mockup_set(gc, offset, value); __gpio_mockup_set(chip, offset, value);
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
return 0; return 0;
......
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