* [PATCH 1/2] pinctrl: support gpio request deferred probing @ 2012-04-25 11:38 Dong Aisheng 2012-04-25 11:38 ` [PATCH v3 2/2] pinctrl: add pinctrl_provide_dummies interface for platforms to use Dong Aisheng ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Dong Aisheng @ 2012-04-25 11:38 UTC (permalink / raw) To: linux-arm-kernel From: Dong Aisheng <dong.aisheng@linaro.org> As pinctrl handles, it may be possible the pinctrl gpio ranges are still not got registered when user call pinctrl_gpio_request. Thus, add defer support for it too. Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> --- drivers/pinctrl/core.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 5cd5a5a..ea2412a 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -276,7 +276,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio) * * Find the pin controller handling a certain GPIO pin from the pinspace of * the GPIO subsystem, return the device and the matching GPIO range. Returns - * negative if the GPIO range could not be found in any device. + * -EPROBE_DEFER if the GPIO range could not be found in any device since it + * may still have not been registered. */ static int pinctrl_get_device_gpio_range(unsigned gpio, struct pinctrl_dev **outdev, @@ -296,7 +297,7 @@ static int pinctrl_get_device_gpio_range(unsigned gpio, } } - return -EINVAL; + return -EPROBE_DEFER; } /** @@ -382,7 +383,7 @@ int pinctrl_request_gpio(unsigned gpio) ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); if (ret) { mutex_unlock(&pinctrl_mutex); - return -EINVAL; + return ret; } /* Convert to the pin controllers number space */ -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] pinctrl: add pinctrl_provide_dummies interface for platforms to use 2012-04-25 11:38 [PATCH 1/2] pinctrl: support gpio request deferred probing Dong Aisheng @ 2012-04-25 11:38 ` Dong Aisheng 2012-04-26 21:36 ` [PATCH 1/2] pinctrl: support gpio request deferred probing Linus Walleij 2012-04-27 18:16 ` Stephen Warren 2 siblings, 0 replies; 6+ messages in thread From: Dong Aisheng @ 2012-04-25 11:38 UTC (permalink / raw) To: linux-arm-kernel From: Dong Aisheng <dong.aisheng@linaro.org> Add a interface pinctrl_provide_dummies for platform to indicate whether it needs use pinctrl dummy state and dummy gpio. Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Stephen Warren <swarren@nvidia.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> --- ChangLog v2->v3: * Also changed the missed pinctrl gpio APIs in v1. ChangeLog v1->v2: * Based on sascha's suggestion, drop using kconfig since it will hide pinctrl errors on all other boards. See: https://lkml.org/lkml/2012/4/18/282 It seemed both Linus and Stephen agreed with this way, so i'm ok with it too. * add dummy gpio support. pinctrl gpio in the same situation as state. * patch name changed. Original is pinctrl: handle dummy state in core. * split removing old dt dummy interface into a separate patch --- drivers/pinctrl/core.c | 46 ++++++++++++++++++++++++++++++++++---- include/linux/pinctrl/machine.h | 5 +++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index ea2412a..2330225 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -43,6 +43,9 @@ struct pinctrl_maps { unsigned num_maps; }; +static bool pinctrl_dummy_state; +static bool pinctrl_dummy_gpio; + /* Mutex taken by all entry points */ DEFINE_MUTEX(pinctrl_mutex); @@ -61,6 +64,17 @@ static LIST_HEAD(pinctrl_maps); _i_ < _maps_node_->num_maps; \ i++, _map_ = &_maps_node_->maps[_i_]) +/** + * pinctrl_provide_dummies() - indicate if provide dummies for state and gpio + * @state - provide dummy state + * @gpio - provide dummy gpio + */ +void pinctrl_provide_dummies(bool state, bool gpio) +{ + pinctrl_dummy_state = state; + pinctrl_dummy_gpio = gpio; +} + const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev) { /* We're not allowed to register devices without name */ @@ -383,7 +397,12 @@ int pinctrl_request_gpio(unsigned gpio) ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); if (ret) { mutex_unlock(&pinctrl_mutex); - return ret; + if (pinctrl_dummy_gpio) { + pr_debug("pinctrl: using dummy gpio(%u)\n", gpio); + return 0; + } else { + return ret; + } } /* Convert to the pin controllers number space */ @@ -436,8 +455,15 @@ static int pinctrl_gpio_direction(unsigned gpio, bool input) int pin; ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); - if (ret) - return ret; + if (ret) { + if (pinctrl_dummy_gpio) { + pr_debug("pinctrl: set dummy gpio(%u) %s\n", gpio, + input ? "input" : "output"); + return 0; + } else { + return ret; + } + } /* Convert to the pin controllers number space */ pin = gpio - range->base + range->pin_base; @@ -720,8 +746,18 @@ static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p, struct pinctrl_state *state; state = find_state(p, name); - if (!state) - return ERR_PTR(-ENODEV); + if (!state) { + if (pinctrl_dummy_state) { + /* create dummy state */ + dev_dbg(p->dev, "using pinctrl dummy state (%s)\n", + name); + state = create_state(p, name); + if (IS_ERR(state)) + return state; + } else { + return ERR_PTR(-ENODEV); + } + } return state; } diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h index e4d1de7..849a844 100644 --- a/include/linux/pinctrl/machine.h +++ b/include/linux/pinctrl/machine.h @@ -154,7 +154,7 @@ struct pinctrl_map { extern int pinctrl_register_mappings(struct pinctrl_map const *map, unsigned num_maps); - +extern void pinctrl_provide_dummies(bool state, bool gpio); #else static inline int pinctrl_register_mappings(struct pinctrl_map const *map, @@ -163,5 +163,8 @@ static inline int pinctrl_register_mappings(struct pinctrl_map const *map, return 0; } +static inline void pinctrl_provide_dummies(bool state, bool gpio) +{ +} #endif /* !CONFIG_PINMUX */ #endif -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] pinctrl: support gpio request deferred probing 2012-04-25 11:38 [PATCH 1/2] pinctrl: support gpio request deferred probing Dong Aisheng 2012-04-25 11:38 ` [PATCH v3 2/2] pinctrl: add pinctrl_provide_dummies interface for platforms to use Dong Aisheng @ 2012-04-26 21:36 ` Linus Walleij 2012-04-27 2:17 ` Stephen Warren 2012-04-27 18:16 ` Stephen Warren 2 siblings, 1 reply; 6+ messages in thread From: Linus Walleij @ 2012-04-26 21:36 UTC (permalink / raw) To: linux-arm-kernel On Wed, Apr 25, 2012 at 1:38 PM, Dong Aisheng <b29396@freescale.com> wrote: > From: Dong Aisheng <dong.aisheng@linaro.org> > > As pinctrl handles, it may be possible the pinctrl gpio ranges > are still not got registered when user call pinctrl_gpio_request. > Thus, add defer support for it too. > > Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> Since nobody is saying anything and it looks reasonable, I just applied this. Thanks! Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] pinctrl: support gpio request deferred probing 2012-04-26 21:36 ` [PATCH 1/2] pinctrl: support gpio request deferred probing Linus Walleij @ 2012-04-27 2:17 ` Stephen Warren 2012-04-27 3:13 ` Dong Aisheng 0 siblings, 1 reply; 6+ messages in thread From: Stephen Warren @ 2012-04-27 2:17 UTC (permalink / raw) To: linux-arm-kernel On 04/26/2012 03:36 PM, Linus Walleij wrote: > On Wed, Apr 25, 2012 at 1:38 PM, Dong Aisheng <b29396@freescale.com> wrote: > >> From: Dong Aisheng <dong.aisheng@linaro.org> >> >> As pinctrl handles, it may be possible the pinctrl gpio ranges >> are still not got registered when user call pinctrl_gpio_request. >> Thus, add defer support for it too. >> >> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> > > Since nobody is saying anything and it looks reasonable, > I just applied this. I didn't look at this, because V4 was sent without this patch, so I assumed it'd been dropped by Dong. Was I wrong? ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] pinctrl: support gpio request deferred probing 2012-04-27 2:17 ` Stephen Warren @ 2012-04-27 3:13 ` Dong Aisheng 0 siblings, 0 replies; 6+ messages in thread From: Dong Aisheng @ 2012-04-27 3:13 UTC (permalink / raw) To: linux-arm-kernel Hi Stephen, On Fri, Apr 27, 2012 at 10:17:26AM +0800, Stephen Warren wrote: > On 04/26/2012 03:36 PM, Linus Walleij wrote: > > On Wed, Apr 25, 2012 at 1:38 PM, Dong Aisheng <b29396@freescale.com> wrote: > > > >> From: Dong Aisheng <dong.aisheng@linaro.org> > >> > >> As pinctrl handles, it may be possible the pinctrl gpio ranges > >> are still not got registered when user call pinctrl_gpio_request. > >> Thus, add defer support for it too. > >> > >> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> > > > > Since nobody is saying anything and it looks reasonable, > > I just applied this. > > I didn't look at this, because V4 was sent without this patch, so I > assumed it'd been dropped by Dong. Was I wrong? > I thought this patch had no relationship with dummy state v4 patch and it had no changes, so i did not resend it out with the v4 patch again. It did not mean drop. Sorry for causing confusing. Anyway thanks for your attention. Regards Dong Aisheng ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] pinctrl: support gpio request deferred probing 2012-04-25 11:38 [PATCH 1/2] pinctrl: support gpio request deferred probing Dong Aisheng 2012-04-25 11:38 ` [PATCH v3 2/2] pinctrl: add pinctrl_provide_dummies interface for platforms to use Dong Aisheng 2012-04-26 21:36 ` [PATCH 1/2] pinctrl: support gpio request deferred probing Linus Walleij @ 2012-04-27 18:16 ` Stephen Warren 2 siblings, 0 replies; 6+ messages in thread From: Stephen Warren @ 2012-04-27 18:16 UTC (permalink / raw) To: linux-arm-kernel On 04/25/2012 05:38 AM, Dong Aisheng wrote: > From: Dong Aisheng <dong.aisheng@linaro.org> > > As pinctrl handles, it may be possible the pinctrl gpio ranges > are still not got registered when user call pinctrl_gpio_request. > Thus, add defer support for it too. > > Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> Acked-by: Stephen Warren <swarren@wwwdotorg.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-04-27 18:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-04-25 11:38 [PATCH 1/2] pinctrl: support gpio request deferred probing Dong Aisheng 2012-04-25 11:38 ` [PATCH v3 2/2] pinctrl: add pinctrl_provide_dummies interface for platforms to use Dong Aisheng 2012-04-26 21:36 ` [PATCH 1/2] pinctrl: support gpio request deferred probing Linus Walleij 2012-04-27 2:17 ` Stephen Warren 2012-04-27 3:13 ` Dong Aisheng 2012-04-27 18:16 ` Stephen Warren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).