diff options
author | Stephen Warren <swarren@nvidia.com> | 2012-03-01 20:48:33 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-03-02 10:20:54 -0500 |
commit | 110e4ec5a1cfe20190e7f8c2b8b4eef369de3c99 (patch) | |
tree | 2e20b44478f47069ac19f0ef9f5a92bee7576bdd | |
parent | 46919ae63d4820e76724beb655274ce143f0da0b (diff) |
pinctrl: assume map table entries can't have a NULL name field
pinctrl_register_mappings() already requires that every mapping table
entry have a non-NULL name field.
Logically, this makes sense too; drivers should always request a specific
named state so they know what they're getting. Relying on getting the
first mentioned state in the mapping table is error-prone, and a nasty
special case to implement, given that a given the mapping table may define
multiple states for a device.
Remove a small part of the documentation that talked about optionally
requesting a specific state; it's mandatory now.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | Documentation/pinctrl.txt | 7 | ||||
-rw-r--r-- | arch/arm/mach-u300/core.c | 8 | ||||
-rw-r--r-- | drivers/pinctrl/core.c | 17 | ||||
-rw-r--r-- | drivers/tty/serial/sirfsoc_uart.c | 2 |
4 files changed, 13 insertions, 21 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index 6fe3232e798e..558aac554d09 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt | |||
@@ -782,16 +782,19 @@ spi on the second function mapping: | |||
782 | static const struct pinctrl_map __initdata mapping[] = { | 782 | static const struct pinctrl_map __initdata mapping[] = { |
783 | { | 783 | { |
784 | .dev_name = "foo-spi.0", | 784 | .dev_name = "foo-spi.0", |
785 | .name = PINCTRL_STATE_DEFAULT, | ||
785 | .ctrl_dev_name = "pinctrl-foo", | 786 | .ctrl_dev_name = "pinctrl-foo", |
786 | .function = "spi0", | 787 | .function = "spi0", |
787 | }, | 788 | }, |
788 | { | 789 | { |
789 | .dev_name = "foo-i2c.0", | 790 | .dev_name = "foo-i2c.0", |
791 | .name = PINCTRL_STATE_DEFAULT, | ||
790 | .ctrl_dev_name = "pinctrl-foo", | 792 | .ctrl_dev_name = "pinctrl-foo", |
791 | .function = "i2c0", | 793 | .function = "i2c0", |
792 | }, | 794 | }, |
793 | { | 795 | { |
794 | .dev_name = "foo-mmc.0", | 796 | .dev_name = "foo-mmc.0", |
797 | .name = PINCTRL_STATE_DEFAULT, | ||
795 | .ctrl_dev_name = "pinctrl-foo", | 798 | .ctrl_dev_name = "pinctrl-foo", |
796 | .function = "mmc0", | 799 | .function = "mmc0", |
797 | }, | 800 | }, |
@@ -944,10 +947,6 @@ foo_remove() | |||
944 | pinctrl_put(state->p); | 947 | pinctrl_put(state->p); |
945 | } | 948 | } |
946 | 949 | ||
947 | If you want to grab a specific control mapping and not just the first one | ||
948 | found for this device you can specify a specific mapping name, for example in | ||
949 | the above example the second i2c0 setting: pinctrl_get(&device, "spi0-pos-B"); | ||
950 | |||
951 | This get/enable/disable/put sequence can just as well be handled by bus drivers | 950 | This get/enable/disable/put sequence can just as well be handled by bus drivers |
952 | if you don't want each and every driver to handle it and you know the | 951 | if you don't want each and every driver to handle it and you know the |
953 | arrangement on your bus. | 952 | arrangement on your bus. |
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c index ea6c79076a91..f29565a10e2e 100644 --- a/arch/arm/mach-u300/core.c +++ b/arch/arm/mach-u300/core.c | |||
@@ -1612,9 +1612,9 @@ static struct pinctrl_map __initdata u300_pinmux_map[] = { | |||
1612 | PIN_MAP_SYS_HOG("pinctrl-u300", "emif0"), | 1612 | PIN_MAP_SYS_HOG("pinctrl-u300", "emif0"), |
1613 | PIN_MAP_SYS_HOG("pinctrl-u300", "emif1"), | 1613 | PIN_MAP_SYS_HOG("pinctrl-u300", "emif1"), |
1614 | /* per-device maps for MMC/SD, SPI and UART */ | 1614 | /* per-device maps for MMC/SD, SPI and UART */ |
1615 | PIN_MAP("MMCSD", "pinctrl-u300", "mmc0", "mmci"), | 1615 | PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "mmc0", "mmci"), |
1616 | PIN_MAP("SPI", "pinctrl-u300", "spi0", "pl022"), | 1616 | PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "spi0", "pl022"), |
1617 | PIN_MAP("UART0", "pinctrl-u300", "uart0", "uart0"), | 1617 | PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "uart0", "uart0"), |
1618 | }; | 1618 | }; |
1619 | 1619 | ||
1620 | struct u300_mux_hog { | 1620 | struct u300_mux_hog { |
@@ -1646,7 +1646,7 @@ static int __init u300_pinctrl_fetch(void) | |||
1646 | struct pinctrl *p; | 1646 | struct pinctrl *p; |
1647 | int ret; | 1647 | int ret; |
1648 | 1648 | ||
1649 | p = pinctrl_get(u300_mux_hogs[i].dev, NULL); | 1649 | p = pinctrl_get(u300_mux_hogs[i].dev, PINCTRL_STATE_DEFAULT); |
1650 | if (IS_ERR(p)) { | 1650 | if (IS_ERR(p)) { |
1651 | pr_err("u300: could not get pinmux hog %s\n", | 1651 | pr_err("u300: could not get pinmux hog %s\n", |
1652 | u300_mux_hogs[i].name); | 1652 | u300_mux_hogs[i].name); |
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index f25307b0e00a..6af6d8d117df 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -461,8 +461,8 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name) | |||
461 | int i; | 461 | int i; |
462 | struct pinctrl_map const *map; | 462 | struct pinctrl_map const *map; |
463 | 463 | ||
464 | /* We must have a dev name */ | 464 | /* We must have both a dev and state name */ |
465 | if (WARN_ON(!dev)) | 465 | if (WARN_ON(!dev || !name)) |
466 | return ERR_PTR(-EINVAL); | 466 | return ERR_PTR(-EINVAL); |
467 | 467 | ||
468 | devname = dev_name(dev); | 468 | devname = dev_name(dev); |
@@ -504,16 +504,9 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name) | |||
504 | if (strcmp(map->dev_name, devname)) | 504 | if (strcmp(map->dev_name, devname)) |
505 | continue; | 505 | continue; |
506 | 506 | ||
507 | /* | 507 | /* State name must be the one we're looking for */ |
508 | * If we're looking for a specific named map, this must match, | 508 | if (strcmp(map->name, name)) |
509 | * else we loop and look for the next. | 509 | continue; |
510 | */ | ||
511 | if (name != NULL) { | ||
512 | if (map->name == NULL) | ||
513 | continue; | ||
514 | if (strcmp(map->name, name)) | ||
515 | continue; | ||
516 | } | ||
517 | 510 | ||
518 | ret = pinmux_apply_muxmap(pctldev, p, dev, devname, map); | 511 | ret = pinmux_apply_muxmap(pctldev, p, dev, devname, map); |
519 | if (ret) { | 512 | if (ret) { |
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c index c1a871eac450..3cabb650a1c1 100644 --- a/drivers/tty/serial/sirfsoc_uart.c +++ b/drivers/tty/serial/sirfsoc_uart.c | |||
@@ -673,7 +673,7 @@ int sirfsoc_uart_probe(struct platform_device *pdev) | |||
673 | port->irq = res->start; | 673 | port->irq = res->start; |
674 | 674 | ||
675 | if (sirfport->hw_flow_ctrl) { | 675 | if (sirfport->hw_flow_ctrl) { |
676 | sirfport->p = pinctrl_get(&pdev->dev, NULL); | 676 | sirfport->p = pinctrl_get(&pdev->dev, PINCTRL_STATE_DEFAULT); |
677 | ret = IS_ERR(sirfport->p); | 677 | ret = IS_ERR(sirfport->p); |
678 | if (ret) | 678 | if (ret) |
679 | goto pin_err; | 679 | goto pin_err; |