diff options
| author | Linus Walleij <linus.walleij@linaro.org> | 2012-02-01 12:02:47 -0500 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2012-02-01 13:42:35 -0500 |
| commit | 9dfac4fd7f8cdcdf734dff2ccc7ca467f53f1cfd (patch) | |
| tree | 6a9ee37b2aac4b288c85387d83310e5f9cd9108e | |
| parent | 8dc6ae4d448758a30cf5fa822d6fe6f4e15a04c6 (diff) | |
pinctrl: delete raw device pointers in pinmux maps
After discussion with Mark Brown in an unrelated thread about
ADC lookups, it came to my knowledge that the ability to pass
a struct device * in the regulator consumers is just a
historical artifact, and not really recommended. Since there
are no in-kernel users of these pointers, we just kill them
right now, before someone starts to use them.
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
| -rw-r--r-- | Documentation/pinctrl.txt | 5 | ||||
| -rw-r--r-- | drivers/pinctrl/core.c | 22 | ||||
| -rw-r--r-- | drivers/pinctrl/core.h | 3 | ||||
| -rw-r--r-- | drivers/pinctrl/pinconf.c | 8 | ||||
| -rw-r--r-- | drivers/pinctrl/pinmux.c | 27 | ||||
| -rw-r--r-- | include/linux/pinctrl/machine.h | 12 |
6 files changed, 23 insertions, 54 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index 150fd3833d0b..14aecd2b2dbc 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt | |||
| @@ -805,10 +805,7 @@ must match a function provided by the pinmux driver handling this pin range. | |||
| 805 | 805 | ||
| 806 | As you can see we may have several pin controllers on the system and thus | 806 | As you can see we may have several pin controllers on the system and thus |
| 807 | we need to specify which one of them that contain the functions we wish | 807 | we need to specify which one of them that contain the functions we wish |
| 808 | to map. The map can also use struct device * directly, so there is no | 808 | to map. |
| 809 | inherent need to use strings to specify .dev_name or .ctrl_dev_name, these | ||
| 810 | are for the situation where you do not have a handle to the struct device *, | ||
| 811 | for example if they are not yet instantiated or cumbersome to obtain. | ||
| 812 | 809 | ||
| 813 | You register this pinmux mapping to the pinmux subsystem by simply: | 810 | You register this pinmux mapping to the pinmux subsystem by simply: |
| 814 | 811 | ||
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 894cd5e103da..4f10476cc1f2 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
| @@ -48,31 +48,23 @@ void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev) | |||
| 48 | EXPORT_SYMBOL_GPL(pinctrl_dev_get_drvdata); | 48 | EXPORT_SYMBOL_GPL(pinctrl_dev_get_drvdata); |
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | * get_pinctrl_dev_from_dev() - look up pin controller device | 51 | * get_pinctrl_dev_from_devname() - look up pin controller device |
| 52 | * @dev: a device pointer, this may be NULL but then devname needs to be | 52 | * @devname: the name of a device instance, as returned by dev_name() |
| 53 | * defined instead | ||
| 54 | * @devname: the name of a device instance, as returned by dev_name(), this | ||
| 55 | * may be NULL but then dev needs to be defined instead | ||
| 56 | * | 53 | * |
| 57 | * Looks up a pin control device matching a certain device name or pure device | 54 | * Looks up a pin control device matching a certain device name or pure device |
| 58 | * pointer, the pure device pointer will take precedence. | 55 | * pointer, the pure device pointer will take precedence. |
| 59 | */ | 56 | */ |
| 60 | struct pinctrl_dev *get_pinctrl_dev_from_dev(struct device *dev, | 57 | struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *devname) |
| 61 | const char *devname) | ||
| 62 | { | 58 | { |
| 63 | struct pinctrl_dev *pctldev = NULL; | 59 | struct pinctrl_dev *pctldev = NULL; |
| 64 | bool found = false; | 60 | bool found = false; |
| 65 | 61 | ||
| 62 | if (!devname) | ||
| 63 | return NULL; | ||
| 64 | |||
| 66 | mutex_lock(&pinctrldev_list_mutex); | 65 | mutex_lock(&pinctrldev_list_mutex); |
| 67 | list_for_each_entry(pctldev, &pinctrldev_list, node) { | 66 | list_for_each_entry(pctldev, &pinctrldev_list, node) { |
| 68 | if (dev && pctldev->dev == dev) { | 67 | if (!strcmp(dev_name(pctldev->dev), devname)) { |
| 69 | /* Matched on device pointer */ | ||
| 70 | found = true; | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | |||
| 74 | if (devname && | ||
| 75 | !strcmp(dev_name(pctldev->dev), devname)) { | ||
| 76 | /* Matched on device name */ | 68 | /* Matched on device name */ |
| 77 | found = true; | 69 | found = true; |
| 78 | break; | 70 | break; |
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index cfa86da6b4b1..8a8b02e9c18e 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h | |||
| @@ -72,8 +72,7 @@ struct pin_desc { | |||
| 72 | #endif | 72 | #endif |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | struct pinctrl_dev *get_pinctrl_dev_from_dev(struct device *dev, | 75 | struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name); |
| 76 | const char *dev_name); | ||
| 77 | struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin); | 76 | struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin); |
| 78 | int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); | 77 | int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); |
| 79 | int pinctrl_get_device_gpio_range(unsigned gpio, | 78 | int pinctrl_get_device_gpio_range(unsigned gpio, |
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 9fb75456824c..b74f64af1923 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c | |||
| @@ -51,7 +51,7 @@ int pin_config_get(const char *dev_name, const char *name, | |||
| 51 | struct pinctrl_dev *pctldev; | 51 | struct pinctrl_dev *pctldev; |
| 52 | int pin; | 52 | int pin; |
| 53 | 53 | ||
| 54 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | 54 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
| 55 | if (!pctldev) | 55 | if (!pctldev) |
| 56 | return -EINVAL; | 56 | return -EINVAL; |
| 57 | 57 | ||
| @@ -99,7 +99,7 @@ int pin_config_set(const char *dev_name, const char *name, | |||
| 99 | struct pinctrl_dev *pctldev; | 99 | struct pinctrl_dev *pctldev; |
| 100 | int pin; | 100 | int pin; |
| 101 | 101 | ||
| 102 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | 102 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
| 103 | if (!pctldev) | 103 | if (!pctldev) |
| 104 | return -EINVAL; | 104 | return -EINVAL; |
| 105 | 105 | ||
| @@ -118,7 +118,7 @@ int pin_config_group_get(const char *dev_name, const char *pin_group, | |||
| 118 | const struct pinconf_ops *ops; | 118 | const struct pinconf_ops *ops; |
| 119 | int selector; | 119 | int selector; |
| 120 | 120 | ||
| 121 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | 121 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
| 122 | if (!pctldev) | 122 | if (!pctldev) |
| 123 | return -EINVAL; | 123 | return -EINVAL; |
| 124 | ops = pctldev->desc->confops; | 124 | ops = pctldev->desc->confops; |
| @@ -151,7 +151,7 @@ int pin_config_group_set(const char *dev_name, const char *pin_group, | |||
| 151 | int ret; | 151 | int ret; |
| 152 | int i; | 152 | int i; |
| 153 | 153 | ||
| 154 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | 154 | pctldev = get_pinctrl_dev_from_devname(dev_name); |
| 155 | if (!pctldev) | 155 | if (!pctldev) |
| 156 | return -EINVAL; | 156 | return -EINVAL; |
| 157 | ops = pctldev->desc->confops; | 157 | ops = pctldev->desc->confops; |
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 7c3193f7a044..1311f1d22002 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
| @@ -354,7 +354,7 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps, | |||
| 354 | return -EINVAL; | 354 | return -EINVAL; |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) { | 357 | if (!maps[i].ctrl_dev_name) { |
| 358 | pr_err("failed to register map %s (%d): no pin control device given\n", | 358 | pr_err("failed to register map %s (%d): no pin control device given\n", |
| 359 | maps[i].name, i); | 359 | maps[i].name, i); |
| 360 | return -EINVAL; | 360 | return -EINVAL; |
| @@ -366,7 +366,7 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps, | |||
| 366 | return -EINVAL; | 366 | return -EINVAL; |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | if (!maps[i].dev && !maps[i].dev_name) | 369 | if (!maps[i].dev_name) |
| 370 | pr_debug("add system map %s function %s with no device\n", | 370 | pr_debug("add system map %s function %s with no device\n", |
| 371 | maps[i].name, | 371 | maps[i].name, |
| 372 | maps[i].function); | 372 | maps[i].function); |
| @@ -721,20 +721,12 @@ struct pinmux *pinmux_get(struct device *dev, const char *name) | |||
| 721 | /* | 721 | /* |
| 722 | * First, try to find the pctldev given in the map | 722 | * First, try to find the pctldev given in the map |
| 723 | */ | 723 | */ |
| 724 | pctldev = get_pinctrl_dev_from_dev(map->ctrl_dev, | 724 | pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); |
| 725 | map->ctrl_dev_name); | ||
| 726 | if (!pctldev) { | 725 | if (!pctldev) { |
| 727 | const char *devname = NULL; | ||
| 728 | |||
| 729 | if (map->ctrl_dev) | ||
| 730 | devname = dev_name(map->ctrl_dev); | ||
| 731 | else if (map->ctrl_dev_name) | ||
| 732 | devname = map->ctrl_dev_name; | ||
| 733 | |||
| 734 | pr_warning("could not find a pinctrl device for pinmux function %s, fishy, they shall all have one\n", | 726 | pr_warning("could not find a pinctrl device for pinmux function %s, fishy, they shall all have one\n", |
| 735 | map->function); | 727 | map->function); |
| 736 | pr_warning("given pinctrl device name: %s", | 728 | pr_warning("given pinctrl device name: %s", |
| 737 | devname ? devname : "UNDEFINED"); | 729 | map->ctrl_dev_name); |
| 738 | 730 | ||
| 739 | /* Continue to check the other mappings anyway... */ | 731 | /* Continue to check the other mappings anyway... */ |
| 740 | continue; | 732 | continue; |
| @@ -925,7 +917,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev, | |||
| 925 | struct pinmux *pmx; | 917 | struct pinmux *pmx; |
| 926 | int ret; | 918 | int ret; |
| 927 | 919 | ||
| 928 | if (map->dev || map->dev_name) { | 920 | if (map->dev_name) { |
| 929 | /* | 921 | /* |
| 930 | * TODO: the day we have device tree support, we can | 922 | * TODO: the day we have device tree support, we can |
| 931 | * traverse the device tree and hog to specific device nodes | 923 | * traverse the device tree and hog to specific device nodes |
| @@ -996,9 +988,8 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev) | |||
| 996 | if (!map->hog_on_boot) | 988 | if (!map->hog_on_boot) |
| 997 | continue; | 989 | continue; |
| 998 | 990 | ||
| 999 | if ((map->ctrl_dev == dev) || | 991 | if (map->ctrl_dev_name && |
| 1000 | (map->ctrl_dev_name && | 992 | !strcmp(map->ctrl_dev_name, devname)) { |
| 1001 | !strcmp(map->ctrl_dev_name, devname))) { | ||
| 1002 | /* OK time to hog! */ | 993 | /* OK time to hog! */ |
| 1003 | ret = pinmux_hog_map(pctldev, map); | 994 | ret = pinmux_hog_map(pctldev, map); |
| 1004 | if (ret) | 995 | if (ret) |
| @@ -1156,14 +1147,12 @@ static int pinmux_maps_show(struct seq_file *s, void *what) | |||
| 1156 | struct pinmux_map const *map = &pinmux_maps[i]; | 1147 | struct pinmux_map const *map = &pinmux_maps[i]; |
| 1157 | 1148 | ||
| 1158 | seq_printf(s, "%s:\n", map->name); | 1149 | seq_printf(s, "%s:\n", map->name); |
| 1159 | if (map->dev || map->dev_name) | 1150 | if (map->dev_name) |
| 1160 | seq_printf(s, " device: %s\n", | 1151 | seq_printf(s, " device: %s\n", |
| 1161 | map->dev ? dev_name(map->dev) : | ||
| 1162 | map->dev_name); | 1152 | map->dev_name); |
| 1163 | else | 1153 | else |
| 1164 | seq_printf(s, " SYSTEM MUX\n"); | 1154 | seq_printf(s, " SYSTEM MUX\n"); |
| 1165 | seq_printf(s, " controlling device %s\n", | 1155 | seq_printf(s, " controlling device %s\n", |
| 1166 | map->ctrl_dev ? dev_name(map->ctrl_dev) : | ||
| 1167 | map->ctrl_dev_name); | 1156 | map->ctrl_dev_name); |
| 1168 | seq_printf(s, " function: %s\n", map->function); | 1157 | seq_printf(s, " function: %s\n", map->function); |
| 1169 | seq_printf(s, " group: %s\n", map->group ? map->group : | 1158 | seq_printf(s, " group: %s\n", map->group ? map->group : |
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h index d0aecb7f6fb9..f8593fdc6466 100644 --- a/include/linux/pinctrl/machine.h +++ b/include/linux/pinctrl/machine.h | |||
| @@ -17,22 +17,16 @@ | |||
| 17 | * @name: the name of this specific map entry for the particular machine. | 17 | * @name: the name of this specific map entry for the particular machine. |
| 18 | * This is the second parameter passed to pinmux_get() when you want | 18 | * This is the second parameter passed to pinmux_get() when you want |
| 19 | * to have several mappings to the same device | 19 | * to have several mappings to the same device |
| 20 | * @ctrl_dev: the pin control device to be used by this mapping, may be NULL | ||
| 21 | * if you provide .ctrl_dev_name instead (this is more common) | ||
| 22 | * @ctrl_dev_name: the name of the device controlling this specific mapping, | 20 | * @ctrl_dev_name: the name of the device controlling this specific mapping, |
| 23 | * the name must be the same as in your struct device*, may be NULL if | 21 | * the name must be the same as in your struct device* |
| 24 | * you provide .ctrl_dev instead | ||
| 25 | * @function: a function in the driver to use for this mapping, the driver | 22 | * @function: a function in the driver to use for this mapping, the driver |
| 26 | * will lookup the function referenced by this ID on the specified | 23 | * will lookup the function referenced by this ID on the specified |
| 27 | * pin control device | 24 | * pin control device |
| 28 | * @group: sometimes a function can map to different pin groups, so this | 25 | * @group: sometimes a function can map to different pin groups, so this |
| 29 | * selects a certain specific pin group to activate for the function, if | 26 | * selects a certain specific pin group to activate for the function, if |
| 30 | * left as NULL, the first applicable group will be used | 27 | * left as NULL, the first applicable group will be used |
| 31 | * @dev: the device using this specific mapping, may be NULL if you provide | ||
| 32 | * .dev_name instead (this is more common) | ||
| 33 | * @dev_name: the name of the device using this specific mapping, the name | 28 | * @dev_name: the name of the device using this specific mapping, the name |
| 34 | * must be the same as in your struct device*, may be NULL if you | 29 | * must be the same as in your struct device* |
| 35 | * provide .dev instead | ||
| 36 | * @hog_on_boot: if this is set to true, the pin control subsystem will itself | 30 | * @hog_on_boot: if this is set to true, the pin control subsystem will itself |
| 37 | * hog the mappings as the pinmux device drivers are attached, so this is | 31 | * hog the mappings as the pinmux device drivers are attached, so this is |
| 38 | * typically used with system maps (mux mappings without an assigned | 32 | * typically used with system maps (mux mappings without an assigned |
| @@ -42,11 +36,9 @@ | |||
| 42 | */ | 36 | */ |
| 43 | struct pinmux_map { | 37 | struct pinmux_map { |
| 44 | const char *name; | 38 | const char *name; |
| 45 | struct device *ctrl_dev; | ||
| 46 | const char *ctrl_dev_name; | 39 | const char *ctrl_dev_name; |
| 47 | const char *function; | 40 | const char *function; |
| 48 | const char *group; | 41 | const char *group; |
| 49 | struct device *dev; | ||
| 50 | const char *dev_name; | 42 | const char *dev_name; |
| 51 | bool hog_on_boot; | 43 | bool hog_on_boot; |
| 52 | }; | 44 | }; |
