@@ -269,7 +269,8 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
269
269
/**
270
270
* gpio_to_pin() - GPIO range GPIO number to pin number translation
271
271
* @range: GPIO range used for the translation
272
- * @gpio: gpio pin to translate to a pin number
272
+ * @gc: GPIO chip structure from the GPIO subsystem
273
+ * @offset: hardware offset of the GPIO relative to the controller
273
274
*
274
275
* Finds the pin number for a given GPIO using the specified GPIO range
275
276
* as a base for translation. The distinction between linear GPIO ranges
@@ -280,13 +281,13 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
280
281
* result of successful pinctrl_get_device_gpio_range calls)!
281
282
*/
282
283
static inline int gpio_to_pin (struct pinctrl_gpio_range * range ,
283
- unsigned int gpio )
284
+ struct gpio_chip * gc , unsigned int offset )
284
285
{
285
- unsigned int offset = gpio - range -> base ;
286
+ unsigned int pin = gc -> base + offset - range -> base ;
286
287
if (range -> pins )
287
- return range -> pins [offset ];
288
+ return range -> pins [pin ];
288
289
else
289
- return range -> pin_base + offset ;
290
+ return range -> pin_base + pin ;
290
291
}
291
292
292
293
/**
@@ -777,7 +778,7 @@ bool pinctrl_gpio_can_use_line(struct gpio_chip *gc, unsigned int offset)
777
778
mutex_lock (& pctldev -> mutex );
778
779
779
780
/* Convert to the pin controllers number space */
780
- pin = gpio_to_pin (range , gc -> base + offset );
781
+ pin = gpio_to_pin (range , gc , offset );
781
782
782
783
result = pinmux_can_be_used_for_gpio (pctldev , pin );
783
784
@@ -812,7 +813,7 @@ int pinctrl_gpio_request(struct gpio_chip *gc, unsigned int offset)
812
813
mutex_lock (& pctldev -> mutex );
813
814
814
815
/* Convert to the pin controllers number space */
815
- pin = gpio_to_pin (range , gc -> base + offset );
816
+ pin = gpio_to_pin (range , gc , offset );
816
817
817
818
ret = pinmux_request_gpio (pctldev , range , pin , gc -> base + offset );
818
819
@@ -844,7 +845,7 @@ void pinctrl_gpio_free(struct gpio_chip *gc, unsigned int offset)
844
845
mutex_lock (& pctldev -> mutex );
845
846
846
847
/* Convert to the pin controllers number space */
847
- pin = gpio_to_pin (range , gc -> base + offset );
848
+ pin = gpio_to_pin (range , gc , offset );
848
849
849
850
pinmux_free_gpio (pctldev , pin , range );
850
851
@@ -868,7 +869,7 @@ static int pinctrl_gpio_direction(struct gpio_chip *gc, unsigned int offset,
868
869
mutex_lock (& pctldev -> mutex );
869
870
870
871
/* Convert to the pin controllers number space */
871
- pin = gpio_to_pin (range , gc -> base + offset );
872
+ pin = gpio_to_pin (range , gc , offset );
872
873
ret = pinmux_gpio_direction (pctldev , range , pin , input );
873
874
874
875
mutex_unlock (& pctldev -> mutex );
@@ -929,7 +930,7 @@ int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
929
930
return ret ;
930
931
931
932
mutex_lock (& pctldev -> mutex );
932
- pin = gpio_to_pin (range , gc -> base + offset );
933
+ pin = gpio_to_pin (range , gc , offset );
933
934
ret = pinconf_set_config (pctldev , pin , configs , ARRAY_SIZE (configs ));
934
935
mutex_unlock (& pctldev -> mutex );
935
936
0 commit comments