pinctrl: pinconf: Fix display of configs

The function pinconf_dbg_config_print() only prints the configuration of
the 1st pin config in an array of pin configurations. Fix this so that
all pin configurations in the array are displayed.

There are a few places in the code where the pin configs are displayed
and so add a helper function to display the pin configs to simplify the
code.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Jon Hunter 2015-07-14 11:17:59 +01:00 committed by Linus Walleij
parent 7562998106
commit d96310aedd

View File

@ -202,18 +202,34 @@ int pinconf_apply_setting(struct pinctrl_setting const *setting)
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map) void pinconf_show_config(struct seq_file *s, struct pinctrl_dev *pctldev,
unsigned long *configs, unsigned num_configs)
{ {
struct pinctrl_dev *pctldev;
const struct pinconf_ops *confops; const struct pinconf_ops *confops;
int i; int i;
pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name);
if (pctldev) if (pctldev)
confops = pctldev->desc->confops; confops = pctldev->desc->confops;
else else
confops = NULL; confops = NULL;
for (i = 0; i < num_configs; i++) {
seq_puts(s, "config ");
if (confops && confops->pin_config_config_dbg_show)
confops->pin_config_config_dbg_show(pctldev, s,
configs[i]);
else
seq_printf(s, "%08lx", configs[i]);
seq_puts(s, "\n");
}
}
void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map)
{
struct pinctrl_dev *pctldev;
pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name);
switch (map->type) { switch (map->type) {
case PIN_MAP_TYPE_CONFIGS_PIN: case PIN_MAP_TYPE_CONFIGS_PIN:
seq_printf(s, "pin "); seq_printf(s, "pin ");
@ -227,15 +243,8 @@ void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map)
seq_printf(s, "%s\n", map->data.configs.group_or_pin); seq_printf(s, "%s\n", map->data.configs.group_or_pin);
for (i = 0; i < map->data.configs.num_configs; i++) { pinconf_show_config(s, pctldev, map->data.configs.configs,
seq_printf(s, "config "); map->data.configs.num_configs);
if (confops && confops->pin_config_config_dbg_show)
confops->pin_config_config_dbg_show(pctldev, s,
map->data.configs.configs[i]);
else
seq_printf(s, "%08lx", map->data.configs.configs[i]);
seq_printf(s, "\n");
}
} }
void pinconf_show_setting(struct seq_file *s, void pinconf_show_setting(struct seq_file *s,
@ -243,9 +252,7 @@ void pinconf_show_setting(struct seq_file *s,
{ {
struct pinctrl_dev *pctldev = setting->pctldev; struct pinctrl_dev *pctldev = setting->pctldev;
const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
const struct pinconf_ops *confops = pctldev->desc->confops;
struct pin_desc *desc; struct pin_desc *desc;
int i;
switch (setting->type) { switch (setting->type) {
case PIN_MAP_TYPE_CONFIGS_PIN: case PIN_MAP_TYPE_CONFIGS_PIN:
@ -269,17 +276,8 @@ void pinconf_show_setting(struct seq_file *s,
* FIXME: We should really get the pin controler to dump the config * FIXME: We should really get the pin controler to dump the config
* values, so they can be decoded to something meaningful. * values, so they can be decoded to something meaningful.
*/ */
for (i = 0; i < setting->data.configs.num_configs; i++) { pinconf_show_config(s, pctldev, setting->data.configs.configs,
seq_printf(s, " "); setting->data.configs.num_configs);
if (confops && confops->pin_config_config_dbg_show)
confops->pin_config_config_dbg_show(pctldev, s,
setting->data.configs.configs[i]);
else
seq_printf(s, "%08lx",
setting->data.configs.configs[i]);
}
seq_printf(s, "\n");
} }
static void pinconf_dump_pin(struct pinctrl_dev *pctldev, static void pinconf_dump_pin(struct pinctrl_dev *pctldev,
@ -412,10 +410,8 @@ static int pinconf_dbg_config_print(struct seq_file *s, void *d)
const struct pinctrl_map *map; const struct pinctrl_map *map;
const struct pinctrl_map *found = NULL; const struct pinctrl_map *found = NULL;
struct pinctrl_dev *pctldev; struct pinctrl_dev *pctldev;
const struct pinconf_ops *confops = NULL;
struct dbg_cfg *dbg = &pinconf_dbg_conf; struct dbg_cfg *dbg = &pinconf_dbg_conf;
int i, j; int i, j;
unsigned long config;
mutex_lock(&pinctrl_maps_mutex); mutex_lock(&pinctrl_maps_mutex);
@ -449,16 +445,10 @@ static int pinconf_dbg_config_print(struct seq_file *s, void *d)
} }
pctldev = get_pinctrl_dev_from_devname(found->ctrl_dev_name); pctldev = get_pinctrl_dev_from_devname(found->ctrl_dev_name);
config = *found->data.configs.configs; seq_printf(s, "Dev %s has config of %s in state %s:\n",
seq_printf(s, "Dev %s has config of %s in state %s: 0x%08lX\n", dbg->dev_name, dbg->pin_name, dbg->state_name);
dbg->dev_name, dbg->pin_name, pinconf_show_config(s, pctldev, found->data.configs.configs,
dbg->state_name, config); found->data.configs.num_configs);
if (pctldev)
confops = pctldev->desc->confops;
if (confops && confops->pin_config_config_dbg_show)
confops->pin_config_config_dbg_show(pctldev, s, config);
exit: exit:
mutex_unlock(&pinctrl_maps_mutex); mutex_unlock(&pinctrl_maps_mutex);