From b02244295fffef61d02e12a7befd438c1b2a1c09 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 16 Aug 2012 19:43:05 -0700 Subject: [PATCH] --- yaml --- r: 324571 b: refs/heads/master c: 6bfbd988d8abfd86e0cd93ae21ba1998378bddfa h: refs/heads/master i: 324569: 50ba7569854fc53f24db71345971a0239705ec1c 324567: 80acc096c1b4223f09376bbd154cb31b8c1454aa v: v3 --- [refs] | 2 +- .../staging/comedi/drivers/adl_pci8164.c | 65 ++++--------------- 2 files changed, 14 insertions(+), 53 deletions(-) diff --git a/[refs] b/[refs] index 0a8dd22bf7e2..097538447ba9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 180d7fc8ab7ace9b911196d6eba2c1e47c3cbe85 +refs/heads/master: 6bfbd988d8abfd86e0cd93ae21ba1998378bddfa diff --git a/trunk/drivers/staging/comedi/drivers/adl_pci8164.c b/trunk/drivers/staging/comedi/drivers/adl_pci8164.c index 247ef00a7c6c..ac406cf54282 100644 --- a/trunk/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/trunk/drivers/staging/comedi/drivers/adl_pci8164.c @@ -27,11 +27,7 @@ Author: Michel Lachaine Status: experimental Updated: Mon, 14 Apr 2008 15:10:32 +0100 -Configuration Options: - [0] - PCI bus of device (optional) - [1] - PCI slot of device (optional) - If bus/slot is not specified, the first supported - PCI device found will be used. +Configuration Options: not applicable, uses PCI auto config */ #include "../comedidev.h" @@ -216,59 +212,24 @@ static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, return 2; } -static struct pci_dev *adl_pci8164_find_pci(struct comedi_device *dev, - struct comedi_devconfig *it) +static int adl_pci8164_attach_pci(struct comedi_device *dev, + struct pci_dev *pcidev) { - struct pci_dev *pcidev = NULL; - int bus = it->options[0]; - int slot = it->options[1]; - - for_each_pci_dev(pcidev) { - if (pcidev->vendor != PCI_VENDOR_ID_ADLINK || - pcidev->device != PCI_DEVICE_ID_PCI8164) - continue; - if (bus || slot) { - /* requested particular bus/slot */ - if (pcidev->bus->number != bus || - PCI_SLOT(pcidev->devfn) != slot) - continue; - } - return pcidev; - } - printk(KERN_ERR - "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", - dev->minor, bus, slot); - return NULL; -} - -static int adl_pci8164_attach(struct comedi_device *dev, - struct comedi_devconfig *it) -{ - struct pci_dev *pcidev; struct comedi_subdevice *s; int ret; - printk(KERN_INFO "comedi: attempt to attach...\n"); - printk(KERN_INFO "comedi%d: adl_pci8164\n", dev->minor); + comedi_set_hw_dev(dev, &pcidev->dev); - dev->board_name = "pci8164"; + dev->board_name = dev->driver->driver_name; - ret = comedi_alloc_subdevices(dev, 4); + ret = comedi_pci_enable(pcidev, dev->board_name); if (ret) return ret; - - pcidev = adl_pci8164_find_pci(dev, it); - if (!pcidev) - return -EIO; - comedi_set_hw_dev(dev, &pcidev->dev); - - if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) { - printk(KERN_ERR "comedi%d: Failed to enable " - "PCI device and request regions\n", dev->minor); - return -EIO; - } dev->iobase = pci_resource_start(pcidev, 2); - printk(KERN_DEBUG "comedi: base addr %4lx\n", dev->iobase); + + ret = comedi_alloc_subdevices(dev, 4); + if (ret) + return ret; s = dev->subdevices + 0; s->type = COMEDI_SUBD_PROC; @@ -310,7 +271,8 @@ static int adl_pci8164_attach(struct comedi_device *dev, s->insn_read = adl_pci8164_insn_read_buf1; s->insn_write = adl_pci8164_insn_write_buf1; - printk(KERN_INFO "comedi: attached\n"); + dev_info(dev->class_dev, "%s attached\n", dev->board_name); + return 0; } @@ -321,14 +283,13 @@ static void adl_pci8164_detach(struct comedi_device *dev) if (pcidev) { if (dev->iobase) comedi_pci_disable(pcidev); - pci_dev_put(pcidev); } } static struct comedi_driver adl_pci8164_driver = { .driver_name = "adl_pci8164", .module = THIS_MODULE, - .attach = adl_pci8164_attach, + .attach_pci = adl_pci8164_attach_pci, .detach = adl_pci8164_detach, };