Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 282139
b: refs/heads/master
c: 97607d1
h: refs/heads/master
i:
  282137: 5911f27
  282135: ca40cae
v: v3
  • Loading branch information
Linus Walleij committed Jan 3, 2012
1 parent 7b406ff commit 3f68e78
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 542e704f3ffee1dc4539c9e8191e4dc215220f5e
refs/heads/master: 97607d157c133ab18dfcd77fa836e37fa950a44a
4 changes: 2 additions & 2 deletions trunk/Documentation/pinctrl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ spi on the second function mapping:

#include <linux/pinctrl/machine.h>

static const struct pinmux_map pmx_mapping[] = {
static const struct pinmux_map __initdata pmx_mapping[] = {
{
.ctrl_dev_name = "pinctrl.0",
.function = "spi0",
Expand Down Expand Up @@ -734,7 +734,7 @@ Since the above construct is pretty common there is a helper macro to make
it even more compact which assumes you want to use pinctrl.0 and position
0 for mapping, for example:

static struct pinmux_map pmx_mapping[] = {
static struct pinmux_map __initdata pmx_mapping[] = {
PINMUX_MAP_PRIMARY("I2CMAP", "i2c0", "foo-i2c.0"),
};

Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm/mach-u300/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ static struct platform_device pinmux_device = {
};

/* Pinmux settings */
static struct pinmux_map u300_pinmux_map[] = {
static struct pinmux_map __initdata u300_pinmux_map[] = {
/* anonymous maps for chip power and EMIFs */
PINMUX_MAP_PRIMARY_SYS_HOG("POWER", "power"),
PINMUX_MAP_PRIMARY_SYS_HOG("EMIF0", "emif0"),
Expand Down
44 changes: 34 additions & 10 deletions trunk/drivers/pinctrl/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
Expand All @@ -33,7 +34,7 @@ static DEFINE_MUTEX(pinmux_list_mutex);
static LIST_HEAD(pinmux_list);

/* Global pinmux maps, we allow one set only */
static struct pinmux_map const *pinmux_maps;
static struct pinmux_map *pinmux_maps;
static unsigned pinmux_maps_num;

/**
Expand Down Expand Up @@ -333,7 +334,9 @@ EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output);

/**
* pinmux_register_mappings() - register a set of pinmux mappings
* @maps: the pinmux mappings table to register
* @maps: the pinmux mappings table to register, this should be marked with
* __initdata so it can be discarded after boot, this function will
* perform a shallow copy for the mapping entries.
* @num_maps: the number of maps in the mapping table
*
* Only call this once during initialization of your machine, the function is
Expand All @@ -344,32 +347,48 @@ EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output);
int __init pinmux_register_mappings(struct pinmux_map const *maps,
unsigned num_maps)
{
int ret = 0;
int i;

if (pinmux_maps != NULL) {
if (pinmux_maps_num != 0) {
pr_err("pinmux mappings already registered, you can only "
"register one set of maps\n");
return -EINVAL;
}

pr_debug("add %d pinmux maps\n", num_maps);

/*
* Make a copy of the map array - string pointers will end up in the
* kernel const section anyway so these do not need to be deep copied.
*/
pinmux_maps = kmemdup(maps, sizeof(struct pinmux_map) * num_maps,
GFP_KERNEL);
if (!pinmux_maps)
return -ENOMEM;

for (i = 0; i < num_maps; i++) {
/* Sanity check the mapping */
/* Sanity check the mapping while copying it */
if (!maps[i].name) {
pr_err("failed to register map %d: "
"no map name given\n", i);
return -EINVAL;
ret = -EINVAL;
goto err_out_free;
}

if (!maps[i].ctrl_dev && !maps[i].ctrl_dev_name) {
pr_err("failed to register map %s (%d): "
"no pin control device given\n",
maps[i].name, i);
return -EINVAL;
ret = -EINVAL;
goto err_out_free;
}

if (!maps[i].function) {
pr_err("failed to register map %s (%d): "
"no function ID given\n", maps[i].name, i);
return -EINVAL;
ret = -EINVAL;
goto err_out_free;
}

if (!maps[i].dev && !maps[i].dev_name)
Expand All @@ -380,12 +399,17 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
pr_debug("register map %s, function %s\n",
maps[i].name,
maps[i].function);
}

pinmux_maps = maps;
pinmux_maps_num = num_maps;
pinmux_maps_num++;
}

return 0;

err_out_free:
kfree(pinmux_maps);
pinmux_maps = NULL;
pinmux_maps_num = 0;
return ret;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/pinctrl/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct pinmux_map {
const char *group;
struct device *dev;
const char *dev_name;
const bool hog_on_boot;
bool hog_on_boot;
};

/*
Expand Down

0 comments on commit 3f68e78

Please sign in to comment.