Parameters of device_create() changed in 2.6.27-rc1, so call compatibility
authorIan Abbott <abbotti@mev.co.uk>
Tue, 5 Aug 2008 14:43:40 +0000 (14:43 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Tue, 5 Aug 2008 14:43:40 +0000 (14:43 +0000)
macro COMEDI_DEVICE_CREATE() instead.

comedi/comedi_fops.c
comedi/drivers.c
include/linux/device.h

index 0568951bfa7382e016246ebd4a596a3161c8ddba..914c9a803a05dcfc61559168c9313518eda8bd45 100644 (file)
@@ -1914,8 +1914,8 @@ static int __init comedi_init(void)
        for (i = 0; i < COMEDI_NDEVICES; i++) {
                struct device *csdev;
                comedi_devices[i].minor = i;
-               csdev = device_create(comedi_class, 0, MKDEV(COMEDI_MAJOR, i),
-                               "comedi%i", i);
+               csdev = COMEDI_DEVICE_CREATE(comedi_class, 0,
+                               MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i);
                if (!IS_ERR(csdev))
                        comedi_devices[i].class_dev = csdev;
                spin_lock_init(&comedi_devices[i].spinlock);
index 625c94133c3eefdeea88f24e70411b86e78628a2..36cbf4b964ab75062f9193f227d7dcf84b8e881b 100644 (file)
@@ -291,8 +291,8 @@ static int postconfig(comedi_device * dev)
                        }
                        minor = comedi_construct_minor_for_subdevice(dev, i);
                        devt = MKDEV(COMEDI_MAJOR, minor);
-                       csdev = device_create(comedi_class,
-                               dev->class_dev, devt, "comedi%i_sub%i",
+                       csdev = COMEDI_DEVICE_CREATE(comedi_class,
+                               dev->class_dev, devt, NULL, "comedi%i_sub%i",
                                dev->minor, i);
                        if (!IS_ERR(csdev))
                                s->class_dev = csdev;
index 4ee4454870ea0d6054e3251b47847c6b189e74c0..7ed524df2a5754363eacce14610b3f2e7ab4abcd 100644 (file)
  * The main limitation is that we cannot use a *real* 'struct device *' as
  * the parent parameter of device_create(), only a pointer from a previous
  * call to device_create().
+ *
+ * Call COMEDI_DEVICE_CREATE() instead of device_create() for compatibility
+ * with kernel versions prior to 2.6.27.
+ *
+ * We do not currently support 'dev_get_drvdata()' and 'dev_set_drvdata()'
+ * for kernel versions prior to 2.6.26, so the 'drvdata' parameter of
+ * COMEDI_DEVICE_CREATE() is pretty useless.
  */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -61,7 +68,7 @@ static inline void class_destroy(struct class *cs)
 }
 
 static inline struct device *device_create(struct class *cls,
-       struct device *parent, dev_t devt, char *fmt, ...)
+       struct device *parent, dev_t devt, void *drvdata, char *fmt, ...)
 {
        return NULL;
 }
@@ -80,7 +87,7 @@ static inline void device_destroy(struct class *cs, dev_t devt)
        (struct class *)class_simple_create(owner, name)
 #define class_destroy(cs) \
        class_simple_destroy((struct class_simple *)(cs))
-#define device_create(cs, parent, devt, fmt...) \
+#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \
        (struct device *)class_simple_device_add((struct class_simple *)(cs), \
                devt, NULL, fmt)
 #define device_destroy(cs, devt) \
@@ -90,7 +97,7 @@ static inline void device_destroy(struct class *cs, dev_t devt)
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
 
-#define device_create(cs, parent, devt, fmt...) \
+#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \
        (struct device *)class_device_create(cs, devt, NULL, fmt)
 #define device_destroy(cs, devt) \
        class_device_destroy(cs, devt)
@@ -99,12 +106,35 @@ static inline void device_destroy(struct class *cs, dev_t devt)
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
 
-#define device_create(cs, parent, devt, fmt...) \
+#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \
        (struct device *)class_device_create( \
                        cs, (struct class_device *)parent, devt, NULL, fmt)
 #define device_destroy(cs, devt) \
        class_device_destroy(cs, devt)
 
+#else
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+
+#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \
+       device_create(cs, parent, devt, fmt)
+
+#else
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+
+#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \
+       device_create_drvdata(cs, parent, devt, drvdata, fmt)
+
+#else
+
+#define COMEDI_DEVICE_CREATE(cs, parent, devt, drvdata, fmt...) \
+       device_create(cs, parent, devt, drvdata, fmt)
+
+#endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+
+#endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+
 #endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
 
 #endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)