Skip to content

Commit 84bb0bc

Browse files
bigguinessgregkh
authored andcommitted
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 <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 738e1e1 commit 84bb0bc

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

drivers/staging/comedi/comedi_fops.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,22 +604,22 @@ bool comedi_is_subdevice_running(struct comedi_subdevice *s)
604604
{
605605
unsigned runflags = comedi_get_subdevice_runflags(s);
606606

607-
return (runflags & SRF_RUNNING) ? true : false;
607+
return (runflags & COMEDI_SRF_RUNNING) ? true : false;
608608
}
609609
EXPORT_SYMBOL_GPL(comedi_is_subdevice_running);
610610

611611
static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s)
612612
{
613613
unsigned runflags = comedi_get_subdevice_runflags(s);
614614

615-
return (runflags & SRF_ERROR) ? true : false;
615+
return (runflags & COMEDI_SRF_ERROR) ? true : false;
616616
}
617617

618618
static bool comedi_is_subdevice_idle(struct comedi_subdevice *s)
619619
{
620620
unsigned runflags = comedi_get_subdevice_runflags(s);
621621

622-
return (runflags & (SRF_ERROR | SRF_RUNNING)) ? false : true;
622+
return (runflags & COMEDI_SRF_BUSY_MASK) ? false : true;
623623
}
624624

625625
/**
@@ -634,7 +634,7 @@ void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size)
634634
{
635635
s->private = kzalloc(size, GFP_KERNEL);
636636
if (s->private)
637-
s->runflags |= SRF_FREE_SPRIV;
637+
s->runflags |= COMEDI_SRF_FREE_SPRIV;
638638
return s->private;
639639
}
640640
EXPORT_SYMBOL_GPL(comedi_alloc_spriv);
@@ -647,7 +647,7 @@ static void do_become_nonbusy(struct comedi_device *dev,
647647
{
648648
struct comedi_async *async = s->async;
649649

650-
comedi_set_subdevice_runflags(s, SRF_RUNNING, 0);
650+
comedi_set_subdevice_runflags(s, COMEDI_SRF_RUNNING, 0);
651651
if (async) {
652652
comedi_buf_reset(s);
653653
async->inttrig = NULL;
@@ -1634,10 +1634,13 @@ static int do_cmd_ioctl(struct comedi_device *dev,
16341634
if (async->cmd.flags & CMDF_WAKE_EOS)
16351635
async->cb_mask |= COMEDI_CB_EOS;
16361636

1637-
comedi_set_subdevice_runflags(s, SRF_ERROR | SRF_RUNNING, SRF_RUNNING);
1637+
comedi_set_subdevice_runflags(s, COMEDI_SRF_BUSY_MASK,
1638+
COMEDI_SRF_RUNNING);
16381639

1639-
/* set s->busy _after_ setting SRF_RUNNING flag to avoid race with
1640-
* comedi_read() or comedi_write() */
1640+
/*
1641+
* Set s->busy _after_ setting COMEDI_SRF_RUNNING flag to avoid
1642+
* race with comedi_read() or comedi_write().
1643+
*/
16411644
s->busy = file;
16421645
ret = s->do_cmd(dev, s);
16431646
if (ret == 0)
@@ -2591,18 +2594,21 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
25912594
return;
25922595

25932596
if (s->async->events & COMEDI_CB_CANCEL_MASK)
2594-
runflags_mask |= SRF_RUNNING;
2597+
runflags_mask |= COMEDI_SRF_RUNNING;
25952598

25962599
/*
25972600
* Remember if an error event has occurred, so an error
25982601
* can be returned the next time the user does a read().
25992602
*/
26002603
if (s->async->events & COMEDI_CB_ERROR_MASK) {
2601-
runflags_mask |= SRF_ERROR;
2602-
runflags |= SRF_ERROR;
2604+
runflags_mask |= COMEDI_SRF_ERROR;
2605+
runflags |= COMEDI_SRF_ERROR;
26032606
}
26042607
if (runflags_mask) {
2605-
/*sets SRF_ERROR and SRF_RUNNING together atomically */
2608+
/*
2609+
* Sets COMEDI_SRF_ERROR and COMEDI_SRF_RUNNING together
2610+
* atomically.
2611+
*/
26062612
comedi_set_subdevice_runflags(s, runflags_mask, runflags);
26072613
}
26082614

drivers/staging/comedi/comedidev.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,22 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
302302
struct comedi_device *comedi_dev_get_from_minor(unsigned minor);
303303
int comedi_dev_put(struct comedi_device *dev);
304304

305-
/* subdevice runflags */
306-
enum subdevice_runflags {
307-
SRF_RT = 0x00000002,
308-
/* indicates an COMEDI_CB_ERROR event has occurred since the last
309-
* command was started */
310-
SRF_ERROR = 0x00000004,
311-
SRF_RUNNING = 0x08000000,
312-
SRF_FREE_SPRIV = 0x80000000, /* free s->private on detach */
313-
};
305+
/**
306+
* comedi_subdevice "runflags"
307+
* @COMEDI_SRF_RT: DEPRECATED: command is running real-time
308+
* @COMEDI_SRF_ERROR: indicates an COMEDI_CB_ERROR event has occurred
309+
* since the last command was started
310+
* @COMEDI_SRF_RUNNING: command is running
311+
* @COMEDI_SRF_FREE_SPRIV: free s->private on detach
312+
*
313+
* @COMEDI_SRF_BUSY_MASK: runflags that indicate the subdevice is "busy"
314+
*/
315+
#define COMEDI_SRF_RT BIT(1)
316+
#define COMEDI_SRF_ERROR BIT(2)
317+
#define COMEDI_SRF_RUNNING BIT(27)
318+
#define COMEDI_SRF_FREE_SPRIV BIT(31)
319+
320+
#define COMEDI_SRF_BUSY_MASK (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING)
314321

315322
bool comedi_is_subdevice_running(struct comedi_subdevice *s);
316323

drivers/staging/comedi/drivers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev)
125125
if (dev->subdevices) {
126126
for (i = 0; i < dev->n_subdevices; i++) {
127127
s = &dev->subdevices[i];
128-
if (s->runflags & SRF_FREE_SPRIV)
128+
if (s->runflags & COMEDI_SRF_FREE_SPRIV)
129129
kfree(s->private);
130130
comedi_free_subdevice_minor(s);
131131
if (s->async) {

0 commit comments

Comments
 (0)