From: H Hartley Sweeten Date: Sat, 26 Jan 2013 00:33:54 +0000 (-0700) Subject: staging: comedi: ni_mio_cs: move pcmcia_driver functions X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=bea5b9035dae264e5da4a8a6aacc8bace0647c35;p=openwrt%2Fstaging%2Fblogic.git staging: comedi: ni_mio_cs: move pcmcia_driver functions For aesthetic reasons, move all the pcmcia_driver functions so they are near the pcmcia_driver declaration. This also removes the need for a couple forward declarations. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c index 1099b8b072f1..4043d02bd6ba 100644 --- a/drivers/staging/comedi/drivers/ni_mio_cs.c +++ b/drivers/staging/comedi/drivers/ni_mio_cs.c @@ -247,67 +247,8 @@ static void mio_cs_detach(struct comedi_device *dev) free_irq(dev->irq, dev); } -static void mio_cs_config(struct pcmcia_device *link); -static void cs_release(struct pcmcia_device *link); -static void cs_detach(struct pcmcia_device *); - static struct pcmcia_device *cur_dev; -static int cs_attach(struct pcmcia_device *link) -{ - cur_dev = link; - - mio_cs_config(link); - - return 0; -} - -static void cs_release(struct pcmcia_device *link) -{ - pcmcia_disable_device(link); -} - -static void cs_detach(struct pcmcia_device *link) -{ - cs_release(link); -} - -static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) -{ - int base, ret; - - p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; - p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; - - for (base = 0x000; base < 0x400; base += 0x20) { - p_dev->resource[0]->start = base; - ret = pcmcia_request_io(p_dev); - if (!ret) - return 0; - } - return -ENODEV; -} - - -static void mio_cs_config(struct pcmcia_device *link) -{ - int ret; - - DPRINTK("mio_cs_config(link=%p)\n", link); - link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; - - ret = pcmcia_loop_config(link, mio_pcmcia_config_loop, NULL); - if (ret) { - dev_warn(&link->dev, "no configuration found\n"); - return; - } - - if (!link->irq) - dev_info(&link->dev, "no IRQ available\n"); - - ret = pcmcia_enable_device(link); -} - static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct ni_private *devpriv; @@ -393,6 +334,60 @@ static int ni_getboardtype(struct comedi_device *dev, return 0; } +static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data) +{ + int base, ret; + + p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; + p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; + + for (base = 0x000; base < 0x400; base += 0x20) { + p_dev->resource[0]->start = base; + ret = pcmcia_request_io(p_dev); + if (!ret) + return 0; + } + return -ENODEV; +} + +static void mio_cs_config(struct pcmcia_device *link) +{ + int ret; + + DPRINTK("mio_cs_config(link=%p)\n", link); + link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; + + ret = pcmcia_loop_config(link, mio_pcmcia_config_loop, NULL); + if (ret) { + dev_warn(&link->dev, "no configuration found\n"); + return; + } + + if (!link->irq) + dev_info(&link->dev, "no IRQ available\n"); + + ret = pcmcia_enable_device(link); +} + +static int cs_attach(struct pcmcia_device *link) +{ + cur_dev = link; + + mio_cs_config(link); + + return 0; +} + +static void cs_release(struct pcmcia_device *link) +{ + pcmcia_disable_device(link); +} + +static void cs_detach(struct pcmcia_device *link) +{ + cs_release(link); +} + static const struct pcmcia_device_id ni_mio_cs_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d), /* DAQCard-ai-16xe-50 */ PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c), /* DAQCard-ai-16e-4 */