Skip to content

Commit 9dfac4f

Browse files
author
Linus Walleij
committed
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>
1 parent 8dc6ae4 commit 9dfac4f

6 files changed

Lines changed: 23 additions & 54 deletions

File tree

‎Documentation/pinctrl.txt‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,7 @@ must match a function provided by the pinmux driver handling this pin range.
805805

806806
As you can see we may have several pin controllers on the system and thus
807807
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
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.
808+
to map.
812809

813810
You register this pinmux mapping to the pinmux subsystem by simply:
814811

‎drivers/pinctrl/core.c‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,23 @@ void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev)
4848
EXPORT_SYMBOL_GPL(pinctrl_dev_get_drvdata);
4949

5050
/**
51-
* get_pinctrl_dev_from_dev() - look up pin controller device
52-
* @dev: a device pointer, this may be NULL but then devname needs to be
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
51+
* get_pinctrl_dev_from_devname() - look up pin controller device
52+
* @devname: the name of a device instance, as returned by dev_name()
5653
*
5754
* Looks up a pin control device matching a certain device name or pure device
5855
* pointer, the pure device pointer will take precedence.
5956
*/
60-
struct pinctrl_dev *get_pinctrl_dev_from_dev(struct device *dev,
61-
const char *devname)
57+
struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *devname)
6258
{
6359
struct pinctrl_dev *pctldev = NULL;
6460
bool found = false;
6561

62+
if (!devname)
63+
return NULL;
64+
6665
mutex_lock(&pinctrldev_list_mutex);
6766
list_for_each_entry(pctldev, &pinctrldev_list, node) {
68-
if (dev && pctldev->dev == dev) {
69-
/* Matched on device pointer */
70-
found = true;
71-
break;
72-
}
73-
74-
if (devname &&
75-
!strcmp(dev_name(pctldev->dev), devname)) {
67+
if (!strcmp(dev_name(pctldev->dev), devname)) {
7668
/* Matched on device name */
7769
found = true;
7870
break;

‎drivers/pinctrl/core.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ struct pin_desc {
7272
#endif
7373
};
7474

75-
struct pinctrl_dev *get_pinctrl_dev_from_dev(struct device *dev,
76-
const char *dev_name);
75+
struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
7776
struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, unsigned int pin);
7877
int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);
7978
int pinctrl_get_device_gpio_range(unsigned gpio,

‎drivers/pinctrl/pinconf.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int pin_config_get(const char *dev_name, const char *name,
5151
struct pinctrl_dev *pctldev;
5252
int pin;
5353

54-
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
54+
pctldev = get_pinctrl_dev_from_devname(dev_name);
5555
if (!pctldev)
5656
return -EINVAL;
5757

@@ -99,7 +99,7 @@ int pin_config_set(const char *dev_name, const char *name,
9999
struct pinctrl_dev *pctldev;
100100
int pin;
101101

102-
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
102+
pctldev = get_pinctrl_dev_from_devname(dev_name);
103103
if (!pctldev)
104104
return -EINVAL;
105105

@@ -118,7 +118,7 @@ int pin_config_group_get(const char *dev_name, const char *pin_group,
118118
const struct pinconf_ops *ops;
119119
int selector;
120120

121-
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
121+
pctldev = get_pinctrl_dev_from_devname(dev_name);
122122
if (!pctldev)
123123
return -EINVAL;
124124
ops = pctldev->desc->confops;
@@ -151,7 +151,7 @@ int pin_config_group_set(const char *dev_name, const char *pin_group,
151151
int ret;
152152
int i;
153153

154-
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
154+
pctldev = get_pinctrl_dev_from_devname(dev_name);
155155
if (!pctldev)
156156
return -EINVAL;
157157
ops = pctldev->desc->confops;

‎drivers/pinctrl/pinmux.c‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
354354
return -EINVAL;
355355
}
356356

357-
if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) {
357+
if (!maps[i].ctrl_dev_name) {
358358
pr_err("failed to register map %s (%d): no pin control device given\n",
359359
maps[i].name, i);
360360
return -EINVAL;
@@ -366,7 +366,7 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
366366
return -EINVAL;
367367
}
368368

369-
if (!maps[i].dev && !maps[i].dev_name)
369+
if (!maps[i].dev_name)
370370
pr_debug("add system map %s function %s with no device\n",
371371
maps[i].name,
372372
maps[i].function);
@@ -721,20 +721,12 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
721721
/*
722722
* First, try to find the pctldev given in the map
723723
*/
724-
pctldev = get_pinctrl_dev_from_dev(map->ctrl_dev,
725-
map->ctrl_dev_name);
724+
pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name);
726725
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-
734726
pr_warning("could not find a pinctrl device for pinmux function %s, fishy, they shall all have one\n",
735727
map->function);
736728
pr_warning("given pinctrl device name: %s",
737-
devname ? devname : "UNDEFINED");
729+
map->ctrl_dev_name);
738730

739731
/* Continue to check the other mappings anyway... */
740732
continue;
@@ -925,7 +917,7 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
925917
struct pinmux *pmx;
926918
int ret;
927919

928-
if (map->dev || map->dev_name) {
920+
if (map->dev_name) {
929921
/*
930922
* TODO: the day we have device tree support, we can
931923
* traverse the device tree and hog to specific device nodes
@@ -996,9 +988,8 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
996988
if (!map->hog_on_boot)
997989
continue;
998990

999-
if ((map->ctrl_dev == dev) ||
1000-
(map->ctrl_dev_name &&
1001-
!strcmp(map->ctrl_dev_name, devname))) {
991+
if (map->ctrl_dev_name &&
992+
!strcmp(map->ctrl_dev_name, devname)) {
1002993
/* OK time to hog! */
1003994
ret = pinmux_hog_map(pctldev, map);
1004995
if (ret)
@@ -1156,14 +1147,12 @@ static int pinmux_maps_show(struct seq_file *s, void *what)
11561147
struct pinmux_map const *map = &pinmux_maps[i];
11571148

11581149
seq_printf(s, "%s:\n", map->name);
1159-
if (map->dev || map->dev_name)
1150+
if (map->dev_name)
11601151
seq_printf(s, " device: %s\n",
1161-
map->dev ? dev_name(map->dev) :
11621152
map->dev_name);
11631153
else
11641154
seq_printf(s, " SYSTEM MUX\n");
11651155
seq_printf(s, " controlling device %s\n",
1166-
map->ctrl_dev ? dev_name(map->ctrl_dev) :
11671156
map->ctrl_dev_name);
11681157
seq_printf(s, " function: %s\n", map->function);
11691158
seq_printf(s, " group: %s\n", map->group ? map->group :

‎include/linux/pinctrl/machine.h‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@
1717
* @name: the name of this specific map entry for the particular machine.
1818
* This is the second parameter passed to pinmux_get() when you want
1919
* 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)
2220
* @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
24-
* you provide .ctrl_dev instead
21+
* the name must be the same as in your struct device*
2522
* @function: a function in the driver to use for this mapping, the driver
2623
* will lookup the function referenced by this ID on the specified
2724
* pin control device
2825
* @group: sometimes a function can map to different pin groups, so this
2926
* selects a certain specific pin group to activate for the function, if
3027
* 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)
3328
* @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
35-
* provide .dev instead
29+
* must be the same as in your struct device*
3630
* @hog_on_boot: if this is set to true, the pin control subsystem will itself
3731
* hog the mappings as the pinmux device drivers are attached, so this is
3832
* typically used with system maps (mux mappings without an assigned
@@ -42,11 +36,9 @@
4236
*/
4337
struct pinmux_map {
4438
const char *name;
45-
struct device *ctrl_dev;
4639
const char *ctrl_dev_name;
4740
const char *function;
4841
const char *group;
49-
struct device *dev;
5042
const char *dev_name;
5143
bool hog_on_boot;
5244
};

0 commit comments

Comments
 (0)