forked from luck/tmp_suning_uos_patched
pinctrl: disallow map table entries with NULL dev_name field
Hog entries are mapping table entries with .ctrl_dev_name == .dev_name. All other mapping table entries need .dev_name set so that they will match some pinctrl_get() call. All extant PIN_MAP*() macros set .dev_name. So, there is no reason to allow mapping table entries without .dev_name set. Update the code and documentation to disallow this. 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>
This commit is contained in:
parent
f7b9006f45
commit
1681f5ae4c
|
@ -494,14 +494,10 @@ Definitions:
|
|||
{"map-i2c0", i2c0, pinctrl0, fi2c0, gi2c0}
|
||||
}
|
||||
|
||||
Every map must be assigned a symbolic name, pin controller and function.
|
||||
The group is not compulsory - if it is omitted the first group presented by
|
||||
the driver as applicable for the function will be selected, which is
|
||||
useful for simple cases.
|
||||
|
||||
The device name is present in map entries tied to specific devices. Maps
|
||||
without device names are referred to as SYSTEM pinmuxes, such as can be taken
|
||||
by the machine implementation on boot and not tied to any specific device.
|
||||
Every map must be assigned a state name, pin controller, device and
|
||||
function. The group is not compulsory - if it is omitted the first group
|
||||
presented by the driver as applicable for the function will be selected,
|
||||
which is useful for simple cases.
|
||||
|
||||
It is possible to map several groups to the same combination of device,
|
||||
pin controller and function. This is for cases where a certain function on
|
||||
|
@ -983,8 +979,7 @@ after this you should be able to see this in the debugfs listing of all pins.
|
|||
System pin control hogging
|
||||
==========================
|
||||
|
||||
A system pin control map entry, i.e. a pin control setting that does not have
|
||||
a device associated with it, can be hogged by the core when the pin controller
|
||||
Pin control map entries can be hogged by the core when the pin controller
|
||||
is registered. This means that the core will attempt to call pinctrl_get() and
|
||||
pinctrl_enable() on it immediately after the pin control device has been
|
||||
registered.
|
||||
|
|
|
@ -479,24 +479,21 @@ EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output);
|
|||
static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
|
||||
{
|
||||
struct pinctrl_dev *pctldev = NULL;
|
||||
const char *devname = NULL;
|
||||
const char *devname;
|
||||
struct pinctrl *p;
|
||||
bool found_map;
|
||||
unsigned num_maps = 0;
|
||||
int ret = -ENODEV;
|
||||
struct pinctrl_maps *maps_node;
|
||||
int i;
|
||||
struct pinctrl_map const *map;
|
||||
|
||||
/* We must have dev or ID or both */
|
||||
if (!dev && !name)
|
||||
/* We must have a dev name */
|
||||
if (WARN_ON(!dev))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
if (dev)
|
||||
devname = dev_name(dev);
|
||||
devname = dev_name(dev);
|
||||
|
||||
pr_debug("get pin control handle %s for device %s\n", name,
|
||||
devname ? devname : "(none)");
|
||||
pr_debug("get pin control handle device %s state %s\n", devname, name);
|
||||
|
||||
/*
|
||||
* create the state cookie holder struct pinctrl for each
|
||||
|
@ -511,8 +508,6 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
|
|||
|
||||
/* Iterate over the pin control maps to locate the right ones */
|
||||
for_each_maps(maps_node, i, map) {
|
||||
found_map = false;
|
||||
|
||||
/*
|
||||
* First, try to find the pctldev given in the map
|
||||
*/
|
||||
|
@ -529,6 +524,10 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
|
|||
pr_debug("in map, found pctldev %s to handle function %s",
|
||||
dev_name(pctldev->dev), map->function);
|
||||
|
||||
/* Map must be for this device */
|
||||
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.
|
||||
|
@ -540,30 +539,12 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
|
|||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is for the case where no device name is given, we
|
||||
* already know that the function name matches from above
|
||||
* code.
|
||||
*/
|
||||
if (!map->dev_name && (name != NULL))
|
||||
found_map = true;
|
||||
|
||||
/* If the mapping has a device set up it must match */
|
||||
if (map->dev_name &&
|
||||
(!devname || !strcmp(map->dev_name, devname)))
|
||||
/* MATCH! */
|
||||
found_map = true;
|
||||
|
||||
/* If this map is applicable, then apply it */
|
||||
if (found_map) {
|
||||
ret = pinmux_apply_muxmap(pctldev, p, dev,
|
||||
devname, map);
|
||||
if (ret) {
|
||||
kfree(p);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
num_maps++;
|
||||
ret = pinmux_apply_muxmap(pctldev, p, dev, devname, map);
|
||||
if (ret) {
|
||||
kfree(p);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
num_maps++;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -578,9 +559,7 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
|
|||
dev_info(dev, "zero maps found for mapping %s\n", name);
|
||||
|
||||
pr_debug("found %u mux maps for device %s, UD %s\n",
|
||||
num_maps,
|
||||
devname ? devname : "(anonymous)",
|
||||
name ? name : "(undefined)");
|
||||
num_maps, devname, name ? name : "(undefined)");
|
||||
|
||||
/* Add the pinmux to the global list */
|
||||
mutex_lock(&pinctrl_list_mutex);
|
||||
|
@ -707,14 +686,11 @@ int pinctrl_register_mappings(struct pinctrl_map const *maps,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!maps[i].dev_name)
|
||||
pr_debug("add system map %s function %s with no device\n",
|
||||
maps[i].name,
|
||||
maps[i].function);
|
||||
else
|
||||
pr_debug("register map %s, function %s\n",
|
||||
maps[i].name,
|
||||
maps[i].function);
|
||||
if (!maps[i].dev_name) {
|
||||
pr_err("failed to register map %s (%d): no device given\n",
|
||||
maps[i].name, i);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
maps_node = kzalloc(sizeof(*maps_node), GFP_KERNEL);
|
||||
|
@ -938,13 +914,8 @@ static int pinctrl_maps_show(struct seq_file *s, void *what)
|
|||
mutex_lock(&pinctrl_maps_mutex);
|
||||
for_each_maps(maps_node, i, map) {
|
||||
seq_printf(s, "%s:\n", map->name);
|
||||
if (map->dev_name)
|
||||
seq_printf(s, " device: %s\n",
|
||||
map->dev_name);
|
||||
else
|
||||
seq_printf(s, " SYSTEM MUX\n");
|
||||
seq_printf(s, " controlling device %s\n",
|
||||
map->ctrl_dev_name);
|
||||
seq_printf(s, " device: %s\n", map->dev_name);
|
||||
seq_printf(s, " controlling device %s\n", map->ctrl_dev_name);
|
||||
seq_printf(s, " function: %s\n", map->function);
|
||||
seq_printf(s, " group: %s\n", map->group ? map->group :
|
||||
"(default)");
|
||||
|
|
|
@ -45,13 +45,6 @@ struct pinctrl_map {
|
|||
#define PIN_MAP(a, b, c, d) \
|
||||
{ .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
|
||||
|
||||
/*
|
||||
* Convenience macro to map a system function onto a certain pinctrl device.
|
||||
* System functions are not assigned to a particular device.
|
||||
*/
|
||||
#define PIN_MAP_SYS(a, b, c) \
|
||||
{ .name = a, .ctrl_dev_name = b, .function = c }
|
||||
|
||||
/*
|
||||
* Convenience macro to map a system function onto a certain pinctrl device,
|
||||
* to be hogged by the pin control core until the system shuts down.
|
||||
|
|
Loading…
Reference in New Issue
Block a user