diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-07-30 03:51:52 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-09-29 11:20:23 -0400 |
commit | 440eed43e2a95bb842488755683716814da10f2b (patch) | |
tree | 45c49181a077f845cd366cfa7dc07f259fd01078 /drivers/pcmcia | |
parent | 9485ee14e143c7076e88deea1e87ca3eb0b2f94e (diff) |
pcmcia: introduce autoconfiguration feature
Introduce an autoconfiguration feature to set certain values in
pcmcia_loop_config(), instead of copying the same code over and over
in each PCMCIA driver. At first, introduce the following options:
CONF_AUTO_CHECK_VCC check or matching Vcc entry
CONF_AUTO_SET_VPP set Vpp
CONF_AUTO_AUDIO enable the speaker line
CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
CC: linux-ide@vger.kernel.org
CC: linux-usb@vger.kernel.org
CC: laforge@gnumonks.org
CC: linux-mtd@lists.infradead.org
CC: alsa-devel@alsa-project.org
CC: linux-serial@vger.kernel.org
CC: Jiri Kosina <jkosina@suse.cz>
CC: linux-scsi@vger.kernel.org
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi> (for drivers/bluetooth)
Tested-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/pcmcia_cis.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/drivers/pcmcia/pcmcia_cis.c b/drivers/pcmcia/pcmcia_cis.c index ce8b94a3b675..160da0697335 100644 --- a/drivers/pcmcia/pcmcia_cis.c +++ b/drivers/pcmcia/pcmcia_cis.c | |||
@@ -131,7 +131,6 @@ struct pcmcia_cfg_mem { | |||
131 | int (*conf_check) (struct pcmcia_device *p_dev, | 131 | int (*conf_check) (struct pcmcia_device *p_dev, |
132 | cistpl_cftable_entry_t *cfg, | 132 | cistpl_cftable_entry_t *cfg, |
133 | cistpl_cftable_entry_t *dflt, | 133 | cistpl_cftable_entry_t *dflt, |
134 | unsigned int vcc, | ||
135 | void *priv_data); | 134 | void *priv_data); |
136 | cisparse_t parse; | 135 | cisparse_t parse; |
137 | cistpl_cftable_entry_t dflt; | 136 | cistpl_cftable_entry_t dflt; |
@@ -146,16 +145,46 @@ struct pcmcia_cfg_mem { | |||
146 | */ | 145 | */ |
147 | static int pcmcia_do_loop_config(tuple_t *tuple, cisparse_t *parse, void *priv) | 146 | static int pcmcia_do_loop_config(tuple_t *tuple, cisparse_t *parse, void *priv) |
148 | { | 147 | { |
149 | cistpl_cftable_entry_t *cfg = &parse->cftable_entry; | ||
150 | struct pcmcia_cfg_mem *cfg_mem = priv; | 148 | struct pcmcia_cfg_mem *cfg_mem = priv; |
149 | struct pcmcia_device *p_dev = cfg_mem->p_dev; | ||
150 | cistpl_cftable_entry_t *cfg = &parse->cftable_entry; | ||
151 | cistpl_cftable_entry_t *dflt = &cfg_mem->dflt; | ||
152 | unsigned int flags = p_dev->config_flags; | ||
153 | unsigned int vcc = p_dev->socket->socket.Vcc; | ||
154 | |||
155 | dev_dbg(&p_dev->dev, "testing configuration %x, autoconf %x\n", | ||
156 | cfg->index, flags); | ||
151 | 157 | ||
152 | /* default values */ | 158 | /* default values */ |
153 | cfg_mem->p_dev->config_index = cfg->index; | 159 | cfg_mem->p_dev->config_index = cfg->index; |
154 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | 160 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) |
155 | cfg_mem->dflt = *cfg; | 161 | cfg_mem->dflt = *cfg; |
156 | 162 | ||
163 | /* check for matching Vcc? */ | ||
164 | if (flags & CONF_AUTO_CHECK_VCC) { | ||
165 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
166 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
167 | return -ENODEV; | ||
168 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
169 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
170 | return -ENODEV; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | /* set Vpp? */ | ||
175 | if (flags & CONF_AUTO_SET_VPP) { | ||
176 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
177 | p_dev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
178 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
179 | p_dev->vpp = | ||
180 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
181 | } | ||
182 | |||
183 | /* enable audio? */ | ||
184 | if ((flags & CONF_AUTO_AUDIO) && (cfg->flags & CISTPL_CFTABLE_AUDIO)) | ||
185 | p_dev->config_flags |= CONF_ENABLE_SPKR; | ||
186 | |||
157 | return cfg_mem->conf_check(cfg_mem->p_dev, cfg, &cfg_mem->dflt, | 187 | return cfg_mem->conf_check(cfg_mem->p_dev, cfg, &cfg_mem->dflt, |
158 | cfg_mem->p_dev->socket->socket.Vcc, | ||
159 | cfg_mem->priv_data); | 188 | cfg_mem->priv_data); |
160 | } | 189 | } |
161 | 190 | ||
@@ -176,7 +205,6 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, | |||
176 | int (*conf_check) (struct pcmcia_device *p_dev, | 205 | int (*conf_check) (struct pcmcia_device *p_dev, |
177 | cistpl_cftable_entry_t *cfg, | 206 | cistpl_cftable_entry_t *cfg, |
178 | cistpl_cftable_entry_t *dflt, | 207 | cistpl_cftable_entry_t *dflt, |
179 | unsigned int vcc, | ||
180 | void *priv_data), | 208 | void *priv_data), |
181 | void *priv_data) | 209 | void *priv_data) |
182 | { | 210 | { |