diff options
Diffstat (limited to 'drivers/pinctrl/core.c')
| -rw-r--r-- | drivers/pinctrl/core.c | 53 | 
1 files changed, 39 insertions, 14 deletions
| diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 7d3370289938..a4ac87c8b4f8 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -160,7 +160,7 @@ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name)  }  /** - * pin_get_name_from_id() - look up a pin name from a pin id + * pin_get_name() - look up a pin name from a pin id   * @pctldev: the pin control device to lookup the pin on   * @pin: pin number/id to look up   */ @@ -1258,7 +1258,7 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)  	p->state = NULL; -	/* Apply all the settings for the new state */ +	/* Apply all the settings for the new state - pinmux first */  	list_for_each_entry(setting, &state->settings, node) {  		switch (setting->type) {  		case PIN_MAP_TYPE_MUX_GROUP: @@ -1266,6 +1266,29 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)  			break;  		case PIN_MAP_TYPE_CONFIGS_PIN:  		case PIN_MAP_TYPE_CONFIGS_GROUP: +			ret = 0; +			break; +		default: +			ret = -EINVAL; +			break; +		} + +		if (ret < 0) +			goto unapply_new_state; + +		/* Do not link hogs (circular dependency) */ +		if (p != setting->pctldev->p) +			pinctrl_link_add(setting->pctldev, p->dev); +	} + +	/* Apply all the settings for the new state - pinconf after */ +	list_for_each_entry(setting, &state->settings, node) { +		switch (setting->type) { +		case PIN_MAP_TYPE_MUX_GROUP: +			ret = 0; +			break; +		case PIN_MAP_TYPE_CONFIGS_PIN: +		case PIN_MAP_TYPE_CONFIGS_GROUP:  			ret = pinconf_apply_setting(setting);  			break;  		default: @@ -1604,8 +1627,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)  	unsigned i, pin;  #ifdef CONFIG_GPIOLIB  	struct pinctrl_gpio_range *range; -	unsigned int gpio_num;  	struct gpio_chip *chip; +	int gpio_num;  #endif  	seq_printf(s, "registered pins: %d\n", pctldev->desc->npins); @@ -1625,7 +1648,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)  		seq_printf(s, "pin %d (%s) ", pin, desc->name);  #ifdef CONFIG_GPIOLIB -		gpio_num = 0; +		gpio_num = -1;  		list_for_each_entry(range, &pctldev->gpio_ranges, node) {  			if ((pin >= range->pin_base) &&  			    (pin < (range->pin_base + range->npins))) { @@ -1633,10 +1656,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)  				break;  			}  		} -		chip = gpio_to_chip(gpio_num); -		if (chip && chip->gpiodev && chip->gpiodev->base) -			seq_printf(s, "%u:%s ", gpio_num - -				chip->gpiodev->base, chip->label); +		if (gpio_num >= 0) +			chip = gpio_to_chip(gpio_num); +		else +			chip = NULL; +		if (chip) +			seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label);  		else  			seq_puts(s, "0:? ");  #endif @@ -1890,11 +1915,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)  			dev_name(pctldev->dev));  		return;  	} -	debugfs_create_file("pins", S_IFREG | S_IRUGO, +	debugfs_create_file("pins", 0444,  			    device_root, pctldev, &pinctrl_pins_fops); -	debugfs_create_file("pingroups", S_IFREG | S_IRUGO, +	debugfs_create_file("pingroups", 0444,  			    device_root, pctldev, &pinctrl_groups_fops); -	debugfs_create_file("gpio-ranges", S_IFREG | S_IRUGO, +	debugfs_create_file("gpio-ranges", 0444,  			    device_root, pctldev, &pinctrl_gpioranges_fops);  	if (pctldev->desc->pmxops)  		pinmux_init_device_debugfs(device_root, pctldev); @@ -1916,11 +1941,11 @@ static void pinctrl_init_debugfs(void)  		return;  	} -	debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, +	debugfs_create_file("pinctrl-devices", 0444,  			    debugfs_root, NULL, &pinctrl_devices_fops); -	debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO, +	debugfs_create_file("pinctrl-maps", 0444,  			    debugfs_root, NULL, &pinctrl_maps_fops); -	debugfs_create_file("pinctrl-handles", S_IFREG | S_IRUGO, +	debugfs_create_file("pinctrl-handles", 0444,  			    debugfs_root, NULL, &pinctrl_fops);  } | 
