* 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)
}
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;
}
(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) \
#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)
#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)