summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 21:59:44 (GMT)
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 21:59:44 (GMT)
commit8966961b31c251b854169e9886394c2a20f2cea7 (patch)
tree248a625b23335acbd5ca4b55eb136fe0dc8ba0aa /drivers/staging/comedi/drivers.c
parent6a5971d8fea1f4a8c33dfe0cec6a1c490f0c9cde (diff)
parent7bcb57cde66c19df378f3468ea342166a8a4504d (diff)
downloadlinux-fsl-qoriq-8966961b31c251b854169e9886394c2a20f2cea7.tar.xz
Merge tag 'staging-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver tree merge from Greg Kroah-Hartman: "Here's the big staging tree merge for 3.8-rc1 There's a lot of patches in here, the majority being the comedi rework/cleanup that has been ongoing and is causing a huge reduction in overall code size, which is amazing to watch. We also removed some older drivers (telephony and rts_pstor), and added a new one (fwserial which also came in through the tty tree due to tty api changes, take that one if you get merge conflicts.) The iio and ipack drivers are moving out of the staging area into their own part of the kernel as they have been cleaned up sufficiently and are working well. Overall, again a reduction of code: 768 files changed, 31887 insertions(+), 82166 deletions(-) All of this has been in the linux-next tree for a while. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'staging-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1298 commits) iio: imu: adis16480: remove duplicated include from adis16480.c iio: gyro: adis16136: remove duplicated include from adis16136.c iio:imu: adis16480: show_firmware() buffer too small iio:gyro: adis16136: divide by zero in write_frequency() iio: adc: Add Texas Instruments ADC081C021/027 support iio:ad7793: Add support for the ad7796 and ad7797 iio:ad7793: Add support for the ad7798 and ad7799 staging:iio: Move ad7793 driver out of staging staging:iio:ad7793: Implement stricter id checking staging:iio:ad7793: Move register definitions from header to source staging:iio:ad7793: Rework regulator handling staging:iio:ad7793: Rework platform data staging:iio:ad7793: Use kstrtol instead of strict_strtol staging:iio:ad7793: Use usleep_range instead of msleep staging:iio:ad7793: Fix temperature scale staging:iio:ad7793: Fix VDD monitor scale staging: gdm72xx: unlock on error in init_usb() staging: panel: pass correct lengths to keypad_send_key() staging: comedi: addi_apci_2032: fix interrupt support staging: comedi: addi_apci_2032: move i_APCI2032_ConfigDigitalOutput() ...
Diffstat (limited to 'drivers/staging/comedi/drivers.c')
-rw-r--r--drivers/staging/comedi/drivers.c144
1 files changed, 14 insertions, 130 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 1db6bfd..50cf498 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -21,9 +21,6 @@
*/
-#define _GNU_SOURCE
-
-#define __NO_VERSION__
#include <linux/device.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -833,11 +830,8 @@ void comedi_reset_async_buf(struct comedi_async *async)
async->events = 0;
}
-static int
-comedi_auto_config_helper(struct device *hardware_device,
- struct comedi_driver *driver,
- int (*attach_wrapper) (struct comedi_device *,
- void *), void *context)
+int comedi_auto_config(struct device *hardware_device,
+ struct comedi_driver *driver, unsigned long context)
{
int minor;
struct comedi_device_file_info *dev_file_info;
@@ -847,6 +841,13 @@ comedi_auto_config_helper(struct device *hardware_device,
if (!comedi_autoconfig)
return 0;
+ if (!driver->auto_attach) {
+ dev_warn(hardware_device,
+ "BUG! comedi driver '%s' has no auto_attach handler\n",
+ driver->driver_name);
+ return -EINVAL;
+ }
+
minor = comedi_alloc_board_minor(hardware_device);
if (minor < 0)
return minor;
@@ -860,9 +861,9 @@ comedi_auto_config_helper(struct device *hardware_device,
else if (!try_module_get(driver->module))
ret = -EIO;
else {
- /* set comedi_dev->driver here for attach wrapper */
+ comedi_set_hw_dev(comedi_dev, hardware_device);
comedi_dev->driver = driver;
- ret = (*attach_wrapper)(comedi_dev, context);
+ ret = driver->auto_attach(comedi_dev, context);
if (ret < 0) {
module_put(driver->module);
__comedi_device_detach(comedi_dev);
@@ -876,49 +877,9 @@ comedi_auto_config_helper(struct device *hardware_device,
comedi_free_board_minor(minor);
return ret;
}
+EXPORT_SYMBOL_GPL(comedi_auto_config);
-static int comedi_auto_config_wrapper(struct comedi_device *dev, void *context)
-{
- struct comedi_devconfig *it = context;
- struct comedi_driver *driv = dev->driver;
-
- if (driv->num_names) {
- /* look for generic board entry matching driver name, which
- * has already been copied to it->board_name */
- dev->board_ptr = comedi_recognize(driv, it->board_name);
- if (dev->board_ptr == NULL) {
- dev_warn(dev->class_dev,
- "auto config failed to find board entry '%s' for driver '%s'\n",
- it->board_name, driv->driver_name);
- comedi_report_boards(driv);
- return -EINVAL;
- }
- }
- if (!driv->attach) {
- dev_warn(dev->class_dev,
- "BUG! driver '%s' using old-style auto config but has no attach handler\n",
- driv->driver_name);
- return -EINVAL;
- }
- return driv->attach(dev, it);
-}
-
-static int comedi_auto_config(struct device *hardware_device,
- struct comedi_driver *driver, const int *options,
- unsigned num_options)
-{
- struct comedi_devconfig it;
-
- memset(&it, 0, sizeof(it));
- strncpy(it.board_name, driver->driver_name, COMEDI_NAMELEN);
- it.board_name[COMEDI_NAMELEN - 1] = '\0';
- BUG_ON(num_options > COMEDI_NDEVCONFOPTS);
- memcpy(it.options, options, num_options * sizeof(int));
- return comedi_auto_config_helper(hardware_device, driver,
- comedi_auto_config_wrapper, &it);
-}
-
-static void comedi_auto_unconfig(struct device *hardware_device)
+void comedi_auto_unconfig(struct device *hardware_device)
{
int minor;
@@ -930,6 +891,7 @@ static void comedi_auto_unconfig(struct device *hardware_device)
BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
comedi_free_board_minor(minor);
}
+EXPORT_SYMBOL_GPL(comedi_auto_unconfig);
/**
* comedi_pci_enable() - Enable the PCI device and request the regions.
@@ -965,48 +927,6 @@ void comedi_pci_disable(struct pci_dev *pdev)
}
EXPORT_SYMBOL_GPL(comedi_pci_disable);
-static int comedi_old_pci_auto_config(struct pci_dev *pcidev,
- struct comedi_driver *driver)
-{
- int options[2];
-
- /* pci bus */
- options[0] = pcidev->bus->number;
- /* pci slot */
- options[1] = PCI_SLOT(pcidev->devfn);
-
- return comedi_auto_config(&pcidev->dev, driver,
- options, ARRAY_SIZE(options));
-}
-
-static int comedi_pci_attach_wrapper(struct comedi_device *dev, void *pcidev)
-{
- return dev->driver->attach_pci(dev, pcidev);
-}
-
-static int comedi_new_pci_auto_config(struct pci_dev *pcidev,
- struct comedi_driver *driver)
-{
- return comedi_auto_config_helper(&pcidev->dev, driver,
- comedi_pci_attach_wrapper, pcidev);
-}
-
-int comedi_pci_auto_config(struct pci_dev *pcidev, struct comedi_driver *driver)
-{
-
- if (driver->attach_pci)
- return comedi_new_pci_auto_config(pcidev, driver);
- else
- return comedi_old_pci_auto_config(pcidev, driver);
-}
-EXPORT_SYMBOL_GPL(comedi_pci_auto_config);
-
-void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
-{
- comedi_auto_unconfig(&pcidev->dev);
-}
-EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig);
-
int comedi_pci_driver_register(struct comedi_driver *comedi_driver,
struct pci_driver *pci_driver)
{
@@ -1040,42 +960,6 @@ EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister);
#if IS_ENABLED(CONFIG_USB)
-static int comedi_old_usb_auto_config(struct usb_interface *intf,
- struct comedi_driver *driver)
-{
- return comedi_auto_config(&intf->dev, driver, NULL, 0);
-}
-
-static int comedi_usb_attach_wrapper(struct comedi_device *dev, void *intf)
-{
- return dev->driver->attach_usb(dev, intf);
-}
-
-static int comedi_new_usb_auto_config(struct usb_interface *intf,
- struct comedi_driver *driver)
-{
- return comedi_auto_config_helper(&intf->dev, driver,
- comedi_usb_attach_wrapper, intf);
-}
-
-int comedi_usb_auto_config(struct usb_interface *intf,
- struct comedi_driver *driver)
-{
- BUG_ON(intf == NULL);
- if (driver->attach_usb)
- return comedi_new_usb_auto_config(intf, driver);
- else
- return comedi_old_usb_auto_config(intf, driver);
-}
-EXPORT_SYMBOL_GPL(comedi_usb_auto_config);
-
-void comedi_usb_auto_unconfig(struct usb_interface *intf)
-{
- BUG_ON(intf == NULL);
- comedi_auto_unconfig(&intf->dev);
-}
-EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig);
-
int comedi_usb_driver_register(struct comedi_driver *comedi_driver,
struct usb_driver *usb_driver)
{