@@ -269,7 +269,8 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
269269/**
270270 * gpio_to_pin() - GPIO range GPIO number to pin number translation
271271 * @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
273274 *
274275 * Finds the pin number for a given GPIO using the specified GPIO range
275276 * as a base for translation. The distinction between linear GPIO ranges
@@ -280,13 +281,13 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev,
280281 * result of successful pinctrl_get_device_gpio_range calls)!
281282 */
282283static inline int gpio_to_pin (struct pinctrl_gpio_range * range ,
283- unsigned int gpio )
284+ struct gpio_chip * gc , unsigned int offset )
284285{
285- unsigned int offset = gpio - range -> base ;
286+ unsigned int pin = gc -> base + offset - range -> base ;
286287 if (range -> pins )
287- return range -> pins [offset ];
288+ return range -> pins [pin ];
288289 else
289- return range -> pin_base + offset ;
290+ return range -> pin_base + pin ;
290291}
291292
292293/**
@@ -777,7 +778,7 @@ bool pinctrl_gpio_can_use_line(struct gpio_chip *gc, unsigned int offset)
777778 mutex_lock (& pctldev -> mutex );
778779
779780 /* Convert to the pin controllers number space */
780- pin = gpio_to_pin (range , gc -> base + offset );
781+ pin = gpio_to_pin (range , gc , offset );
781782
782783 result = pinmux_can_be_used_for_gpio (pctldev , pin );
783784
@@ -812,7 +813,7 @@ int pinctrl_gpio_request(struct gpio_chip *gc, unsigned int offset)
812813 mutex_lock (& pctldev -> mutex );
813814
814815 /* Convert to the pin controllers number space */
815- pin = gpio_to_pin (range , gc -> base + offset );
816+ pin = gpio_to_pin (range , gc , offset );
816817
817818 ret = pinmux_request_gpio (pctldev , range , pin , gc -> base + offset );
818819
@@ -844,7 +845,7 @@ void pinctrl_gpio_free(struct gpio_chip *gc, unsigned int offset)
844845 mutex_lock (& pctldev -> mutex );
845846
846847 /* Convert to the pin controllers number space */
847- pin = gpio_to_pin (range , gc -> base + offset );
848+ pin = gpio_to_pin (range , gc , offset );
848849
849850 pinmux_free_gpio (pctldev , pin , range );
850851
@@ -868,7 +869,7 @@ static int pinctrl_gpio_direction(struct gpio_chip *gc, unsigned int offset,
868869 mutex_lock (& pctldev -> mutex );
869870
870871 /* Convert to the pin controllers number space */
871- pin = gpio_to_pin (range , gc -> base + offset );
872+ pin = gpio_to_pin (range , gc , offset );
872873 ret = pinmux_gpio_direction (pctldev , range , pin , input );
873874
874875 mutex_unlock (& pctldev -> mutex );
@@ -929,7 +930,7 @@ int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
929930 return ret ;
930931
931932 mutex_lock (& pctldev -> mutex );
932- pin = gpio_to_pin (range , gc -> base + offset );
933+ pin = gpio_to_pin (range , gc , offset );
933934 ret = pinconf_set_config (pctldev , pin , configs , ARRAY_SIZE (configs ));
934935 mutex_unlock (& pctldev -> mutex );
935936
0 commit comments