Commit 5b3aa5f7c6287b1a0698950a91e94546888e553b

Authored by Dong Aisheng
Committed by Linus Walleij
1 parent ad6e1107ba

pinctrl: add pinctrl_provide_dummies interface for platforms to use

Add a interface pinctrl_provide_dummies for platform to indicate
whether it needs use pinctrl dummy state.

ChangeLog v3->v4:
* remove dummy gpio support in pinctrl subsystem.
  Let gpio driver decide whether it wants to use pinctrl gpio mux
  function.
ChangeLog 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

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Showing 2 changed files with 31 additions and 3 deletions Side-by-side Diff

drivers/pinctrl/core.c
... ... @@ -43,6 +43,8 @@
43 43 unsigned num_maps;
44 44 };
45 45  
  46 +static bool pinctrl_dummy_state;
  47 +
46 48 /* Mutex taken by all entry points */
47 49 DEFINE_MUTEX(pinctrl_mutex);
48 50  
... ... @@ -61,6 +63,19 @@
61 63 _i_ < _maps_node_->num_maps; \
62 64 i++, _map_ = &_maps_node_->maps[_i_])
63 65  
  66 +/**
  67 + * pinctrl_provide_dummies() - indicate if pinctrl provides dummy state support
  68 + *
  69 + * Usually this function is called by platforms without pinctrl driver support
  70 + * but run with some shared drivers using pinctrl APIs.
  71 + * After calling this function, the pinctrl core will return successfully
  72 + * with creating a dummy state for the driver to keep going smoothly.
  73 + */
  74 +void pinctrl_provide_dummies(void)
  75 +{
  76 + pinctrl_dummy_state = true;
  77 +}
  78 +
64 79 const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev)
65 80 {
66 81 /* We're not allowed to register devices without name */
... ... @@ -719,8 +734,18 @@
719 734 struct pinctrl_state *state;
720 735  
721 736 state = find_state(p, name);
722   - if (!state)
723   - return ERR_PTR(-ENODEV);
  737 + if (!state) {
  738 + if (pinctrl_dummy_state) {
  739 + /* create dummy state */
  740 + dev_dbg(p->dev, "using pinctrl dummy state (%s)\n",
  741 + name);
  742 + state = create_state(p, name);
  743 + if (IS_ERR(state))
  744 + return state;
  745 + } else {
  746 + return ERR_PTR(-ENODEV);
  747 + }
  748 + }
724 749  
725 750 return state;
726 751 }
include/linux/pinctrl/machine.h
... ... @@ -154,7 +154,7 @@
154 154  
155 155 extern int pinctrl_register_mappings(struct pinctrl_map const *map,
156 156 unsigned num_maps);
157   -
  157 +extern void pinctrl_provide_dummies(void);
158 158 #else
159 159  
160 160 static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
... ... @@ -163,6 +163,9 @@
163 163 return 0;
164 164 }
165 165  
  166 +static inline void pinctrl_provide_dummies(void)
  167 +{
  168 +}
166 169 #endif /* !CONFIG_PINCTRL */
167 170 #endif