8255 shouldn't use async structure because it doesn't get allocated.
authorDavid Schleef <ds@schleef.org>
Fri, 16 Mar 2001 19:32:22 +0000 (19:32 +0000)
committerDavid Schleef <ds@schleef.org>
Fri, 16 Mar 2001 19:32:22 +0000 (19:32 +0000)
comedi/drivers/8255.c

index e9bd6a9232977beeebc1ce4cf5a0f50d94366733..aa16591357826c1a40223d1b95b0b5615a05a4e0 100644 (file)
 #define CR_A_MODE(a)   ((a)<<5)
 #define CR_CW          0x80
 
-#define CALLBACK_ARG   ((void *)(s->async->cb_arg))
-#define CALLBACK_FUNC  ((int (*)(int,int,int,void *))(s->async->cb_func))
+struct subdev_8255_struct{
+       void *cb_arg;
+       int (*cb_func)(int,int,int,void *);
+};
+
+#define CALLBACK_ARG   (((struct subdev_8255_struct *)s->private)->cb_arg)
+#define CALLBACK_FUNC  (((struct subdev_8255_struct *)s->private)->cb_func)
 
 static int dev_8255_attach(comedi_device * dev, comedi_devconfig * it);
 static int dev_8255_detach(comedi_device * dev);
@@ -162,10 +167,11 @@ int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,in
        s->range_table=&range_digital;
        s->maxdata=1;
 
-       /* commandeer range_list */
-       CALLBACK_ARG=arg;
+       /* XXX This causes a memory leak */
+       s->private=kmalloc(sizeof(struct subdev_8255_struct),GFP_KERNEL);
+       if(!s->private)return -ENOMEM;
 
-       /* same for flaglist */
+       CALLBACK_ARG=arg;
        if(cb==NULL){
                CALLBACK_FUNC=subdev_8255_cb;
        }else{