Skip to content

Commit 30b06ab

Browse files
committed
Merge tag 'pinctrl-v4.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
Pull pin control fixes from Linus Walleij: - A slew of driver fixes for Mediatek mt7622 - Fix a direction inversion bug in the Ingenic driver - Fix unsupported drive strength setting on the PFC r8a77970 - Off by one and NULL dereference fixes in the NSP driver * tag 'pinctrl-v4.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: pinctrl: nsp: Fix potential NULL dereference pinctrl: nsp: off by ones in nsp_pinmux_enable() pinctrl: sh-pfc: r8a77970: remove SH_PFC_PIN_CFG_DRIVE_STRENGTH flag pinctrl: ingenic: Fix inverted direction for < JZ4770 pinctrl: mt7622: fix a kernel panic when gpio-hog is being applied pinctrl: mt7622: stop using the deprecated pinctrl_add_gpio_range pinctrl: mt7622: fix that pinctrl_claim_hogs cannot work pinctrl: mt7622: fix initialization sequence between eint and gpiochip pinctrl: mt7622: fix error path on failing at groups building
2 parents 706bf68 + c29e9da commit 30b06ab

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

drivers/pinctrl/bcm/pinctrl-nsp-mux.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
460460
const struct nsp_pin_function *func;
461461
const struct nsp_pin_group *grp;
462462

463-
if (grp_select > pinctrl->num_groups ||
464-
func_select > pinctrl->num_functions)
463+
if (grp_select >= pinctrl->num_groups ||
464+
func_select >= pinctrl->num_functions)
465465
return -EINVAL;
466466

467467
func = &pinctrl->functions[func_select];
@@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
577577
return PTR_ERR(pinctrl->base0);
578578

579579
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
580+
if (!res)
581+
return -EINVAL;
580582
pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
581583
resource_size(res));
582584
if (!pinctrl->base1) {

drivers/pinctrl/mediatek/pinctrl-mt7622.c

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ static struct pinctrl_desc mtk_desc = {
14241424

14251425
static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
14261426
{
1427-
struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
1427+
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
14281428
int value, err;
14291429

14301430
err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
@@ -1436,7 +1436,7 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
14361436

14371437
static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
14381438
{
1439-
struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent);
1439+
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
14401440

14411441
mtk_hw_set_value(hw, gpio, PINCTRL_PIN_REG_DO, !!value);
14421442
}
@@ -1508,11 +1508,20 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
15081508
if (ret < 0)
15091509
return ret;
15101510

1511-
ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
1512-
chip->ngpio);
1513-
if (ret < 0) {
1514-
gpiochip_remove(chip);
1515-
return ret;
1511+
/* Just for backward compatible for these old pinctrl nodes without
1512+
* "gpio-ranges" property. Otherwise, called directly from a
1513+
* DeviceTree-supported pinctrl driver is DEPRECATED.
1514+
* Please see Section 2.1 of
1515+
* Documentation/devicetree/bindings/gpio/gpio.txt on how to
1516+
* bind pinctrl and gpio drivers via the "gpio-ranges" property.
1517+
*/
1518+
if (!of_find_property(np, "gpio-ranges", NULL)) {
1519+
ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
1520+
chip->ngpio);
1521+
if (ret < 0) {
1522+
gpiochip_remove(chip);
1523+
return ret;
1524+
}
15161525
}
15171526

15181527
return 0;
@@ -1695,15 +1704,16 @@ static int mtk_pinctrl_probe(struct platform_device *pdev)
16951704
mtk_desc.custom_conf_items = mtk_conf_items;
16961705
#endif
16971706

1698-
hw->pctrl = devm_pinctrl_register(&pdev->dev, &mtk_desc, hw);
1699-
if (IS_ERR(hw->pctrl))
1700-
return PTR_ERR(hw->pctrl);
1707+
err = devm_pinctrl_register_and_init(&pdev->dev, &mtk_desc, hw,
1708+
&hw->pctrl);
1709+
if (err)
1710+
return err;
17011711

17021712
/* Setup groups descriptions per SoC types */
17031713
err = mtk_build_groups(hw);
17041714
if (err) {
17051715
dev_err(&pdev->dev, "Failed to build groups\n");
1706-
return 0;
1716+
return err;
17071717
}
17081718

17091719
/* Setup functions descriptions per SoC types */
@@ -1713,17 +1723,25 @@ static int mtk_pinctrl_probe(struct platform_device *pdev)
17131723
return err;
17141724
}
17151725

1716-
err = mtk_build_gpiochip(hw, pdev->dev.of_node);
1717-
if (err) {
1718-
dev_err(&pdev->dev, "Failed to add gpio_chip\n");
1726+
/* For able to make pinctrl_claim_hogs, we must not enable pinctrl
1727+
* until all groups and functions are being added one.
1728+
*/
1729+
err = pinctrl_enable(hw->pctrl);
1730+
if (err)
17191731
return err;
1720-
}
17211732

17221733
err = mtk_build_eint(hw, pdev);
17231734
if (err)
17241735
dev_warn(&pdev->dev,
17251736
"Failed to add EINT, but pinctrl still can work\n");
17261737

1738+
/* Build gpiochip should be after pinctrl_enable is done */
1739+
err = mtk_build_gpiochip(hw, pdev->dev.of_node);
1740+
if (err) {
1741+
dev_err(&pdev->dev, "Failed to add gpio_chip\n");
1742+
return err;
1743+
}
1744+
17271745
platform_set_drvdata(pdev, hw);
17281746

17291747
return 0;

drivers/pinctrl/pinctrl-ingenic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
536536
ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
537537
} else {
538538
ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
539-
ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, input);
539+
ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
540540
ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
541541
}
542542

drivers/pinctrl/sh-pfc/pfc-r8a77970.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
#include "core.h"
2222
#include "sh_pfc.h"
2323

24-
#define CFG_FLAGS SH_PFC_PIN_CFG_DRIVE_STRENGTH
25-
2624
#define CPU_ALL_PORT(fn, sfx) \
27-
PORT_GP_CFG_22(0, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
28-
PORT_GP_CFG_28(1, fn, sfx, CFG_FLAGS), \
29-
PORT_GP_CFG_17(2, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
30-
PORT_GP_CFG_17(3, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
31-
PORT_GP_CFG_6(4, fn, sfx, CFG_FLAGS), \
32-
PORT_GP_CFG_15(5, fn, sfx, CFG_FLAGS)
25+
PORT_GP_CFG_22(0, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
26+
PORT_GP_28(1, fn, sfx), \
27+
PORT_GP_CFG_17(2, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
28+
PORT_GP_CFG_17(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
29+
PORT_GP_6(4, fn, sfx), \
30+
PORT_GP_15(5, fn, sfx)
3331
/*
3432
* F_() : just information
3533
* FM() : macro for FN_xxx / xxx_MARK

0 commit comments

Comments
 (0)