diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-09-24 16:21:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-26 12:37:29 -0400 |
commit | 91e674e83c530d5902e482ede1af0115989c4fe6 (patch) | |
tree | 4a5be768e965c92ec9b59395ee1c99bd29ed641c | |
parent | 832defbb58061fedb7a5c43aab7d762afaac2cc9 (diff) |
staging: comedi: s626: use attach_pci callback
Convert this PCI driver to use the comedi PCI auto config attach
mechanism by adding an 'attach_pci' callback function. Since the
driver does not require any external configuration options, and
the legacy 'attach' callback is not optional, remove it.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/s626.c | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index bac14458536e..eff7e962b9b5 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c | |||
@@ -32,11 +32,7 @@ Authors: Gianluca Palli <gpalli@deis.unibo.it>, | |||
32 | Updated: Fri, 15 Feb 2008 10:28:42 +0000 | 32 | Updated: Fri, 15 Feb 2008 10:28:42 +0000 |
33 | Status: experimental | 33 | Status: experimental |
34 | 34 | ||
35 | Configuration options: | 35 | Configuration options: not applicable, uses PCI auto config |
36 | [0] - PCI bus of device (optional) | ||
37 | [1] - PCI slot of device (optional) | ||
38 | If bus/slot is not specified, the first supported | ||
39 | PCI device found will be used. | ||
40 | 36 | ||
41 | INSN_CONFIG instructions: | 37 | INSN_CONFIG instructions: |
42 | analog input: | 38 | analog input: |
@@ -2442,35 +2438,7 @@ static void CountersInit(struct comedi_device *dev) | |||
2442 | } | 2438 | } |
2443 | } | 2439 | } |
2444 | 2440 | ||
2445 | static struct pci_dev *s626_find_pci(struct comedi_device *dev, | 2441 | static int s626_attach_pci(struct comedi_device *dev, struct pci_dev *pcidev) |
2446 | struct comedi_devconfig *it) | ||
2447 | { | ||
2448 | struct pci_dev *pcidev = NULL; | ||
2449 | int bus = it->options[0]; | ||
2450 | int slot = it->options[1]; | ||
2451 | int i; | ||
2452 | |||
2453 | do { | ||
2454 | pcidev = pci_get_subsys(PCI_VENDOR_ID_S626, | ||
2455 | PCI_DEVICE_ID_S626, | ||
2456 | PCI_SUBVENDOR_ID_S626, | ||
2457 | PCI_SUBDEVICE_ID_S626, | ||
2458 | pcidev); | ||
2459 | |||
2460 | if ((bus || slot) && pcidev) { | ||
2461 | /* matches requested bus/slot */ | ||
2462 | if (pcidev->bus->number == bus && | ||
2463 | PCI_SLOT(pcidev->devfn) == slot) | ||
2464 | break; | ||
2465 | } else { | ||
2466 | break; | ||
2467 | } | ||
2468 | } while (1); | ||
2469 | |||
2470 | return pcidev; | ||
2471 | } | ||
2472 | |||
2473 | static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) | ||
2474 | { | 2442 | { |
2475 | /* uint8_t PollList; */ | 2443 | /* uint8_t PollList; */ |
2476 | /* uint16_t AdcData; */ | 2444 | /* uint16_t AdcData; */ |
@@ -2487,11 +2455,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
2487 | if (alloc_private(dev, sizeof(struct s626_private)) < 0) | 2455 | if (alloc_private(dev, sizeof(struct s626_private)) < 0) |
2488 | return -ENOMEM; | 2456 | return -ENOMEM; |
2489 | 2457 | ||
2490 | devpriv->pdev = s626_find_pci(dev, it); | 2458 | devpriv->pdev = pcidev; |
2491 | if (!devpriv->pdev) { | ||
2492 | printk(KERN_ERR "s626_attach: Board not present!!!\n"); | ||
2493 | return -ENODEV; | ||
2494 | } | ||
2495 | 2459 | ||
2496 | result = comedi_pci_enable(devpriv->pdev, "s626"); | 2460 | result = comedi_pci_enable(devpriv->pdev, "s626"); |
2497 | if (result < 0) { | 2461 | if (result < 0) { |
@@ -2932,7 +2896,6 @@ static void s626_detach(struct comedi_device *dev) | |||
2932 | if (devpriv->pdev) { | 2896 | if (devpriv->pdev) { |
2933 | if (devpriv->got_regions) | 2897 | if (devpriv->got_regions) |
2934 | comedi_pci_disable(devpriv->pdev); | 2898 | comedi_pci_disable(devpriv->pdev); |
2935 | pci_dev_put(devpriv->pdev); | ||
2936 | } | 2899 | } |
2937 | } | 2900 | } |
2938 | } | 2901 | } |
@@ -2940,7 +2903,7 @@ static void s626_detach(struct comedi_device *dev) | |||
2940 | static struct comedi_driver s626_driver = { | 2903 | static struct comedi_driver s626_driver = { |
2941 | .driver_name = "s626", | 2904 | .driver_name = "s626", |
2942 | .module = THIS_MODULE, | 2905 | .module = THIS_MODULE, |
2943 | .attach = s626_attach, | 2906 | .attach_pci = s626_attach_pci, |
2944 | .detach = s626_detach, | 2907 | .detach = s626_detach, |
2945 | }; | 2908 | }; |
2946 | 2909 | ||