comedi_proc_init();
for (i = 0; i < COMEDI_NDEVICES; i++) {
- char name[20];
- sprintf(name, "comedi%d", i);
+ struct device *csdev;
comedi_devices[i].minor = i;
- comedi_devices[i].class_dev =
- COMEDI_CLASS_DEVICE_CREATE(comedi_class, 0,
- MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i);
+ csdev = device_create(comedi_class, 0, MKDEV(COMEDI_MAJOR, i),
+ "comedi%i", i);
+ if (!IS_ERR(csdev))
+ comedi_devices[i].class_dev = csdev;
spin_lock_init(&comedi_devices[i].spinlock);
mutex_init(&comedi_devices[i].mutex);
}
comedi_device_detach(dev);
mutex_unlock(&dev->mutex);
mutex_destroy(&dev->mutex);
- class_device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, i));
+ device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, i));
}
class_destroy(comedi_class);
cdev_del(&comedi_cdev);
comedi_construct_minor_for_subdevice
(dev, i);
dev_t devt = MKDEV(COMEDI_MAJOR, minor);
- class_device_destroy(comedi_class, devt);
+ device_destroy(comedi_class, devt);
}
if (s->async) {
comedi_buf_alloc(dev, s, 0);
if (s->do_cmd) {
unsigned minor;
dev_t devt;
+ struct device *csdev;
BUG_ON((s->subdev_flags & (SDF_CMD_READ |
SDF_CMD_WRITE)) == 0);
}
minor = comedi_construct_minor_for_subdevice(dev, i);
devt = MKDEV(COMEDI_MAJOR, minor);
- s->class_dev =
- COMEDI_CLASS_DEVICE_CREATE(comedi_class,
- dev->class_dev, devt, NULL, "comedi%i_sub%i",
+ csdev = device_create(comedi_class,
+ dev->class_dev, devt, "comedi%i_sub%i",
dev->minor, i);
+ if (!IS_ERR(csdev))
+ s->class_dev = csdev;
}
if (!s->range_table && !s->range_table_list)
};
struct class;
-struct class_device;
struct device;
static inline struct class *class_create(struct module *owner, char *name)
{
return NULL;
-};
+}
static inline void class_destroy(struct class *cs)
{
-};
+}
-static inline struct class_device *COMEDI_CLASS_DEVICE_CREATE(struct class *cls,
- struct class_device *parent, dev_t devt, struct device *device,
- char *fmt, ...)
+static inline struct device *device_create(struct class *cls,
+ struct device *parent, dev_t devt, char *fmt, ...)
{
return NULL;
-};
+}
-static inline void class_device_destroy(struct class *cs, dev_t dev)
+static inline void device_destroy(struct class *cs, dev_t devt)
{
-};
+}
#else
(struct class *)class_simple_create(owner, name)
#define class_destroy(cs) \
class_simple_destroy((struct class_simple *)(cs))
-#define COMEDI_CLASS_DEVICE_CREATE(cs, parent, dev, device, fmt...) \
- class_simple_device_add((struct class_simple *)(cs), \
- dev, device, fmt)
-#define class_device_destroy(cs, dev) \
- class_simple_device_remove(dev)
+#define device_create(cs, parent, devt, fmt...) \
+ (struct device *)class_simple_device_add((struct class_simple *)(cs), \
+ devt, NULL, fmt)
+#define device_destroy(cs, devt) \
+ class_simple_device_remove(devt)
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
-#define COMEDI_CLASS_DEVICE_CREATE(cs, parent, dev, device, fmt...) \
- class_device_create(cs, dev, device, fmt)
+#define device_create(cs, parent, devt, fmt...) \
+ (struct device *)class_device_create(cs, devt, NULL, fmt)
+#define device_destroy(cs, devt) \
+ class_device_destroy(cs, devt)
#else
-#define COMEDI_CLASS_DEVICE_CREATE(cs, parent, dev, device, fmt...) \
- class_device_create(cs, parent, dev, device, fmt)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+
+#define device_create(cs, parent, devt, fmt...) \
+ (struct device *)class_device_create( \
+ cs, (struct class_device *)parent, devt, NULL, fmt)
+#define device_destroy(cs, devt) \
+ class_device_destroy(cs, devt)
+
+#endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
#endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)