Skip to content

Commit

Permalink
staging: comedi: avoid forward declarations
Browse files Browse the repository at this point in the history
Move a few functions and variables to avoid a couple of forward
declarations.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Apr 5, 2013
1 parent 8ab4ed6 commit d9740a0
Showing 1 changed file with 56 additions and 59 deletions.
115 changes: 56 additions & 59 deletions drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,62 @@ struct comedi_file_info {
static DEFINE_SPINLOCK(comedi_file_info_table_lock);
static struct comedi_file_info *comedi_file_info_table[COMEDI_NUM_MINORS];

static struct comedi_file_info *comedi_clear_minor(unsigned minor);
static void comedi_free_board_file_info(struct comedi_file_info *info);
static struct class *comedi_class;
static struct cdev comedi_cdev;

static void comedi_device_init(struct comedi_device *dev)
{
spin_lock_init(&dev->spinlock);
mutex_init(&dev->mutex);
dev->minor = -1;
}

static void comedi_device_cleanup(struct comedi_device *dev)
{
struct module *driver_module = NULL;

if (dev == NULL)
return;
mutex_lock(&dev->mutex);
if (dev->attached)
driver_module = dev->driver->module;
comedi_device_detach(dev);
while (dev->use_count > 0) {
if (driver_module)
module_put(driver_module);
module_put(THIS_MODULE);
dev->use_count--;
}
mutex_unlock(&dev->mutex);
mutex_destroy(&dev->mutex);
}

static struct comedi_file_info *comedi_clear_minor(unsigned minor)
{
struct comedi_file_info *info;

spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
comedi_file_info_table[minor] = NULL;
spin_unlock(&comedi_file_info_table_lock);
return info;
}

static void comedi_free_board_file_info(struct comedi_file_info *info)
{
if (info) {
struct comedi_device *dev = info->device;
if (dev) {
if (dev->class_dev) {
device_destroy(comedi_class,
MKDEV(COMEDI_MAJOR, dev->minor));
}
comedi_device_cleanup(dev);
kfree(dev);
}
kfree(info);
}
}

static struct comedi_file_info *comedi_file_info_from_minor(unsigned minor)
{
Expand Down Expand Up @@ -2212,9 +2266,6 @@ static const struct file_operations comedi_fops = {
.llseek = noop_llseek,
};

static struct class *comedi_class;
static struct cdev comedi_cdev;

void comedi_error(const struct comedi_device *dev, const char *s)
{
dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s);
Expand Down Expand Up @@ -2264,33 +2315,6 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
}
EXPORT_SYMBOL(comedi_event);

static void comedi_device_init(struct comedi_device *dev)
{
spin_lock_init(&dev->spinlock);
mutex_init(&dev->mutex);
dev->minor = -1;
}

static void comedi_device_cleanup(struct comedi_device *dev)
{
struct module *driver_module = NULL;

if (dev == NULL)
return;
mutex_lock(&dev->mutex);
if (dev->attached)
driver_module = dev->driver->module;
comedi_device_detach(dev);
while (dev->use_count > 0) {
if (driver_module)
module_put(driver_module);
module_put(THIS_MODULE);
dev->use_count--;
}
mutex_unlock(&dev->mutex);
mutex_destroy(&dev->mutex);
}

/* Note: the ->mutex is pre-locked on successful return */
struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
{
Expand Down Expand Up @@ -2339,33 +2363,6 @@ struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
return dev;
}

static struct comedi_file_info *comedi_clear_minor(unsigned minor)
{
struct comedi_file_info *info;

spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
comedi_file_info_table[minor] = NULL;
spin_unlock(&comedi_file_info_table_lock);
return info;
}

static void comedi_free_board_file_info(struct comedi_file_info *info)
{
if (info) {
struct comedi_device *dev = info->device;
if (dev) {
if (dev->class_dev) {
device_destroy(comedi_class,
MKDEV(COMEDI_MAJOR, dev->minor));
}
comedi_device_cleanup(dev);
kfree(dev);
}
kfree(info);
}
}

static void comedi_free_board_minor(unsigned minor)
{
BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
Expand Down

0 comments on commit d9740a0

Please sign in to comment.