From a3ac95195b020a0a8fa2a9b0649145324ba64c83 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 5 Feb 2013 18:16:07 -0700 Subject: [PATCH] staging: comedi: comedi_pcmcia: allow drivers to use a custom conf_check() Allow comedi pcmcia drivers to use a custom conf_check() when calling comedi_pcmcia_enable() to enable the pcmcia device. If a conf_check() is not passed the internal comedi_pcmcia_conf_check() will be used. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_pcmcia.c | 9 +++++++-- drivers/staging/comedi/comedidev.h | 3 ++- drivers/staging/comedi/drivers/cb_das16_cs.c | 2 +- drivers/staging/comedi/drivers/das08_cs.c | 2 +- drivers/staging/comedi/drivers/ni_daq_700.c | 2 +- drivers/staging/comedi/drivers/ni_daq_dio24.c | 2 +- drivers/staging/comedi/drivers/ni_labpc_cs.c | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_pcmcia.c b/drivers/staging/comedi/comedi_pcmcia.c index 925f12825c1b..453ff3b28617 100644 --- a/drivers/staging/comedi/comedi_pcmcia.c +++ b/drivers/staging/comedi/comedi_pcmcia.c @@ -49,12 +49,14 @@ static int comedi_pcmcia_conf_check(struct pcmcia_device *link, /** * comedi_pcmcia_enable() - Request the regions and enable the PCMCIA device. * @dev: comedi_device struct + * @conf_check: optional callback to check the pcmcia_device configuration * * The comedi PCMCIA driver needs to set the link->config_flags, as * appropriate for that driver, before calling this function in order * to allow pcmcia_loop_config() to do its internal autoconfiguration. */ -int comedi_pcmcia_enable(struct comedi_device *dev) +int comedi_pcmcia_enable(struct comedi_device *dev, + int (*conf_check)(struct pcmcia_device *, void *)) { struct pcmcia_device *link = comedi_to_pcmcia_dev(dev); int ret; @@ -62,7 +64,10 @@ int comedi_pcmcia_enable(struct comedi_device *dev) if (!link) return -ENODEV; - ret = pcmcia_loop_config(link, comedi_pcmcia_conf_check, NULL); + if (!conf_check) + conf_check = comedi_pcmcia_conf_check; + + ret = pcmcia_loop_config(link, conf_check, NULL); if (ret) return ret; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d921cd784b00..f3a990b45df5 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -440,7 +440,8 @@ struct pcmcia_device; struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *); -int comedi_pcmcia_enable(struct comedi_device *); +int comedi_pcmcia_enable(struct comedi_device *, + int (*conf_check)(struct pcmcia_device *, void *)); void comedi_pcmcia_disable(struct comedi_device *); int comedi_pcmcia_auto_config(struct pcmcia_device *, struct comedi_driver *); diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 5bbffd9f8af9..f874fff44523 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -413,7 +413,7 @@ static int das16cs_auto_attach(struct comedi_device *dev, dev->board_name = board->name; link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; - ret = comedi_pcmcia_enable(dev); + ret = comedi_pcmcia_enable(dev, NULL); if (ret) return ret; dev->iobase = link->resource[0]->start; diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 818a609b0dba..cfeebe4d1ddd 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -81,7 +81,7 @@ static int das08_cs_auto_attach(struct comedi_device *dev, dev->board_ptr = &das08_cs_boards[0]; link->config_flags |= CONF_AUTO_SET_IO; - ret = comedi_pcmcia_enable(dev); + ret = comedi_pcmcia_enable(dev, NULL); if (ret) return ret; iobase = link->resource[0]->start; diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index c8f4c7d2a832..9cc6092eacdd 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -205,7 +205,7 @@ static int daq700_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; link->config_flags |= CONF_AUTO_SET_IO; - ret = comedi_pcmcia_enable(dev); + ret = comedi_pcmcia_enable(dev, NULL); if (ret) return ret; dev->iobase = link->resource[0]->start; diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index edfbfb315122..32ee22dbb858 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -55,7 +55,7 @@ static int dio24_auto_attach(struct comedi_device *dev, dev->board_name = dev->driver->driver_name; link->config_flags |= CONF_AUTO_SET_IO; - ret = comedi_pcmcia_enable(dev); + ret = comedi_pcmcia_enable(dev, NULL); return ret; dev->iobase = link->resource[0]->start; diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index 1c55de35e874..be7d1413b2e5 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -99,7 +99,7 @@ static int labpc_auto_attach(struct comedi_device *dev, link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ; - ret = comedi_pcmcia_enable(dev); + ret = comedi_pcmcia_enable(dev, NULL); if (ret) return ret; dev->iobase = link->resource[0]->start; -- 2.30.2