From: Frank Mori Hess Date: Mon, 20 Oct 2008 18:18:06 +0000 (+0000) Subject: Fixed up device_create call for auto-probed device files so it X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ee347ef80ffff282373fe96cd02e7545f1fda303;p=comedi.git Fixed up device_create call for auto-probed device files so it more fully associates the pci_dev with the device file. --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 747b8382..c1fbcb26 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -2126,14 +2126,9 @@ int comedi_alloc_board_minor(struct device *hardware_device) } info->device->minor = i; csdev = COMEDI_DEVICE_CREATE(comedi_class, NULL, - MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i); + MKDEV(COMEDI_MAJOR, i), NULL, hardware_device, "comedi%i", i); if(!IS_ERR(csdev)) { info->device->class_dev = csdev; - if(hardware_device) - { - sysfs_create_link(&csdev->kobj, - &hardware_device->kobj, "device"); - } } return i; } @@ -2156,7 +2151,6 @@ void comedi_free_board_minor(unsigned minor) { if(dev->class_dev) { - sysfs_remove_link(&dev->class_dev->kobj, "device"); device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, dev->minor)); } comedi_device_cleanup(dev); @@ -2196,7 +2190,7 @@ int comedi_alloc_subdevice_minor(comedi_device *dev, comedi_subdevice *s) } s->minor = i; csdev = COMEDI_DEVICE_CREATE(comedi_class, dev->class_dev, - MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i_subd%i", dev->minor, s - dev->subdevices); + MKDEV(COMEDI_MAJOR, i), NULL, NULL, "comedi%i_subd%i", dev->minor, s - dev->subdevices); if(!IS_ERR(csdev)) { s->class_dev = csdev; diff --git a/include/linux/device.h b/include/linux/device.h index 79fc252d..71be1e00 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -89,19 +89,19 @@ static inline void device_destroy(struct class *cs, dev_t devt) class_simple_destroy((struct class_simple *)(cs)) typedef struct class_device device_create_result_type; -#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \ +#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, device, fmt...) \ class_simple_device_add((struct class_simple *)(cs), \ - devt, NULL, fmt) + devt, device, fmt) #define device_destroy(cs, devt) \ class_simple_device_remove(devt) #else -/* versions earlier than 2.6.15 are currently broken as of 2008-10-16 FMH*/ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) typedef struct class_device device_create_result_type; -#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \ - class_device_create(cs, devt, NULL, fmt) +#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, device, fmt...) \ + class_device_create(cs, devt, device, fmt) #define device_destroy(cs, devt) \ class_device_destroy(cs, devt) @@ -111,9 +111,9 @@ exactly which kernel version it was fixed in. */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) typedef struct class_device device_create_result_type; -#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \ +#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, device, fmt...) \ class_device_create( \ - cs, parent, devt, NULL, fmt) + cs, parent, devt, device, fmt) #define device_destroy(cs, devt) \ class_device_destroy(cs, devt) @@ -122,21 +122,21 @@ typedef struct class_device device_create_result_type; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) typedef struct device device_create_result_type; -#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \ - device_create(cs, parent, devt, fmt) +#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, device, fmt...) \ + device_create(cs, ((parent) ? (parent) : (device)), devt, fmt) #else #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) typedef struct device device_create_result_type; -#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \ - device_create_drvdata(cs, parent, devt, drvdata, fmt) +#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, device, fmt...) \ + device_create_drvdata(cs, ((parent) ? (parent) : (device)), devt, drvdata, fmt) #else -#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \ - device_create(cs, parent, devt, drvdata, fmt) +#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, device, fmt...) \ + device_create(cs, ((parent) ? (parent) : (device)), devt, drvdata, fmt) #endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)