pinctrl: Introduce PINCTRL_STATE_DEFAULT define, and use it
Subsystems (4)
PATCH 1/3 pinctrl: Introduce PINCTRL_STATE_DEFAULT define, and use it
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
Update documentation and mapping tables to use this.
---
These 3 patches are small cleanup/fixes triggered by review comments from the 20-long series I posted a few days ago.
These patches are based on the 4-long series that I posted yesterday.
Documentation/pinctrl.txt | 8 ++++---- arch/arm/mach-u300/core.c | 6 +++--- include/linux/pinctrl/machine.h | 13 ++++++++----- include/linux/pinctrl/pinctrl.h | 2 ++ 4 files changed, 17 insertions(+), 12 deletions(-)
Documentation/pinctrl.txt +4 -4
@@ -814,7 +814,7 @@ it even more compact which assumes you want to use pinctrl-foo and position 0 for mapping, for example: static struct pinctrl_map __initdata mapping[] = { - PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), + PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-foo", "i2c0", "foo-i2c.0"), };
@@ -930,7 +930,7 @@ foo_probe() /* Allocate a state holder named "state" etc */ struct pinctrl p; - p = pinctrl_get(&device, NULL); + p = pinctrl_get(&device, PINCTRL_STATE_DEFAULT); if IS_ERR(p) return PTR_ERR(p); pinctrl_enable(p);
@@ -988,7 +988,7 @@ This is enabled by simply setting the .dev_name field in the map to the name of the pin controller itself, like this: { - .name = "POWERMAP" + .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = "pinctrl-foo", .function = "power_func", .dev_name = "pinctrl-foo",
@@ -998,7 +998,7 @@ Since it may be common to request the core to hog a few always-applicable mux settings on the primary pin controller, there is a convenience macro for this: -PIN_MAP_PRIMARY_SYS_HOG("POWERMAP", "pinctrl-foo", "power_func") +PIN_MAP_SYS_HOG("pinctrl-foo", "power_func") This gives the exact same result as the above construction.
arch/arm/mach-u300/core.c +3 -3
@@ -1554,9 +1554,9 @@ static struct platform_device pinmux_device = {/* Pinmux settings */ static struct pinctrl_map __initdata u300_pinmux_map[] = {/* anonymous maps for chip power and EMIFs */ -PIN_MAP_SYS_HOG ("POWER" ,"pinmux-u300" ,"power" ), -PIN_MAP_SYS_HOG ("EMIF0" ,"pinmux-u300" ,"emif0" ), -PIN_MAP_SYS_HOG ("EMIF1" ,"pinmux-u300" ,"emif1" ), +PIN_MAP_SYS_HOG ("pinmux-u300" ,"power" ), +PIN_MAP_SYS_HOG ("pinmux-u300" ,"emif0" ), +PIN_MAP_SYS_HOG ("pinmux-u300" ,"emif1" ),/* per-device maps for MMC/SD, SPI and UART */ PIN_MAP ("MMCSD" ,"pinmux-u300" ,"mmc0" ,"mmci" ),PIN_MAP ("SPI" ,"pinmux-u300" ,"spi0" ,"pl022" ),
include/linux/pinctrl/machine.h +8 -5
@@ -12,6 +12,8 @@#ifndef __LINUX_PINCTRL_MACHINE_H#define __LINUX_PINCTRL_MACHINE_H +#include "pinctrl.h" +/** * struct pinctrl_map - boards/machines shall provide this map for devices * @name: the name of this specific map entry for the particular machine.
@@ -49,17 +51,18 @@ struct pinctrl_map {* 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. */ -#define PIN_MAP_SYS_HOG (a, b, c) \ - { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, } +#define PIN_MAP_SYS_HOG (a, b) \ + { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ + .function = b, }/* * Convenience macro to map a system function onto a certain pinctrl device * using a specified group, to be hogged by the pin control core until the * system shuts down. */ -#define PIN_MAP_SYS_HOG_GROUP (a, b, c, d) \ - { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, \ - .group = d, } +#define PIN_MAP_SYS_HOG_GROUP (a, b, c) \ + { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ + .function = b, .group = c, }#ifdef CONFIG_PINMUX
include/linux/pinctrl/pinctrl.h +2 -0
@@ -19,6 +19,8 @@#include <linux/list.h> #include <linux/seq_file.h> +#define PINCTRL_STATE_DEFAULT "default" +struct pinctrl_dev ;struct pinmux_ops ;struct pinconf_ops ;
Signature · 1 line
1.7.0.4
PATCH 2/3 pinctrl: Re-order struct pinctrl_map
The lookup key in struct pinctrl_map is (.dev_name, .name). Re-order the struct definition to put the lookup key fields first, and the result values afterwards. To me at least, this slightly better reflects the lookup process.
Update the documentation in a similar fashion.
Note: PIN_MAP*() macros aren't updated; I plan to update this once later when enhancing the mapping table format to support pin config to reduce churn.
--- Documentation/pinctrl.txt | 24 ++++++++++++------------ include/linux/pinctrl/machine.h | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-)
Documentation/pinctrl.txt +12 -12
@@ -781,19 +781,19 @@ spi on the second function mapping: static const struct pinctrl_map __initdata mapping[] = { { + .dev_name = "foo-spi.0", .ctrl_dev_name = "pinctrl-foo", .function = "spi0", - .dev_name = "foo-spi.0", }, { + .dev_name = "foo-i2c.0", .ctrl_dev_name = "pinctrl-foo", .function = "i2c0", - .dev_name = "foo-i2c.0", }, { + .dev_name = "foo-mmc.0", .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", - .dev_name = "foo-mmc.0", }, };
@@ -826,18 +826,18 @@ As it is possible to map a function to different groups of pins an optional ... { + .dev_name = "foo-spi.0", .name = "spi0-pos-A", .ctrl_dev_name = "pinctrl-foo", .function = "spi0", .group = "spi0_0_grp", - .dev_name = "foo-spi.0", }, { + .dev_name = "foo-spi.0", .name = "spi0-pos-B", .ctrl_dev_name = "pinctrl-foo", .function = "spi0", .group = "spi0_1_grp", - .dev_name = "foo-spi.0", }, ...
@@ -852,45 +852,45 @@ case), we define a mapping like this: ... { + .dev_name = "foo-mmc.0", .name = "2bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_1_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "4bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_1_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "4bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_2_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "8bit" .ctrl_dev_name = "pinctrl-foo", .group = "mmc0_1_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "8bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_2_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "8bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_3_grp", - .dev_name = "foo-mmc.0", }, ...
@@ -988,10 +988,10 @@ This is enabled by simply setting the .dev_name field in the map to the name of the pin controller itself, like this: { + .dev_name = "pinctrl-foo", .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = "pinctrl-foo", .function = "power_func", - .dev_name = "pinctrl-foo", }, Since it may be common to request the core to hog a few always-applicable
include/linux/pinctrl/machine.h +5 -5
@@ -16,6 +16,10 @@/** * struct pinctrl_map - boards/machines shall provide this map for devices +* @dev_name: the name of the device using this specific mapping, the name +* must be the same as in your struct device*. If this name is set to the +* same name as the pin controllers own dev_name(), the map entry will be +* hogged by the driver itself upon registration * @name: the name of this specific map entry for the particular machine. * This is the second parameter passed to pinmux_get() when you want * to have several mappings to the same device
@@ -27,17 +31,13 @@* @group: sometimes a function can map to different pin groups, so this * selects a certain specific pin group to activate for the function, if * left as NULL, the first applicable group will be used -* @dev_name: the name of the device using this specific mapping, the name -* must be the same as in your struct device*. If this name is set to the -* same name as the pin controllers own dev_name(), the map entry will be -* hogged by the driver itself upon registration */ struct pinctrl_map { +const char *dev_name;const char *name;const char *ctrl_dev_name;const char *function;const char *group; -const char *dev_name; };/*
Signature · 1 line
1.7.0.4
Re: [PATCH 2/3] pinctrl: Re-order struct pinctrl_map
Quoted 5 lines · Stephen Warren
The lookup key in struct
pinctrl_mapis (.dev_name, .name). Re-order the struct definition to put the lookup key fields first, and the result values afterwards. To me at least, this slightly better reflects the lookup process.
Not only better reflects the llokup process, i think the map name meaning is a litlle different as before since it represents states now rather than a map name, right?
And a map entry becomes a specific device's map entry, here the device becomes the main entity, so it's reasonable to me to put it in the first.
Regards
Dong Aisheng
Quoted 162 lines
Update the documentation in a similar fashion.
Note: PIN_MAP*() macros aren't updated; I plan to update this once later when enhancing the mapping table format to support pin config to reduce churn.
Signed-off-by Stephen Warren <[email protected]>--- Documentation/pinctrl.txt | 24 ++++++++++++------------ include/linux/pinctrl/machine.h | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-)Documentation/pinctrl.txt +12
-12@@ -781,19 +781,19 @@ spi on the second function mapping: static const struct pinctrl_map __initdata mapping[] = { { + .dev_name = "foo-spi.0", .ctrl_dev_name = "pinctrl-foo", .function = "spi0", - .dev_name = "foo-spi.0", }, { + .dev_name = "foo-i2c.0", .ctrl_dev_name = "pinctrl-foo", .function = "i2c0", - .dev_name = "foo-i2c.0", }, { + .dev_name = "foo-mmc.0", .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", - .dev_name = "foo-mmc.0", }, };@@ -826,18 +826,18 @@ As it is possible to map a function to different groups of pins an optional { + .dev_name = "foo-spi.0", .name = "spi0-pos-A", .ctrl_dev_name = "pinctrl-foo", .function = "spi0", .group = "spi0_0_grp", - .dev_name = "foo-spi.0", }, { + .dev_name = "foo-spi.0", .name = "spi0-pos-B", .ctrl_dev_name = "pinctrl-foo", .function = "spi0", .group = "spi0_1_grp", - .dev_name = "foo-spi.0", },@@ -852,45 +852,45 @@ case), we define a mapping like this: { + .dev_name = "foo-mmc.0", .name = "2bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_1_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "4bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_1_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "4bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_2_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "8bit" .ctrl_dev_name = "pinctrl-foo", .group = "mmc0_1_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "8bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_2_grp", - .dev_name = "foo-mmc.0", }, { + .dev_name = "foo-mmc.0", .name = "8bit" .ctrl_dev_name = "pinctrl-foo", .function = "mmc0", .group = "mmc0_3_grp", - .dev_name = "foo-mmc.0", },@@ -988,10 +988,10 @@ This is enabled by simply setting the .dev_name field in the map to the name of the pin controller itself, like this: { + .dev_name = "pinctrl-foo", .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = "pinctrl-foo", .function = "power_func", - .dev_name = "pinctrl-foo", }, Since it may be common to request the core to hog a few always-applicableinclude/linux/pinctrl/machine.h +5
-5@@ -16,6 +16,10 @@/** * struct pinctrl_map - boards/machines shall provide this map for devices +* @dev_name: the name of the device using this specific mapping, the name +* must be the same as in your struct device*. If this name is set to the +* same name as the pin controllers own dev_name(), the map entry will be +* hogged by the driver itself upon registration * @name: the name of this specific map entry for the particular machine. * This is the second parameter passed to pinmux_get() when you want * to have several mappings to the same device @@ -27,17 +31,13 @@* @group: sometimes a function can map to different pin groups, so this * selects a certain specific pin group to activate for the function, if * left as NULL, the first applicable group will be used -* @dev_name: the name of the device using this specific mapping, the name -* must be the same as in your struct device*. If this name is set to the -* same name as the pin controllers own dev_name(), the map entry will be -* hogged by the driver itself upon registration */ struct pinctrl_map { +const char *dev_name;const char *name;const char *ctrl_dev_name;const char *function;const char *group; -const char *dev_name; };/* Signature · 1 line
1.7.0.4
Re: [PATCH 2/3] pinctrl: Re-order struct pinctrl_map
In reply to Stephen WarrenQuoted 5 lines · Stephen Warren
The lookup key in struct
pinctrl_mapis (.dev_name, .name). Re-order the struct definition to put the lookup key fields first, and the result values afterwards. To me at least, this slightly better reflects the lookup process.
Quoted 7 lines
Update the documentation in a similar fashion.
Note: PIN_MAP*() macros aren't updated; I plan to update this once later when enhancing the mapping table format to support pin config to reduce churn.
Signed-off-by Stephen Warren <[email protected]>
Rebased and applied with Dong's ACK.
Thanks,
Linus Walleij
PATCH 3/3 pinctrl: Move pinctrl-maps debugfs file to top-level
In reply to Stephen WarrenThe debugfs file pinctrl-maps is a system-wide file, not specific to any pin controller, so place it in the top-level directory.
Also, move the code implementing the file to keep the order of all the functions matching the order they're created in pinctrl_init_*debugfs(). The only non-obvious change here is no private data is passed to debugfs_create_file() or single_open().
--- drivers/pinctrl/core.c | 70 ++++++++++++++++++++++++------------------------ 1 files changed, 35 insertions(+), 35 deletions(-)
drivers/pinctrl/core.c +35 -35
@@ -889,28 +889,6 @@ static int pinctrl_gpioranges_show(struct seq_file *s, void *what)return 0 ; } -static int pinctrl_maps_show (struct seq_file *s,void *what) -{ -struct pinctrl_maps *maps_node; -int i; -struct pinctrl_map const *map; - -seq_puts (s,"Pinctrl maps:\n" ); - -mutex_lock (&pinctrl_maps_mutex); -for_each_maps (maps_node, i, map) { -seq_printf (s,"%s:\n" , map->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)" ); - } -mutex_unlock (&pinctrl_maps_mutex); - -return 0 ; -} -static int pinmux_hogs_show (struct seq_file *s,void *what) {struct pinctrl_dev *pctldev = s->private;
@@ -947,6 +925,28 @@ static int pinctrl_devices_show(struct seq_file *s, void *what)return 0 ; } +static int pinctrl_maps_show (struct seq_file *s,void *what) +{ +struct pinctrl_maps *maps_node; +int i; +struct pinctrl_map const *map; + +seq_puts (s,"Pinctrl maps:\n" ); + +mutex_lock (&pinctrl_maps_mutex); +for_each_maps (maps_node, i, map) { +seq_printf (s,"%s:\n" , map->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)" ); + } +mutex_unlock (&pinctrl_maps_mutex); + +return 0 ; +} +static int pinctrl_show (struct seq_file *s,void *what) {struct pinctrl *p;
@@ -988,11 +988,6 @@ static int pinctrl_gpioranges_open(struct inode *inode, struct file *file)return single_open (file, pinctrl_gpioranges_show, inode->i_private); } -static int pinctrl_maps_open (struct inode *inode,struct file *file) -{ -return single_open (file, pinctrl_maps_show, inode->i_private); -} -static int pinmux_hogs_open (struct inode *inode,struct file *file) {return single_open (file, pinmux_hogs_show, inode->i_private);
@@ -1003,6 +998,11 @@ static int pinctrl_devices_open(struct inode *inode, struct file *file)return single_open (file, pinctrl_devices_show,NULL ); } +static int pinctrl_maps_open (struct inode *inode,struct file *file) +{ +return single_open (file, pinctrl_maps_show,NULL ); +} +static int pinctrl_open (struct inode *inode,struct file *file) {return single_open (file, pinctrl_show,NULL );
@@ -1029,22 +1029,22 @@ static const struct file_operations pinctrl_gpioranges_ops = { .release = single_release, }; -static const struct file_operations pinctrl_maps_ops = { - .open = pinctrl_maps_open, +static const struct file_operations pinmux_hogs_ops = { + .open = pinmux_hogs_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; -static const struct file_operations pinmux_hogs_ops = { - .open = pinmux_hogs_open, +static const struct file_operations pinctrl_devices_ops = { + .open = pinctrl_devices_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; -static const struct file_operations pinctrl_devices_ops = { - .open = pinctrl_devices_open, +static const struct file_operations pinctrl_maps_ops = { + .open = pinctrl_maps_open, .read = seq_read, .llseek = seq_lseek, .release = single_release,
@@ -1078,8 +1078,6 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) device_root, pctldev, &pinctrl_groups_ops);debugfs_create_file ("gpio-ranges" ,S_IFREG |S_IRUGO , device_root, pctldev, &pinctrl_gpioranges_ops); -debugfs_create_file ("pinctrl-maps" ,S_IFREG |S_IRUGO , - device_root, pctldev, &pinctrl_maps_ops);debugfs_create_file ("pinmux-hogs" ,S_IFREG |S_IRUGO , device_root, pctldev, &pinmux_hogs_ops);pinmux_init_device_debugfs (device_root, pctldev);
@@ -1102,6 +1100,8 @@ static void pinctrl_init_debugfs(void)debugfs_create_file ("pinctrl-devices" ,S_IFREG |S_IRUGO , debugfs_root,NULL , &pinctrl_devices_ops); +debugfs_create_file ("pinctrl-maps" ,S_IFREG |S_IRUGO , + debugfs_root,NULL , &pinctrl_maps_ops);debugfs_create_file ("pinctrl-handles" ,S_IFREG |S_IRUGO , debugfs_root,NULL , &pinctrl_ops); }
Signature · 1 line
1.7.0.4
Re: [PATCH 3/3] pinctrl: Move pinctrl-maps debugfs file to top-level
Quoted 3 lines · Stephen Warren
The debugfs file pinctrl-maps is a system-wide file, not specific to any pin controller, so place it in the top-level directory.
Reasonable to me.
Quoted 4 lines
Also, move the code implementing the file to keep the order of all the functions matching the order they're created in pinctrl_init_*debugfs(). The only non-obvious change here is no private data is passed to
debugfs_create_file()orsingle_open().
Looks correct.
Regards
Dong Aisheng
Quoted 143 lines
Signed-off-by Stephen Warren <[email protected]>--- drivers/pinctrl/core.c | 70 ++++++++++++++++++++++++------------------------ 1 files changed, 35 insertions(+), 35 deletions(-)drivers/pinctrl/core.c +35
-35@@ -889,28 +889,6 @@ static int pinctrl_gpioranges_show(struct seq_file *s, void *what)return 0 ; } -static int pinctrl_maps_show (struct seq_file *s,void *what) -{ -struct pinctrl_maps *maps_node; -int i; -struct pinctrl_map const *map; - -seq_puts (s,"Pinctrl maps:\n" ); - -mutex_lock (&pinctrl_maps_mutex); -for_each_maps (maps_node, i, map) { -seq_printf (s,"%s:\n" , map->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)" ); - } -mutex_unlock (&pinctrl_maps_mutex); - -return 0 ; -} -static int pinmux_hogs_show (struct seq_file *s,void *what) {struct pinctrl_dev *pctldev = s->private;@@ -947,6 +925,28 @@ static int pinctrl_devices_show(struct seq_file *s, void *what)return 0 ; } +static int pinctrl_maps_show (struct seq_file *s,void *what) +{ +struct pinctrl_maps *maps_node; +int i; +struct pinctrl_map const *map; + +seq_puts (s,"Pinctrl maps:\n" ); + +mutex_lock (&pinctrl_maps_mutex); +for_each_maps (maps_node, i, map) { +seq_printf (s,"%s:\n" , map->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)" ); + } +mutex_unlock (&pinctrl_maps_mutex); + +return 0 ; +} +static int pinctrl_show (struct seq_file *s,void *what) {struct pinctrl *p;@@ -988,11 +988,6 @@ static int pinctrl_gpioranges_open(struct inode *inode, struct file *file)return single_open (file, pinctrl_gpioranges_show, inode->i_private); } -static int pinctrl_maps_open (struct inode *inode,struct file *file) -{ -return single_open (file, pinctrl_maps_show, inode->i_private); -} -static int pinmux_hogs_open (struct inode *inode,struct file *file) {return single_open (file, pinmux_hogs_show, inode->i_private);@@ -1003,6 +998,11 @@ static int pinctrl_devices_open(struct inode *inode, struct file *file)return single_open (file, pinctrl_devices_show,NULL ); } +static int pinctrl_maps_open (struct inode *inode,struct file *file) +{ +return single_open (file, pinctrl_maps_show,NULL ); +} +static int pinctrl_open (struct inode *inode,struct file *file) {return single_open (file, pinctrl_show,NULL );@@ -1029,22 +1029,22 @@ static const struct file_operations pinctrl_gpioranges_ops = { .release = single_release, }; -static const struct file_operations pinctrl_maps_ops = { - .open = pinctrl_maps_open, +static const struct file_operations pinmux_hogs_ops = { + .open = pinmux_hogs_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; -static const struct file_operations pinmux_hogs_ops = { - .open = pinmux_hogs_open, +static const struct file_operations pinctrl_devices_ops = { + .open = pinctrl_devices_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; -static const struct file_operations pinctrl_devices_ops = { - .open = pinctrl_devices_open, +static const struct file_operations pinctrl_maps_ops = { + .open = pinctrl_maps_open, .read = seq_read, .llseek = seq_lseek, .release = single_release,@@ -1078,8 +1078,6 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) device_root, pctldev, &pinctrl_groups_ops);debugfs_create_file ("gpio-ranges" ,S_IFREG |S_IRUGO , device_root, pctldev, &pinctrl_gpioranges_ops); -debugfs_create_file ("pinctrl-maps" ,S_IFREG |S_IRUGO , - device_root, pctldev, &pinctrl_maps_ops);debugfs_create_file ("pinmux-hogs" ,S_IFREG |S_IRUGO , device_root, pctldev, &pinmux_hogs_ops);pinmux_init_device_debugfs (device_root, pctldev);@@ -1102,6 +1100,8 @@ static void pinctrl_init_debugfs(void)debugfs_create_file ("pinctrl-devices" ,S_IFREG |S_IRUGO , debugfs_root,NULL , &pinctrl_devices_ops); +debugfs_create_file ("pinctrl-maps" ,S_IFREG |S_IRUGO , + debugfs_root,NULL , &pinctrl_maps_ops);debugfs_create_file ("pinctrl-handles" ,S_IFREG |S_IRUGO , debugfs_root,NULL , &pinctrl_ops); }Signature · 1 line
1.7.0.4
Re: [PATCH 3/3] pinctrl: Move pinctrl-maps debugfs file to top-level
In reply to Stephen WarrenQuoted 9 lines · Stephen Warren
The debugfs file pinctrl-maps is a system-wide file, not specific to any pin controller, so place it in the top-level directory.
Also, move the code implementing the file to keep the order of all the functions matching the order they're created in pinctrl_init_*debugfs(). The only non-obvious change here is no private data is passed to
debugfs_create_file()orsingle_open().Signed-off-by Stephen Warren <[email protected]>
Obviously correct, thanks, applied with Dong's ACK.
Yours,
Linus Walleij
Quoted 25 lines · Stephen Warren
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
Update documentation and mapping tables to use this.
Signed-off-by Stephen Warren <[email protected]>---
These 3 patches are small cleanup/fixes triggered by review comments from the 20-long series I posted a few days ago.These patches are based on the 4-long series that I posted yesterday.
Documentation/pinctrl.txt | 8 ++++---- arch/arm/mach-u300/core.c | 6 +++--- include/linux/pinctrl/machine.h | 13 ++++++++----- include/linux/pinctrl/pinctrl.h | 2 ++ 4 files changed, 17 insertions(+), 12 deletions(-)Documentation/pinctrl.txt +0
-0
Documentation/pinctrl.txt it even more compact which assumes you want to use pinctrl-foo and position · line 817
Quoted 5 lines
Documentation/pinctrl.txt +1
-1@@ -814,7 +814,7 @@ it even more compact which assumes you want to use pinctrl-foo and position 0 for mapping, for example: static struct pinctrl_map __initdata mapping[] = { - PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), + PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-foo", "i2c0", "foo-i2c.0"),
To keep align with the following PIN_MAP_SYS_HOG("pinmux-u300", "power"),
Maybe PIN_MAP("pinctrl-foo", "i2c0", "foo-i2c.0") is better, right?
And we may want to add a PIN_MAP_STAT macro, as well as PIN_MAP_SYS_HOG_STAT.
Regards
Dong Aisheng
Quoted 106 lines
Documentation/pinctrl.txt +3
-3};@@ -930,7 +930,7 @@ foo_probe() /* Allocate a state holder named "state" etc */ struct pinctrl p; - p = pinctrl_get(&device, NULL); + p = pinctrl_get(&device, PINCTRL_STATE_DEFAULT); if IS_ERR(p) return PTR_ERR(p); pinctrl_enable(p);@@ -988,7 +988,7 @@ This is enabled by simply setting the .dev_name field in the map to the name of the pin controller itself, like this: { - .name = "POWERMAP" + .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = "pinctrl-foo", .function = "power_func", .dev_name = "pinctrl-foo",@@ -998,7 +998,7 @@ Since it may be common to request the core to hog a few always-applicable mux settings on the primary pin controller, there is a convenience macro for this: -PIN_MAP_PRIMARY_SYS_HOG("POWERMAP", "pinctrl-foo", "power_func") +PIN_MAP_SYS_HOG("pinctrl-foo", "power_func") This gives the exact same result as the above construction.arch/arm/mach-u300/core.c +3
-3@@ -1554,9 +1554,9 @@ static struct platform_device pinmux_device = {/* Pinmux settings */ static struct pinctrl_map __initdata u300_pinmux_map[] = {/* anonymous maps for chip power and EMIFs */ -PIN_MAP_SYS_HOG ("POWER" ,"pinmux-u300" ,"power" ), -PIN_MAP_SYS_HOG ("EMIF0" ,"pinmux-u300" ,"emif0" ), -PIN_MAP_SYS_HOG ("EMIF1" ,"pinmux-u300" ,"emif1" ), +PIN_MAP_SYS_HOG ("pinmux-u300" ,"power" ), +PIN_MAP_SYS_HOG ("pinmux-u300" ,"emif0" ), +PIN_MAP_SYS_HOG ("pinmux-u300" ,"emif1" ),/* per-device maps for MMC/SD, SPI and UART */ PIN_MAP ("MMCSD" ,"pinmux-u300" ,"mmc0" ,"mmci" ),PIN_MAP ("SPI" ,"pinmux-u300" ,"spi0" ,"pl022" ),include/linux/pinctrl/machine.h +8
-5@@ -12,6 +12,8 @@#ifndef __LINUX_PINCTRL_MACHINE_H#define __LINUX_PINCTRL_MACHINE_H +#include "pinctrl.h" +/** * struct pinctrl_map - boards/machines shall provide this map for devices * @name: the name of this specific map entry for the particular machine. @@ -49,17 +51,18 @@ struct pinctrl_map {* 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. */ -#define PIN_MAP_SYS_HOG (a, b, c) \ - { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, } +#define PIN_MAP_SYS_HOG (a, b) \ + { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ + .function = b, }/* * Convenience macro to map a system function onto a certain pinctrl device * using a specified group, to be hogged by the pin control core until the * system shuts down. */ -#define PIN_MAP_SYS_HOG_GROUP (a, b, c, d) \ - { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, \ - .group = d, } +#define PIN_MAP_SYS_HOG_GROUP (a, b, c) \ + { .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \ + .function = b, .group = c, }#ifdef CONFIG_PINMUX include/linux/pinctrl/pinctrl.h +2
-0@@ -19,6 +19,8 @@#include <linux/list.h> #include <linux/seq_file.h> +#define PINCTRL_STATE_DEFAULT "default" +struct pinctrl_dev ;struct pinmux_ops ;struct pinconf_ops ;Signature · 7 lines
1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Dong Aisheng wrote at Thursday, February 23, 2012 8:25 PM:
Quoted 5 lines · Stephen Warren
Quoted 4 lines
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
...
Quoted 1 line
Quoted 1 line
Documentation/pinctrl.txt +0
-0
...
Quoted 8 lines
Documentation/pinctrl.txt it even more compact which assumes you want to use pinctrl-foo and position · line 817
Quoted 2 lines
Documentation/pinctrl.txt +1
-1- PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), + PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-foo", "i2c0", "foo-i2c.0"),To keep align with the following
PIN_MAP_SYS_HOG("pinmux-u300", "power"),
MaybePIN_MAP("pinctrl-foo", "i2c0", "foo-i2c.0")is better, right?And we may want to add a
PIN_MAP_STATmacro, as well asPIN_MAP_SYS_HOG_STAT.
I don't think so.
PIN_MAP_SYS_HOG hard-codes the state name inside the macro because its sole purpose is to support drivers/pinctrl/core.c's pinctrl_get() call for pin hogging purposes, so that state name is always "default", or rather, PINCTRL_STATE_DEFAULT.
The same isn't true of PIN_MAP; it's a general purpose macro intended for any device/situation/... I'd rather not keep inventing tons of macros in consumer.h and clutter it up.
I guess if you really want, you can submit a patch to add a macro e.g. PIN_MAP_MUX_GROUP_DEFAULT() which hard-codes the default state name if you wish, following on from my patch to extend the mapping table to support pin config.
BTW, did you have any further thoughts on (not) allowing NULL state names? I'd like to repost the final version of that patch, or rework it so that the code actually does allow NULL state names ASAP (i.e. early Friday for me), since it blocks some of the later patches in the series. Thanks.
Signature · 1 line
nvpublic
Quoted 16 lines · Stephen Warren
Dong Aisheng wrote at Thursday, February 23, 2012 8:25 PM:
Quoted 5 lines · Stephen Warren
Quoted 4 lines
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
...
Quoted 1 line
Quoted 1 line
Documentation/pinctrl.txt +0
-0...
Quoted 7 lines
Documentation/pinctrl.txt it even more compact which assumes you want to use pinctrl-foo and position · line 817
Quoted 2 lines
Documentation/pinctrl.txt +1
-1- PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), + PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-foo", "i2c0", "foo-i2c.0"),To keep align with the following
PIN_MAP_SYS_HOG("pinmux-u300", "power"),
MaybePIN_MAP("pinctrl-foo", "i2c0", "foo-i2c.0")is better, right?
Quoted 8 lines
Quoted 1 line
And we may want to add a
PIN_MAP_STATmacro, as well asPIN_MAP_SYS_HOG_STAT.I don't think so.
PIN_MAP_SYS_HOGhard-codes the state name inside the macro because its sole purpose is to support drivers/pinctrl/core.c'spinctrl_get()call for pin hogging purposes, so that state name is always "default", or rather,PINCTRL_STATE_DEFAULT.
I'm considering that we may also need to support multi states for system hog functions, do you agree?
If we support that, it may not mean the system function's state is always "defualt". And then we may be better to have separate convenience macro for those people who want to support multi states for system functions.
Quoted 5 lines
The same isn't true of
PIN_MAP; it's a general purpose macro intended for any device/situation/... I'd rather not keep inventing tons of macros inconsumer.hand clutter it up.
It's just the basic one and useful.
If we do not do it, i guess people will do it in their drivers which makes code duplication in kernel.
Quoted 10 lines
I guess if you really want, you can submit a patch to add a macro e.g.
PIN_MAP_MUX_GROUP_DEFAULT()which hard-codes the default state name if you wish, following on from my patch to extend the mapping table to support pin config.BTW, did you have any further thoughts on (not) allowing NULL state names? I'd like to repost the final version of that patch, or rework it so that the code actually does allow NULL state names ASAP (i.e. early Friday for me), since it blocks some of the later patches in the series. Thanks.
Personally i wish to support NULL state name.
But if it really can't, i can also accept no NULL state names.
You mentioned it may cause many problems on DT side to support NULL state. I'm still thinking the problems we're facing for dt and if we can fix it.
Thinking the model we discussed in Linaro connect:
sdhci@c8000200 {
pinctrl-0 = <&pmx_sdhci &pmx_sdhci_active>;
pinctrl-1 = <&pmx_sdhci &pmx_sdhci_standby>;
/* An optional list of state names; depends on SDHCI driver */
pinctrl-names = "active", "suspend";
};The orginally purpose will convert the id of pinctrl-0 (eg. it's '0' here) to be the state name if no pincgtrl-names property defined.
I'm wondering can we not use that id, just treat this case as no state names? If that we can allow dt to define null state names.
And it's easy for map writers to write such map.
But i do not know how much troubles it will be caused in implementation since you're writing all these code.
What do you think of it?
Regards
Dong Aisheng
Dong Aisheng wrote at Friday, February 24, 2012 12:10 AM:
Quoted 21 lines · Stephen Warren
Quoted 20 lines
Dong Aisheng wrote at Thursday, February 23, 2012 8:25 PM:
Quoted 5 lines · Stephen Warren
Quoted 4 lines
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
...
Quoted 1 line
Quoted 1 line
Documentation/pinctrl.txt +0
-0...
Quoted 8 lines
Documentation/pinctrl.txt it even more compact which assumes you want to use pinctrl-foo and position · line 817
Quoted 2 lines
Documentation/pinctrl.txt +1
-1- PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), + PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-foo", "i2c0", "foo-i2c.0"),To keep align with the following
PIN_MAP_SYS_HOG("pinmux-u300", "power"),
MaybePIN_MAP("pinctrl-foo", "i2c0", "foo-i2c.0")is better, right?And we may want to add a
PIN_MAP_STATmacro, as well asPIN_MAP_SYS_HOG_STAT.I don't think so.
Quoted 7 lines
Quoted 4 lines
PIN_MAP_SYS_HOGhard-codes the state name inside the macro because its sole purpose is to support drivers/pinctrl/core.c'spinctrl_get()call for pin hogging purposes, so that state name is always "default", or rather,PINCTRL_STATE_DEFAULT.I'm considering that we may also need to support multi states for system hog functions, do you agree?
Well, I don't think that'd be hogging; to my mind, hogging is specifically setting up PINCTRL_STATE_DEFAULT when a pin controller is registered.
But yes, I can see that the pinctrl core might want to use other state names for a pin controller, e.g. for suspend/resume, when unregistering the pin controller driver, etc.
That's exactly why in the mapping table rework patch I posted, I wrote a single all-encompassing table entry macro that'd work for all these situations, without the need to create a ton of special-case macros.
Still, I suppose now I've already enhanced that patch to support a few special case macros, I can add yet more. But, please can I defer this to that later patch rather than this one, since I'm already reworking all the macros there to support the enhanced mapping table format for pin config too?
Quoted 7 lines
Quoted 4 lines
BTW, did you have any further thoughts on (not) allowing NULL state names? I'd like to repost the final version of that patch, or rework it so that the code actually does allow NULL state names ASAP (i.e. early Friday for me), since it blocks some of the later patches in the series. Thanks.
Personally i wish to support NULL state name.
But if it really can't, i can also accept no NULL state names.
OK, can I take that as an ACK for my patch that completely removes the partial support for them ("Assume map table entries can't have a NULL name filed")?
Quoted 16 lines
You mentioned it may cause many problems on DT side to support NULL state. I'm still thinking the problems we're facing for dt and if we can fix it.
Thinking the model we discussed in Linaro connect:
sdhci@c8000200 { pinctrl-0 = <&pmx_sdhci &pmx_sdhci_active>; pinctrl-1 = <&pmx_sdhci &pmx_sdhci_standby>; /* An optional list of state names; depends on SDHCI driver */ pinctrl-names = "active", "suspend"; };The orginally purpose will convert the id of pinctrl-0 (eg. it's '0' here) to be the state name if no pincgtrl-names property defined.
I'm wondering can we not use that id, just treat this case as no state names? If that we can allow dt to define null state names.
And it's easy for map writers to write such map.
Quoted 4 lines
But i do not know how much troubles it will be caused in implementation since you're writing all these code.
What do you think of it?
That sure seems like adding a special-case to the device tree parsing code solely to provide justification for a special case in the mapping table processing code.
My root issue here: Why do we want a NULL name field? It serves no benefit that I can see, slightly complicates the code, obscures information in device drivers (since they aren't requesting a particular state name) and the pinctrl debugfs files (since we have these unnamed states, so people need to know what that means), etc.
Given I've agreed to make macros that set .name = PINCTRL_STATE_DEFAULT so that no mapping table author will need to do this, I don't think that having .name=PINCTRL_STATE_DEFAULT is going to save anything either.
Signature · 1 line
nvpublic
Quoted 27 lines · Stephen Warren
Dong Aisheng wrote at Friday, February 24, 2012 12:10 AM:
Quoted 26 lines · Stephen Warren
Quoted 24 lines
Dong Aisheng wrote at Thursday, February 23, 2012 8:25 PM:
Quoted 5 lines · Stephen Warren
Quoted 4 lines
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
...
Quoted 1 line
Quoted 1 line
Documentation/pinctrl.txt +0
-0...
Quoted 8 lines
Quoted 2 lines
-
PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"),
+PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-foo", "i2c0", "foo-i2c.0"),To keep align with the following
PIN_MAP_SYS_HOG("pinmux-u300", "power"),
MaybePIN_MAP("pinctrl-foo", "i2c0", "foo-i2c.0")is better, right?And we may want to add a
PIN_MAP_STATmacro, as well asPIN_MAP_SYS_HOG_STAT.I don't think so.
PIN_MAP_SYS_HOGhard-codes the state name inside the macro because its sole purpose is to support drivers/pinctrl/core.c'spinctrl_get()call for pin hogging purposes, so that state name is always "default", or rather,PINCTRL_STATE_DEFAULT.
Quoted 6 lines
Quoted 2 lines
I'm considering that we may also need to support multi states for system hog functions, do you agree?
Well, I don't think that'd be hogging; to my mind, hogging is specifically setting up
PINCTRL_STATE_DEFAULTwhen a pin controller is registered.
The hogging is determined by the device name not state name. And i can see there may be need for different pin config setting for system hog function
during different state like suspend and resume.
So the hog function may have different state like suspend and resume.
Quoted 8 lines
But yes, I can see that the pinctrl core might want to use other state names for a pin controller, e.g. for suspend/resume, when unregistering the pin controller driver, etc.
That's exactly why in the mapping table rework patch I posted, I wrote a single all-encompassing table entry macro that'd work for all these situations, without the need to create a ton of special-case macros.
Looks good, Will see it.
Quoted 6 lines
Still, I suppose now I've already enhanced that patch to support a few special case macros, I can add yet more. But, please can I defer this to that later patch rather than this one, since I'm already reworking all the macros there to support the enhanced mapping table format for pin config too?
Of course, yes.
It's ok to me since actually it's not a big deal.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
BTW, did you have any further thoughts on (not) allowing NULL state names? I'd like to repost the final version of that patch, or rework it so that the code actually does allow NULL state names ASAP (i.e. early Friday for me), since it blocks some of the later patches in the series. Thanks.
Quoted 7 lines
Quoted 2 lines
Personally i wish to support NULL state name.
But if it really can't, i can also accept no NULL state names.OK, can I take that as an ACK for my patch that completely removes the partial support for them ("Assume map table entries can't have a NULL name filed")?
Yes, please take my ACK.
I may miss something since i've not read over all your patches. You're the main contributor of the dt binding proposal and you may know it better
We can go for forward to see what we get if you think disallow NULL name is better.
Quoted 19 lines
Quoted 19 lines
You mentioned it may cause many problems on DT side to support NULL state. I'm still thinking the problems we're facing for dt and if we can fix it.
Thinking the model we discussed in Linaro connect:
sdhci@c8000200 {
pinctrl-0 = <&pmx_sdhci&pmx_sdhci_active>;
pinctrl-1 = <&pmx_sdhci&pmx_sdhci_standby>;
/* An optional list of state names; depends on SDHCI driver */ pinctrl-names = "active", "suspend";
};
The orginally purpose will convert the id of pinctrl-0 (eg. it's '0' here) to be the state name if no pincgtrl-names property defined.
I'm wondering can we not use that id, just treat this case as no state names? If that we can allow dt to define null state names.
And it's easy for map writers to write such map.But i do not know how much troubles it will be caused in implementation since you're writing all these code.
Quoted 7 lines
Quoted 1 line
What do you think of it?
That sure seems like adding a special-case to the device tree parsing code solely to provide justification for a special case in the mapping table processing code.
My root issue here: Why do we want a NULL name field? It serves no
The original reason to me is that 1) the mandatory state name does not make too much sense for those devices which do not support multi states.
2) And we do not need to change pinctrl_get(dev, NULL) to pinctrl_get(dev, PINCTR_DEFAULT_STATE) for device drivers already in kernel if allow NULL state name.
3) it also simplify the dt pinctrl map writing (do not need to add "default" state name for devices not support multi states).
Quoted 2 lines
benefit that I can see, slightly complicates the code, obscures information in device drivers (since they aren't requesting a particular state name)
This is true.
Quoted 2 lines
and the pinctrl debugfs files (since we have these unnamed states, so people need to know what that means), etc.
Maybe define these unnamed states to a special name to tell people that means not support multi states, right?
Quoted 3 lines
Given I've agreed to make macros that set .name =
PINCTRL_STATE_DEFAULTso that no mapping table author will need to do this, I don't think that
For non-dt, yes, for dt we still can not use such macros right?
Quoted 2 lines
having .name=PINCTRL_STATE_DEFAULT is going to save anything either.
Regards
Dong Aisheng
Quoted 8 lines · Stephen Warren
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
Update documentation and mapping tables to use this.
Signed-off-by Stephen Warren <[email protected]>
I like the direction this is taking for sure. This is however not working because
it break U300, no hogs nor device requests work after this patch so I cannot apply it.
I folded in this:
arch/arm/mach-u300/core.c +4 -4
@@ -1612,9 +1612,9 @@ static struct pinctrl_map __initdata u300_pinmux_map[] = {PIN_MAP_SYS_HOG ("pinmux-u300" ,"emif0" ),PIN_MAP_SYS_HOG ("pinmux-u300" ,"emif1" ),/* per-device maps for MMC/SD, SPI and UART */ -PIN_MAP ("MMCSD" ,"pinctrl-u300" ,"mmc0" ,"mmci" ), -PIN_MAP ("SPI" ,"pinctrl-u300" ,"spi0" ,"pl022" ), - PIN_MAP("UART0", "pinctrl-u300", "uart0", "uart0"), +PIN_MAP (PINCTRL_STATE_DEFAULT ,"pinctrl-u300" ,"mmc0" ,"mmci" ), +PIN_MAP (PINCTRL_STATE_DEFAULT ,"pinctrl-u300" ,"spi0" ,"pl022" ), + PIN_MAP(PINCTRL_STATE_DEFAULT, "pinctrl-u300", "uart0", "uart0"), }; struct u300_mux_hog {
@@ -1646,7 +1646,7 @@ static int __init u300_pinctrl_fetch(void)struct pinctrl *p;int ret; - p =pinctrl_get (u300_mux_hogs[i].dev,NULL ); + p =pinctrl_get (u300_mux_hogs[i].dev,PINCTRL_STATE_DEFAULT );if (IS_ERR (p)) {pr_err ("u300: could not get pinmux hog %s\n" , u300_mux_hogs[i].name);
Still no luck :-(
What am I missing?
Yours,
Linus Walleij
Linus Walleij wrote at Thursday, February 23, 2012 11:09 PM:
Quoted 7 lines · Stephen Warren
Quoted 6 lines
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
Quoted 7 lines
Quoted 3 lines
Update documentation and mapping tables to use this.
Signed-off-by Stephen Warren <[email protected]>I like the direction this is taking for sure. This is however not working because it break U300, no hogs nor device requests work after this patch so I cannot apply it.
Ah, I think I see what's happening.
Right now, pinctrl_hog_maps() iterates over every map entry, and when it finds a hog entry, it tries to get() and enable() that one entry. get() again iterates over the mapping table finding every entry with the same name. This all works fine if every hog entry in the mapping table for a given pin controller has a different name. However, this patch changes the name field to PINCTRL_STATE_DEFAULT in all cases, so the first get() finds 3 matching table entries and enables them all, then the outer loop in pinctrl_hog_maps() finds the second table entry and calls get() again which again finds all 3 entries and tries to enable them all.
I think the fix for this is to replace the body of pinctrl_hog_maps() with:
static int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
{
int ret;
INIT_LIST_HEAD(&pctldev->pinctrl_hogs);
mutex_lock(&pinctrl_maps_mutex);
ret = pinctrl_hog_map(pctldev, PINCTRL_STATE_DEFAULT);
mutex_unlock(&pinctrl_maps_mutex);
return ret;
}Does that work better? If so, I can fold it into the patch and repost, or you can fix it up as you apply; whichever you wish.
Signature · 1 line
nvpublic
Stephen Warren wrote at Friday, February 24, 2012 10:10 AM:
Quoted 9 lines
Linus Walleij wrote at Thursday, February 23, 2012 11:09 PM:
Quoted 8 lines · Stephen Warren
Quoted 7 lines
This provides a single centralized name for the default state.
Update PIN_MAP_* macros to use this state name, instead of requiring the user to pass a state name in.
Update documentation and mapping tables to use this.
...
Quoted 3 lines
Quoted 3 lines
I like the direction this is taking for sure. This is however not working because it break U300, no hogs nor device requests work after this patch so I cannot apply it.
...
Quoted 4 lines
I think the fix for this is to replace the body of
pinctrl_hog_maps()with:static int
pinctrl_hog_maps(struct pinctrl_dev *pctldev)
Quoted 11 lines
{
int ret;
INIT_LIST_HEAD(&pctldev->pinctrl_hogs);
mutex_lock(&pinctrl_maps_mutex);
ret = pinctrl_hog_map(pctldev, PINCTRL_STATE_DEFAULT);
mutex_unlock(&pinctrl_maps_mutex);
return ret;
}Oh, that won't work; the second parameter to pinctrl_hog_map() is a map entry, not a state name.
Fixing this requires removing pctldev->pinctrl_hogs, and removing the hog debugfs files (since that all relies on storing a list of mapping entries that were hogged) and just doing a single pinctrl_get()/pinctrl_enable(), and storing the one resulting struct pinctrl. I already did that as part of my later patch for the API rework. I can extract that part into this patch, and couple it with introducing define PINCTRL_STATE_DEFAULT, and repost.
Signature · 1 line
nvpublic