OSDN Git Service

staging: comedi: comedidev.h: add namespace to the subdevice "runflags"
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 20 Jan 2015 19:06:00 +0000 (12:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Jan 2015 11:59:09 +0000 (19:59 +0800)
Tidy up and document the subdevice "runflags". Rename them so they have
comedi namespace.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c

index f143cb6..68bfe92 100644 (file)
@@ -604,7 +604,7 @@ bool comedi_is_subdevice_running(struct comedi_subdevice *s)
 {
        unsigned runflags = comedi_get_subdevice_runflags(s);
 
-       return (runflags & SRF_RUNNING) ? true : false;
+       return (runflags & COMEDI_SRF_RUNNING) ? true : false;
 }
 EXPORT_SYMBOL_GPL(comedi_is_subdevice_running);
 
@@ -612,14 +612,14 @@ static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s)
 {
        unsigned runflags = comedi_get_subdevice_runflags(s);
 
-       return (runflags & SRF_ERROR) ? true : false;
+       return (runflags & COMEDI_SRF_ERROR) ? true : false;
 }
 
 static bool comedi_is_subdevice_idle(struct comedi_subdevice *s)
 {
        unsigned runflags = comedi_get_subdevice_runflags(s);
 
-       return (runflags & (SRF_ERROR | SRF_RUNNING)) ? false : true;
+       return (runflags & COMEDI_SRF_BUSY_MASK) ? false : true;
 }
 
 /**
@@ -634,7 +634,7 @@ void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size)
 {
        s->private = kzalloc(size, GFP_KERNEL);
        if (s->private)
-               s->runflags |= SRF_FREE_SPRIV;
+               s->runflags |= COMEDI_SRF_FREE_SPRIV;
        return s->private;
 }
 EXPORT_SYMBOL_GPL(comedi_alloc_spriv);
@@ -647,7 +647,7 @@ static void do_become_nonbusy(struct comedi_device *dev,
 {
        struct comedi_async *async = s->async;
 
-       comedi_set_subdevice_runflags(s, SRF_RUNNING, 0);
+       comedi_set_subdevice_runflags(s, COMEDI_SRF_RUNNING, 0);
        if (async) {
                comedi_buf_reset(s);
                async->inttrig = NULL;
@@ -1634,10 +1634,13 @@ static int do_cmd_ioctl(struct comedi_device *dev,
        if (async->cmd.flags & CMDF_WAKE_EOS)
                async->cb_mask |= COMEDI_CB_EOS;
 
-       comedi_set_subdevice_runflags(s, SRF_ERROR | SRF_RUNNING, SRF_RUNNING);
+       comedi_set_subdevice_runflags(s, COMEDI_SRF_BUSY_MASK,
+                                     COMEDI_SRF_RUNNING);
 
-       /* set s->busy _after_ setting SRF_RUNNING flag to avoid race with
-        * comedi_read() or comedi_write() */
+       /*
+        * Set s->busy _after_ setting COMEDI_SRF_RUNNING flag to avoid
+        * race with comedi_read() or comedi_write().
+        */
        s->busy = file;
        ret = s->do_cmd(dev, s);
        if (ret == 0)
@@ -2591,18 +2594,21 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
                return;
 
        if (s->async->events & COMEDI_CB_CANCEL_MASK)
-               runflags_mask |= SRF_RUNNING;
+               runflags_mask |= COMEDI_SRF_RUNNING;
 
        /*
         * Remember if an error event has occurred, so an error
         * can be returned the next time the user does a read().
         */
        if (s->async->events & COMEDI_CB_ERROR_MASK) {
-               runflags_mask |= SRF_ERROR;
-               runflags |= SRF_ERROR;
+               runflags_mask |= COMEDI_SRF_ERROR;
+               runflags |= COMEDI_SRF_ERROR;
        }
        if (runflags_mask) {
-               /*sets SRF_ERROR and SRF_RUNNING together atomically */
+               /*
+                * Sets COMEDI_SRF_ERROR and COMEDI_SRF_RUNNING together
+                * atomically.
+                */
                comedi_set_subdevice_runflags(s, runflags_mask, runflags);
        }
 
index 928572f..e5daaeb 100644 (file)
@@ -302,15 +302,22 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
 struct comedi_device *comedi_dev_get_from_minor(unsigned minor);
 int comedi_dev_put(struct comedi_device *dev);
 
-/* subdevice runflags */
-enum subdevice_runflags {
-       SRF_RT = 0x00000002,
-       /* indicates an COMEDI_CB_ERROR event has occurred since the last
-        * command was started */
-       SRF_ERROR = 0x00000004,
-       SRF_RUNNING = 0x08000000,
-       SRF_FREE_SPRIV = 0x80000000,    /* free s->private on detach */
-};
+/**
+ * comedi_subdevice "runflags"
+ * @COMEDI_SRF_RT:             DEPRECATED: command is running real-time
+ * @COMEDI_SRF_ERROR:          indicates an COMEDI_CB_ERROR event has occurred
+ *                             since the last command was started
+ * @COMEDI_SRF_RUNNING:                command is running
+ * @COMEDI_SRF_FREE_SPRIV:     free s->private on detach
+ *
+ * @COMEDI_SRF_BUSY_MASK:      runflags that indicate the subdevice is "busy"
+ */
+#define COMEDI_SRF_RT          BIT(1)
+#define COMEDI_SRF_ERROR       BIT(2)
+#define COMEDI_SRF_RUNNING     BIT(27)
+#define COMEDI_SRF_FREE_SPRIV  BIT(31)
+
+#define COMEDI_SRF_BUSY_MASK   (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING)
 
 bool comedi_is_subdevice_running(struct comedi_subdevice *s);
 
index 61802d7..f32e714 100644 (file)
@@ -125,7 +125,7 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev)
        if (dev->subdevices) {
                for (i = 0; i < dev->n_subdevices; i++) {
                        s = &dev->subdevices[i];
-                       if (s->runflags & SRF_FREE_SPRIV)
+                       if (s->runflags & COMEDI_SRF_FREE_SPRIV)
                                kfree(s->private);
                        comedi_free_subdevice_minor(s);
                        if (s->async) {