pinctrl: pass name instead of device to pin_config_*

Obtaining a "struct pinctrl_dev *" is difficult for code not directly
related to the pinctrl subsystem. However, the device name of the pinctrl
device is fairly well known. So, modify pin_config_*() to take the device
name instead of the "struct pinctrl_dev *".

Signed-off-by: Stephen Warren <swarren@nvidia.com>
[rebased on top of refactoring code]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Stephen Warren 2011-12-15 16:57:17 -07:00 коммит произвёл Linus Walleij
Родитель 63fd5984a9
Коммит 43699dea1e
3 изменённых файлов: 41 добавлений и 18 удалений

Просмотреть файл

@ -208,7 +208,7 @@ unconnected.
For example, a platform may do this: For example, a platform may do this:
ret = pin_config_set(dev, "FOO_GPIO_PIN", PLATFORM_X_PULL_UP); ret = pin_config_set("foo-dev", "FOO_GPIO_PIN", PLATFORM_X_PULL_UP);
To pull up a pin to VDD. The pin configuration driver implements callbacks for To pull up a pin to VDD. The pin configuration driver implements callbacks for
changing pin configuration in the pin controller ops like this: changing pin configuration in the pin controller ops like this:

Просмотреть файл

@ -39,17 +39,22 @@ int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
/** /**
* pin_config_get() - get the configuration of a single pin parameter * pin_config_get() - get the configuration of a single pin parameter
* @pctldev: pin controller device for this pin * @dev_name: name of the pin controller device for this pin
* @name: name of the pin to get the config for * @name: name of the pin to get the config for
* @config: the config pointed to by this argument will be filled in with the * @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 * current pin state, it can be used directly by drivers as a numeral, or
* it can be dereferenced to any struct. * it can be dereferenced to any struct.
*/ */
int pin_config_get(struct pinctrl_dev *pctldev, const char *name, int pin_config_get(const char *dev_name, const char *name,
unsigned long *config) unsigned long *config)
{ {
struct pinctrl_dev *pctldev;
int pin; int pin;
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
if (!pctldev)
return -EINVAL;
pin = pin_get_from_name(pctldev, name); pin = pin_get_from_name(pctldev, name);
if (pin < 0) if (pin < 0)
return pin; return pin;
@ -82,17 +87,22 @@ int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
/** /**
* pin_config_set() - set the configuration of a single pin parameter * pin_config_set() - set the configuration of a single pin parameter
* @pctldev: pin controller device for this pin * @dev_name: name of pin controller device for this pin
* @name: name of the pin to set the config for * @name: name of the pin to set the config for
* @config: the config in this argument will contain the desired pin state, it * @config: the config in this argument will contain the desired pin state, it
* can be used directly by drivers as a numeral, or it can be dereferenced * can be used directly by drivers as a numeral, or it can be dereferenced
* to any struct. * to any struct.
*/ */
int pin_config_set(struct pinctrl_dev *pctldev, const char *name, int pin_config_set(const char *dev_name, const char *name,
unsigned long config) unsigned long config)
{ {
struct pinctrl_dev *pctldev;
int pin; int pin;
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
if (!pctldev)
return -EINVAL;
pin = pin_get_from_name(pctldev, name); pin = pin_get_from_name(pctldev, name);
if (pin < 0) if (pin < 0)
return pin; return pin;
@ -101,12 +111,18 @@ int pin_config_set(struct pinctrl_dev *pctldev, const char *name,
} }
EXPORT_SYMBOL(pin_config_set); EXPORT_SYMBOL(pin_config_set);
int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group, int pin_config_group_get(const char *dev_name, const char *pin_group,
unsigned long *config) unsigned long *config)
{ {
const struct pinconf_ops *ops = pctldev->desc->confops; struct pinctrl_dev *pctldev;
const struct pinconf_ops *ops;
int selector; int selector;
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
if (!pctldev)
return -EINVAL;
ops = pctldev->desc->confops;
if (!ops || !ops->pin_config_group_get) { if (!ops || !ops->pin_config_group_get) {
dev_err(pctldev->dev, "cannot get configuration for pin " dev_err(pctldev->dev, "cannot get configuration for pin "
"group, missing group config get function in " "group, missing group config get function in "
@ -123,17 +139,24 @@ int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group,
EXPORT_SYMBOL(pin_config_group_get); EXPORT_SYMBOL(pin_config_group_get);
int pin_config_group_set(struct pinctrl_dev *pctldev, const char *pin_group, int pin_config_group_set(const char *dev_name, const char *pin_group,
unsigned long config) unsigned long config)
{ {
const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; struct pinctrl_dev *pctldev;
const struct pinconf_ops *ops = pctldev->desc->confops; const struct pinconf_ops *ops;
const struct pinctrl_ops *pctlops;
int selector; int selector;
const unsigned *pins; const unsigned *pins;
unsigned num_pins; unsigned num_pins;
int ret; int ret;
int i; int i;
pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
if (!pctldev)
return -EINVAL;
ops = pctldev->desc->confops;
pctlops = pctldev->desc->pctlops;
if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) {
dev_err(pctldev->dev, "cannot configure pin group, missing " dev_err(pctldev->dev, "cannot configure pin group, missing "
"config function in driver\n"); "config function in driver\n");

Просмотреть файл

@ -53,39 +53,39 @@ struct pinconf_ops {
unsigned selector); unsigned selector);
}; };
extern int pin_config_get(struct pinctrl_dev *pctldev, const char *name, extern int pin_config_get(const char *dev_name, const char *name,
unsigned long *config); unsigned long *config);
extern int pin_config_set(struct pinctrl_dev *pctldev, const char *name, extern int pin_config_set(const char *dev_name, const char *name,
unsigned long config); unsigned long config);
extern int pin_config_group_get(struct pinctrl_dev *pctldev, extern int pin_config_group_get(const char *dev_name,
const char *pin_group, const char *pin_group,
unsigned long *config); unsigned long *config);
extern int pin_config_group_set(struct pinctrl_dev *pctldev, extern int pin_config_group_set(const char *dev_name,
const char *pin_group, const char *pin_group,
unsigned long config); unsigned long config);
#else #else
static inline int pin_config_get(struct pinctrl_dev *pctldev, const char *name, static inline int pin_config_get(const char *dev_name, const char *name,
unsigned long *config) unsigned long *config)
{ {
return 0; return 0;
} }
static inline int pin_config_set(struct pinctrl_dev *pctldev, const char *name, static inline int pin_config_set(const char *dev_name, const char *name,
unsigned long config) unsigned long config)
{ {
return 0; return 0;
} }
static inline int pin_config_group_get(struct pinctrl_dev *pctldev, static inline int pin_config_group_get(const char *dev_name,
const char *pin_group, const char *pin_group,
unsigned long *config) unsigned long *config)
{ {
return 0; return 0;
} }
static inline int pin_config_group_set(struct pinctrl_dev *pctldev, static inline int pin_config_group_set(const char *dev_name,
const char *pin_group, const char *pin_group,
unsigned long config) unsigned long config)
{ {