pinctrl: assume map table entries can't have a NULL name field
authorStephen Warren <swarren@nvidia.com>
Fri, 2 Mar 2012 01:48:33 +0000 (18:48 -0700)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 2 Mar 2012 15:20:54 +0000 (16:20 +0100)
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>
Documentation/pinctrl.txt
arch/arm/mach-u300/core.c
drivers/pinctrl/core.c
drivers/tty/serial/sirfsoc_uart.c

index 6fe3232e798e19cbfb7a18e7ee374c59f37390b7..558aac554d098d211de5b1e22095ef1ab56fdd2e 100644 (file)
@@ -782,16 +782,19 @@ spi on the second function mapping:
 static const struct pinctrl_map __initdata mapping[] = {
        {
                .dev_name = "foo-spi.0",
+               .name = PINCTRL_STATE_DEFAULT,
                .ctrl_dev_name = "pinctrl-foo",
                .function = "spi0",
        },
        {
                .dev_name = "foo-i2c.0",
+               .name = PINCTRL_STATE_DEFAULT,
                .ctrl_dev_name = "pinctrl-foo",
                .function = "i2c0",
        },
        {
                .dev_name = "foo-mmc.0",
+               .name = PINCTRL_STATE_DEFAULT,
                .ctrl_dev_name = "pinctrl-foo",
                .function = "mmc0",
        },
@@ -944,10 +947,6 @@ foo_remove()
        pinctrl_put(state->p);
 }
 
-If you want to grab a specific control mapping and not just the first one
-found for this device you can specify a specific mapping name, for example in
-the above example the second i2c0 setting: pinctrl_get(&device, "spi0-pos-B");
-
 This get/enable/disable/put sequence can just as well be handled by bus drivers
 if you don't want each and every driver to handle it and you know the
 arrangement on your bus.
index ea6c79076a910aa1ec215207d6579060fed30ea4..f29565a10e2e91b8d53944c5d51311959dc3c287 100644 (file)
@@ -1612,9 +1612,9 @@ static struct pinctrl_map __initdata u300_pinmux_map[] = {
        PIN_MAP_SYS_HOG("pinctrl-u300", "emif0"),
        PIN_MAP_SYS_HOG("pinctrl-u300", "emif1"),
        /* per-device maps for MMC/SD, SPI and UART */
-       PIN_MAP("MMCSD", "pinctrl-u300", "mmc0", "mmci"),
-       PIN_MAP("SPI", "pinctrl-u300", "spi0", "pl022"),
-       PIN_MAP("UART0", "pinctrl-u300", "uart0", "uart0"),
+       PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "mmc0", "mmci"),
+       PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "spi0", "pl022"),
+       PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "uart0", "uart0"),
 };
 
 struct u300_mux_hog {
@@ -1646,7 +1646,7 @@ static int __init u300_pinctrl_fetch(void)
                struct pinctrl *p;
                int ret;
 
-               p = pinctrl_get(u300_mux_hogs[i].dev, NULL);
+               p = pinctrl_get(u300_mux_hogs[i].dev, PINCTRL_STATE_DEFAULT);
                if (IS_ERR(p)) {
                        pr_err("u300: could not get pinmux hog %s\n",
                               u300_mux_hogs[i].name);
index f25307b0e00a70a76788ca02997e2ad0aac1ef34..6af6d8d117df44e57849a2dcdc888de5c4eb7749 100644 (file)
@@ -461,8 +461,8 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
        int i;
        struct pinctrl_map const *map;
 
-       /* We must have a dev name */
-       if (WARN_ON(!dev))
+       /* We must have both a dev and state name */
+       if (WARN_ON(!dev || !name))
                return ERR_PTR(-EINVAL);
 
        devname = dev_name(dev);
@@ -504,16 +504,9 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
                if (strcmp(map->dev_name, devname))
                        continue;
 
-               /*
-                * If we're looking for a specific named map, this must match,
-                * else we loop and look for the next.
-                */
-               if (name != NULL) {
-                       if (map->name == NULL)
-                               continue;
-                       if (strcmp(map->name, name))
-                               continue;
-               }
+               /* State name must be the one we're looking for */
+               if (strcmp(map->name, name))
+                       continue;
 
                ret = pinmux_apply_muxmap(pctldev, p, dev, devname, map);
                if (ret) {
index c1a871eac4503e7cdf2a4855fbbbe3830cfd66a7..3cabb650a1c10a5e0f33aa1d4b3a1eab4a113f85 100644 (file)
@@ -673,7 +673,7 @@ int sirfsoc_uart_probe(struct platform_device *pdev)
        port->irq = res->start;
 
        if (sirfport->hw_flow_ctrl) {
-               sirfport->p = pinctrl_get(&pdev->dev, NULL);
+               sirfport->p = pinctrl_get(&pdev->dev, PINCTRL_STATE_DEFAULT);
                ret = IS_ERR(sirfport->p);
                if (ret)
                        goto pin_err;