From 7d32eb1e9066ac1bafdaa9cc06853874384bd07a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 4 Apr 2013 14:59:18 +0100 Subject: [PATCH] --- yaml --- r: 363931 b: refs/heads/master c: db210da268ec537f8944ea5bc490184a6707c8a2 h: refs/heads/master i: 363929: bc0043c6424403ffe8736eca1c667c0d4667320b 363927: 98b2e04b8af30a72ef8a24821b2d7ba3b9d08cbb v: v3 --- [refs] | 2 +- trunk/drivers/staging/comedi/comedi_fops.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index fb20cb8c3c6e..42c81ed694ff 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c6f5b4d587a46fc0713cecc30ef3993c59b7e41e +refs/heads/master: db210da268ec537f8944ea5bc490184a6707c8a2 diff --git a/trunk/drivers/staging/comedi/comedi_fops.c b/trunk/drivers/staging/comedi/comedi_fops.c index b5e4bf1373e2..dec04b9b025e 100644 --- a/trunk/drivers/staging/comedi/comedi_fops.c +++ b/trunk/drivers/staging/comedi/comedi_fops.c @@ -120,6 +120,20 @@ static void comedi_device_cleanup(struct comedi_device *dev) mutex_destroy(&dev->mutex); } +static bool comedi_clear_board_dev(struct comedi_device *dev) +{ + unsigned int i = dev->minor; + bool cleared = false; + + mutex_lock(&comedi_board_minor_table_lock); + if (dev == comedi_board_minor_table[i]) { + comedi_board_minor_table[i] = NULL; + cleared = true; + } + mutex_unlock(&comedi_board_minor_table_lock); + return cleared; +} + static struct comedi_device *comedi_clear_board_minor(unsigned minor) { struct comedi_device *dev; @@ -1766,9 +1780,7 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, dev->minor >= comedi_num_legacy_minors) { /* Successfully unconfigured a dynamically * allocated device. Try and remove it. */ - struct comedi_device *devr; - devr = comedi_clear_board_minor(dev->minor); - if (dev == devr) { + if (comedi_clear_board_dev(dev)) { mutex_unlock(&dev->mutex); comedi_free_board_dev(dev); return rc;