void pinconf_generic_dump_pin(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned pin) { const struct pinconf_ops *ops = pctldev->desc->confops; int i; if (!ops->is_generic) return; for(i = 0; i < ARRAY_SIZE(conf_items); i++) { unsigned long config; int ret; /* We want to check out this parameter */ config = pinconf_to_config_packed(conf_items[i].param, 0); ret = pin_config_get_for_pin(pctldev, pin, &config); /* These are legal errors */ if (ret == -EINVAL || ret == -ENOTSUPP) continue; if (ret) { seq_printf(s, "ERROR READING CONFIG SETTING %d ", i); continue; } /* Space between multiple configs */ seq_puts(s, " "); seq_puts(s, conf_items[i].display); /* Print unit if available */ if (conf_items[i].format && pinconf_to_config_argument(config) != 0) seq_printf(s, " (%u %s)", pinconf_to_config_argument(config), conf_items[i].format); } }
/** * pin_config_get() - get the configuration of a single pin parameter * @dev_name: name of the pin controller device for this pin * @name: name of the pin to get the config for * @config: the config pointed to by this argument will be filled in with the * current pin state, it can be used directly by drivers as a numeral, or * it can be dereferenced to any struct. */ int pin_config_get(const char *dev_name, const char *name, unsigned long *config) { struct pinctrl_dev *pctldev; int pin; pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); if (!pctldev) return -EINVAL; pin = pin_get_from_name(pctldev, name); if (pin < 0) return pin; return pin_config_get_for_pin(pctldev, pin, config); }
static void pinconf_generic_dump_one(struct pinctrl_dev *pctldev, struct seq_file *s, const char *gname, unsigned pin, const struct pin_config_item *items, int nitems, int *print_sep) { int i; for (i = 0; i < nitems; i++) { unsigned long config; int ret; /* We want to check out this parameter */ config = pinconf_to_config_packed(items[i].param, 0); if (gname) ret = pin_config_group_get(dev_name(pctldev->dev), gname, &config); else ret = pin_config_get_for_pin(pctldev, pin, &config); /* These are legal errors */ if (ret == -EINVAL || ret == -ENOTSUPP) continue; if (ret) { seq_printf(s, "ERROR READING CONFIG SETTING %d ", i); continue; } /* comma between multiple configs */ if (*print_sep) seq_puts(s, ", "); *print_sep = 1; seq_puts(s, items[i].display); /* Print unit if available */ if (items[i].has_arg) { seq_printf(s, " (%u", pinconf_to_config_argument(config)); if (items[i].format) seq_printf(s, " %s)", items[i].format); else seq_puts(s, ")"); } } }
/** * pin_config_get() - get the configuration of a single pin parameter * @dev_name: name of the pin controller device for this pin * @name: name of the pin to get the config for * @config: the config pointed to by this argument will be filled in with the * current pin state, it can be used directly by drivers as a numeral, or * it can be dereferenced to any struct. */ int pin_config_get(const char *dev_name, const char *name, unsigned long *config) { struct pinctrl_dev *pctldev; int pin; mutex_lock(&pinctrl_mutex); pctldev = get_pinctrl_dev_from_devname(dev_name); if (!pctldev) { pin = -EINVAL; goto unlock; } pin = pin_get_from_name(pctldev, name); if (pin < 0) goto unlock; pin = pin_config_get_for_pin(pctldev, pin, config); unlock: mutex_unlock(&pinctrl_mutex); return pin; }