From 84bb0bccd26ec3029124a9dd200b985c1cde77bd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 20 Jan 2015 12:06:00 -0700 Subject: [PATCH] staging: comedi: comedidev.h: add namespace to the subdevice "runflags" Tidy up and document the subdevice "runflags". Rename them so they have comedi namespace. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 30 +++++++++++++++++----------- drivers/staging/comedi/comedidev.h | 25 ++++++++++++++--------- drivers/staging/comedi/drivers.c | 2 +- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index f143cb64d69e..68bfe92319e6 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -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); } diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 928572fc958c..e5daaeb6b013 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -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); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 61802d7947ae..f32e71438948 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -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) { -- 2.20.1