Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e2a2880 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Here are some fixes to the pin control system that has accumulated since
-rc1.  Mainly Tony Lindgren fixed the module load/unload logic and the
rest are minor fixes and documentation.

* 'for-torvalds' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
  pinctrl: add checks for empty function names
  pinctrl: fix pinmux_hog_maps when ctrl_dev_name is not set
  pinctrl: fix some pinmux typos
  pinctrl: free debugfs entries when unloading a pinmux driver
  pinctrl: unbreak error messages
  Documentation/pinctrl: fix a few syntax errors in code examples
  pinctrl: fix pinconf_pins_show iteration
parents 27ba234c b9130b77
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -857,42 +857,41 @@ case), we define a mapping like this:

...
{
	.name "2bit"
	.name = "2bit"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "mmc0",
	.group = "mmc0_1_grp",
	.dev_name = "foo-mmc.0",
},
{
	.name "4bit"
	.name = "4bit"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "mmc0",
	.group = "mmc0_1_grp",
	.dev_name = "foo-mmc.0",
},
{
	.name "4bit"
	.name = "4bit"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "mmc0",
	.group = "mmc0_2_grp",
	.dev_name = "foo-mmc.0",
},
{
	.name "8bit"
	.name = "8bit"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "mmc0",
	.group = "mmc0_1_grp",
	.dev_name = "foo-mmc.0",
},
{
	.name "8bit"
	.name = "8bit"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "mmc0",
	.group = "mmc0_2_grp",
	.dev_name = "foo-mmc.0",
},
{
	.name "8bit"
	.name = "8bit"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "mmc0",
	.group = "mmc0_3_grp",
@@ -995,7 +994,7 @@ This is enabled by simply setting the .hog_on_boot field in the map to true,
like this:

{
	.name "POWERMAP"
	.name = "POWERMAP"
	.ctrl_dev_name = "pinctrl-foo",
	.function = "power_func",
	.hog_on_boot = true,
@@ -1025,7 +1024,7 @@ it, disables and releases it, and muxes it in on the pins defined by group B:

foo_switch()
{
	struct pinmux pmx;
	struct pinmux *pmx;

	/* Enable on position A */
	pmx = pinmux_get(&device, "spi0-pos-A");
+31 −19
Original line number Diff line number Diff line
@@ -510,10 +510,12 @@ static struct dentry *debugfs_root;

static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
{
	static struct dentry *device_root;
	struct dentry *device_root;

	device_root = debugfs_create_dir(dev_name(pctldev->dev),
					 debugfs_root);
	pctldev->device_root = device_root;

	if (IS_ERR(device_root) || !device_root) {
		pr_warn("failed to create debugfs directory for %s\n",
			dev_name(pctldev->dev));
@@ -529,6 +531,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
	pinconf_init_device_debugfs(device_root, pctldev);
}

static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
{
	debugfs_remove_recursive(pctldev->device_root);
}

static void pinctrl_init_debugfs(void)
{
	debugfs_root = debugfs_create_dir("pinctrl", NULL);
@@ -553,6 +560,10 @@ static void pinctrl_init_debugfs(void)
{
}

static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
{
}

#endif

/**
@@ -572,40 +583,40 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
	if (pctldesc->name == NULL)
		return NULL;

	pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
	if (pctldev == NULL)
		return NULL;

	/* Initialize pin control device struct */
	pctldev->owner = pctldesc->owner;
	pctldev->desc = pctldesc;
	pctldev->driver_data = driver_data;
	INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
	spin_lock_init(&pctldev->pin_desc_tree_lock);
	INIT_LIST_HEAD(&pctldev->gpio_ranges);
	mutex_init(&pctldev->gpio_ranges_lock);
	pctldev->dev = dev;

	/* If we're implementing pinmuxing, check the ops for sanity */
	if (pctldesc->pmxops) {
		ret = pinmux_check_ops(pctldesc->pmxops);
		ret = pinmux_check_ops(pctldev);
		if (ret) {
			pr_err("%s pinmux ops lacks necessary functions\n",
			       pctldesc->name);
			return NULL;
			goto out_err;
		}
	}

	/* If we're implementing pinconfig, check the ops for sanity */
	if (pctldesc->confops) {
		ret = pinconf_check_ops(pctldesc->confops);
		ret = pinconf_check_ops(pctldev);
		if (ret) {
			pr_err("%s pin config ops lacks necessary functions\n",
			       pctldesc->name);
			return NULL;
			goto out_err;
		}
	}

	pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
	if (pctldev == NULL)
		return NULL;

	/* Initialize pin control device struct */
	pctldev->owner = pctldesc->owner;
	pctldev->desc = pctldesc;
	pctldev->driver_data = driver_data;
	INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
	spin_lock_init(&pctldev->pin_desc_tree_lock);
	INIT_LIST_HEAD(&pctldev->gpio_ranges);
	mutex_init(&pctldev->gpio_ranges_lock);
	pctldev->dev = dev;

	/* Register all the pins */
	pr_debug("try to register %d pins on %s...\n",
		 pctldesc->npins, pctldesc->name);
@@ -641,6 +652,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
	if (pctldev == NULL)
		return;

	pinctrl_remove_device_debugfs(pctldev);
	pinmux_unhog_maps(pctldev);
	/* TODO: check that no pinmuxes are still active? */
	mutex_lock(&pinctrldev_list_mutex);
+3 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ struct pinctrl_dev {
	struct device *dev;
	struct module *owner;
	void *driver_data;
#ifdef CONFIG_DEBUG_FS
	struct dentry *device_root;
#endif
#ifdef CONFIG_PINMUX
	struct mutex pinmux_hogs_lock;
	struct list_head pinmux_hogs;
+4 −2
Original line number Diff line number Diff line
@@ -205,8 +205,10 @@ int pin_config_group_set(const char *dev_name, const char *pin_group,
}
EXPORT_SYMBOL(pin_config_group_set);

int pinconf_check_ops(const struct pinconf_ops *ops)
int pinconf_check_ops(struct pinctrl_dev *pctldev)
{
	const struct pinconf_ops *ops = pctldev->desc->confops;

	/* We must be able to read out pin status */
	if (!ops->pin_config_get && !ops->pin_config_group_get)
		return -EINVAL;
@@ -236,7 +238,7 @@ static int pinconf_pins_show(struct seq_file *s, void *what)
	seq_puts(s, "Format: pin (name): pinmux setting array\n");

	/* The pin number can be retrived from the pin controller descriptor */
	for (i = 0; pin < pctldev->desc->npins; i++) {
	for (i = 0; i < pctldev->desc->npins; i++) {
		struct pin_desc *desc;

		pin = pctldev->desc->pins[i].number;
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@

#ifdef CONFIG_PINCONF

int pinconf_check_ops(const struct pinconf_ops *ops);
int pinconf_check_ops(struct pinctrl_dev *pctldev);
void pinconf_init_device_debugfs(struct dentry *devroot,
				 struct pinctrl_dev *pctldev);
int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
@@ -23,7 +23,7 @@ int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin,

#else

static inline int pinconf_check_ops(const struct pinconf_ops *ops)
static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
{
	return 0;
}
Loading