aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-30 03:51:52 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-09-29 11:20:23 -0400
commit440eed43e2a95bb842488755683716814da10f2b (patch)
tree45c49181a077f845cd366cfa7dc07f259fd01078 /drivers/ata
parent9485ee14e143c7076e88deea1e87ca3eb0b2f94e (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/ata')
-rw-r--r--drivers/ata/pata_pcmcia.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 76da55d27e08..954f43c512f1 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -169,34 +169,16 @@ static struct ata_port_operations pcmcia_8bit_port_ops = {
169 169
170struct pcmcia_config_check { 170struct pcmcia_config_check {
171 unsigned long ctl_base; 171 unsigned long ctl_base;
172 int skip_vcc;
173 int is_kme; 172 int is_kme;
174}; 173};
175 174
176static int pcmcia_check_one_config(struct pcmcia_device *pdev, 175static int pcmcia_check_one_config(struct pcmcia_device *pdev,
177 cistpl_cftable_entry_t *cfg, 176 cistpl_cftable_entry_t *cfg,
178 cistpl_cftable_entry_t *dflt, 177 cistpl_cftable_entry_t *dflt,
179 unsigned int vcc,
180 void *priv_data) 178 void *priv_data)
181{ 179{
182 struct pcmcia_config_check *stk = priv_data; 180 struct pcmcia_config_check *stk = priv_data;
183 181
184 /* Check for matching Vcc, unless we're desperate */
185 if (!stk->skip_vcc) {
186 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
187 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
188 return -ENODEV;
189 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
190 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
191 return -ENODEV;
192 }
193 }
194
195 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
196 pdev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
197 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
198 pdev->vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
199
200 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 182 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
201 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 183 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
202 pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 184 pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
@@ -249,6 +231,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
249 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 231 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
250 pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 232 pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
251 pdev->config_flags |= CONF_ENABLE_IRQ; 233 pdev->config_flags |= CONF_ENABLE_IRQ;
234 pdev->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
252 235
253 /* See if we have a manufacturer identifier. Use it to set is_kme for 236 /* See if we have a manufacturer identifier. Use it to set is_kme for
254 vendor quirks */ 237 vendor quirks */
@@ -262,10 +245,10 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
262 if (!stk) 245 if (!stk)
263 goto out1; 246 goto out1;
264 stk->is_kme = is_kme; 247 stk->is_kme = is_kme;
265 stk->skip_vcc = io_base = ctl_base = 0; 248 io_base = ctl_base = 0;
266 249
267 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { 250 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
268 stk->skip_vcc = 1; 251 pdev->config_flags &= ~CONF_AUTO_CHECK_VCC;
269 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) 252 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
270 goto failed; /* No suitable config found */ 253 goto failed; /* No suitable config found */
271 } 254 }