Commit 4f870fe6 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: replace printk calls in comedi core

Replace the printk() calls in the comedi core module with something more
suitable, such as dev_...() or pr_...().  Remove the ones that report a
failure to increment a module count (try_module_get() failure).  Change
the printk() call in the DPRINTK() macro to pr_debug().

TODO: Most of the DPRINTK() calls need to be replaced with something
else.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 00255d19
...@@ -882,14 +882,12 @@ static int check_insn_config_length(struct comedi_insn *insn, ...@@ -882,14 +882,12 @@ static int check_insn_config_length(struct comedi_insn *insn,
/* by default we allow the insn since we don't have checks for /* by default we allow the insn since we don't have checks for
* all possible cases yet */ * all possible cases yet */
default: default:
printk(KERN_WARNING pr_warn("comedi: No check for data length of config insn id %i is implemented.\n",
"comedi: no check for data length of config insn id " data[0]);
"%i is implemented.\n" pr_warn("comedi: Add a check to %s in %s.\n",
" Add a check to %s in %s.\n" __func__, __FILE__);
" Assuming n=%i is correct.\n", data[0], __func__, pr_warn("comedi: Assuming n=%i is correct.\n", insn->n);
__FILE__, insn->n);
return 0; return 0;
break;
} }
return -EINVAL; return -EINVAL;
} }
...@@ -2034,8 +2032,8 @@ void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -2034,8 +2032,8 @@ void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s)
comedi_reset_async_buf(async); comedi_reset_async_buf(async);
async->inttrig = NULL; async->inttrig = NULL;
} else { } else {
printk(KERN_ERR dev_err(dev->class_dev,
"BUG: (?) do_become_nonbusy called with async=0\n"); "BUG: (?) do_become_nonbusy called with async=NULL\n");
} }
s->busy = NULL; s->busy = NULL;
...@@ -2211,14 +2209,12 @@ static int __init comedi_init(void) ...@@ -2211,14 +2209,12 @@ static int __init comedi_init(void)
int i; int i;
int retval; int retval;
printk(KERN_INFO "comedi: version " COMEDI_RELEASE pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n");
" - http://www.comedi.org\n");
if (comedi_num_legacy_minors < 0 || if (comedi_num_legacy_minors < 0 ||
comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) { comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
printk(KERN_ERR "comedi: error: invalid value for module " pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\". Valid values are 0 through %i.\n",
"parameter \"comedi_num_legacy_minors\". Valid values " COMEDI_NUM_BOARD_MINORS);
"are 0 through %i.\n", COMEDI_NUM_BOARD_MINORS);
return -EINVAL; return -EINVAL;
} }
...@@ -2247,7 +2243,7 @@ static int __init comedi_init(void) ...@@ -2247,7 +2243,7 @@ static int __init comedi_init(void)
} }
comedi_class = class_create(THIS_MODULE, "comedi"); comedi_class = class_create(THIS_MODULE, "comedi");
if (IS_ERR(comedi_class)) { if (IS_ERR(comedi_class)) {
printk(KERN_ERR "comedi: failed to create class"); pr_err("comedi: failed to create class\n");
cdev_del(&comedi_cdev); cdev_del(&comedi_cdev);
unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
COMEDI_NUM_MINORS); COMEDI_NUM_MINORS);
...@@ -2295,8 +2291,7 @@ module_exit(comedi_cleanup); ...@@ -2295,8 +2291,7 @@ module_exit(comedi_cleanup);
void comedi_error(const struct comedi_device *dev, const char *s) void comedi_error(const struct comedi_device *dev, const char *s)
{ {
printk(KERN_ERR "comedi%d: %s: %s\n", dev->minor, dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s);
dev->driver->driver_name, s);
} }
EXPORT_SYMBOL(comedi_error); EXPORT_SYMBOL(comedi_error);
...@@ -2420,9 +2415,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) ...@@ -2420,9 +2415,7 @@ int comedi_alloc_board_minor(struct device *hardware_device)
comedi_device_cleanup(info->device); comedi_device_cleanup(info->device);
kfree(info->device); kfree(info->device);
kfree(info); kfree(info);
printk(KERN_ERR pr_err("comedi: error: ran out of minor numbers for board device files.\n");
"comedi: error: "
"ran out of minor numbers for board device files.\n");
return -EBUSY; return -EBUSY;
} }
info->device->minor = i; info->device->minor = i;
...@@ -2499,9 +2492,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, ...@@ -2499,9 +2492,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
spin_unlock(&comedi_file_info_table_lock); spin_unlock(&comedi_file_info_table_lock);
if (i == COMEDI_NUM_MINORS) { if (i == COMEDI_NUM_MINORS) {
kfree(info); kfree(info);
printk(KERN_ERR pr_err("comedi: error: ran out of minor numbers for board device files.\n");
"comedi: error: "
"ran out of minor numbers for board device files.\n");
return -EBUSY; return -EBUSY;
} }
s->minor = i; s->minor = i;
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define DPRINTK(format, args...) do { \ #define DPRINTK(format, args...) do { \
if (comedi_debug) \ if (comedi_debug) \
printk(KERN_DEBUG "comedi: " format , ## args); \ pr_debug("comedi: " format, ## args); \
} while (0) } while (0)
#define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) #define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
......
...@@ -119,8 +119,8 @@ static void __comedi_device_detach(struct comedi_device *dev) ...@@ -119,8 +119,8 @@ static void __comedi_device_detach(struct comedi_device *dev)
if (dev->driver) if (dev->driver)
dev->driver->detach(dev); dev->driver->detach(dev);
else else
printk(KERN_WARNING dev_warn(dev->class_dev,
"BUG: dev->driver=NULL in comedi_device_detach()\n"); "BUG: dev->driver=NULL in comedi_device_detach()\n");
cleanup_device(dev); cleanup_device(dev);
} }
...@@ -142,8 +142,7 @@ static int comedi_device_postconfig(struct comedi_device *dev) ...@@ -142,8 +142,7 @@ static int comedi_device_postconfig(struct comedi_device *dev)
return ret; return ret;
} }
if (!dev->board_name) { if (!dev->board_name) {
printk(KERN_WARNING "BUG: dev->board_name=<%p>\n", dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n");
dev->board_name);
dev->board_name = "BUG"; dev->board_name = "BUG";
} }
smp_wmb(); smp_wmb();
...@@ -161,7 +160,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -161,7 +160,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (driv = comedi_drivers; driv; driv = driv->next) { for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) { if (!try_module_get(driv->module)) {
printk(KERN_INFO "comedi: failed to increment module count, skipping\n");
continue; continue;
} }
if (driv->num_names) { if (driv->num_names) {
...@@ -177,8 +175,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -177,8 +175,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* report valid board names before returning error */ /* report valid board names before returning error */
for (driv = comedi_drivers; driv; driv = driv->next) { for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) { if (!try_module_get(driv->module)) {
printk(KERN_INFO
"comedi: failed to increment module count\n");
continue; continue;
} }
comedi_report_boards(driv); comedi_report_boards(driv);
...@@ -233,8 +229,9 @@ int comedi_driver_unregister(struct comedi_driver *driver) ...@@ -233,8 +229,9 @@ int comedi_driver_unregister(struct comedi_driver *driver)
mutex_lock(&dev->mutex); mutex_lock(&dev->mutex);
if (dev->attached && dev->driver == driver) { if (dev->attached && dev->driver == driver) {
if (dev->use_count) if (dev->use_count)
printk(KERN_WARNING "BUG! detaching device with use_count=%d\n", dev_warn(dev->class_dev,
dev->use_count); "BUG! detaching device with use_count=%d\n",
dev->use_count);
comedi_device_detach(dev); comedi_device_detach(dev);
} }
mutex_unlock(&dev->mutex); mutex_unlock(&dev->mutex);
...@@ -281,8 +278,8 @@ static int postconfig(struct comedi_device *dev) ...@@ -281,8 +278,8 @@ static int postconfig(struct comedi_device *dev)
async = async =
kzalloc(sizeof(struct comedi_async), GFP_KERNEL); kzalloc(sizeof(struct comedi_async), GFP_KERNEL);
if (async == NULL) { if (async == NULL) {
printk(KERN_INFO dev_warn(dev->class_dev,
"failed to allocate async struct\n"); "failed to allocate async struct\n");
return -ENOMEM; return -ENOMEM;
} }
init_waitqueue_head(&async->wait_head); init_waitqueue_head(&async->wait_head);
...@@ -298,7 +295,8 @@ static int postconfig(struct comedi_device *dev) ...@@ -298,7 +295,8 @@ static int postconfig(struct comedi_device *dev)
async->prealloc_buf = NULL; async->prealloc_buf = NULL;
async->prealloc_bufsz = 0; async->prealloc_bufsz = 0;
if (comedi_buf_alloc(dev, s, buf_size) < 0) { if (comedi_buf_alloc(dev, s, buf_size) < 0) {
printk(KERN_INFO "Buffer allocation failed\n"); dev_warn(dev->class_dev,
"Buffer allocation failed\n");
return -ENOMEM; return -ENOMEM;
} }
if (s->buf_change) { if (s->buf_change) {
...@@ -378,17 +376,17 @@ static void comedi_report_boards(struct comedi_driver *driv) ...@@ -378,17 +376,17 @@ static void comedi_report_boards(struct comedi_driver *driv)
unsigned int i; unsigned int i;
const char *const *name_ptr; const char *const *name_ptr;
printk(KERN_INFO "comedi: valid board names for %s driver are:\n", pr_info("comedi: valid board names for %s driver are:\n",
driv->driver_name); driv->driver_name);
name_ptr = driv->board_name; name_ptr = driv->board_name;
for (i = 0; i < driv->num_names; i++) { for (i = 0; i < driv->num_names; i++) {
printk(KERN_INFO " %s\n", *name_ptr); pr_info(" %s\n", *name_ptr);
name_ptr = (const char **)((char *)name_ptr + driv->offset); name_ptr = (const char **)((char *)name_ptr + driv->offset);
} }
if (driv->num_names == 0) if (driv->num_names == 0)
printk(KERN_INFO " %s\n", driv->driver_name); pr_info(" %s\n", driv->driver_name);
} }
static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s)
...@@ -592,9 +590,9 @@ static unsigned int comedi_buf_munge(struct comedi_async *async, ...@@ -592,9 +590,9 @@ static unsigned int comedi_buf_munge(struct comedi_async *async,
block_size = num_bytes - count; block_size = num_bytes - count;
if (block_size < 0) { if (block_size < 0) {
printk(KERN_WARNING dev_warn(s->device->class_dev,
"%s: %s: bug! block_size is negative\n", "%s: %s: bug! block_size is negative\n",
__FILE__, __func__); __FILE__, __func__);
break; break;
} }
if ((int)(async->munge_ptr + block_size - if ((int)(async->munge_ptr + block_size -
...@@ -675,7 +673,8 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes) ...@@ -675,7 +673,8 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
{ {
if ((int)(async->buf_write_count + nbytes - if ((int)(async->buf_write_count + nbytes -
async->buf_write_alloc_count) > 0) { async->buf_write_alloc_count) > 0) {
printk(KERN_INFO "comedi: attempted to write-free more bytes than have been write-allocated.\n"); dev_info(async->subdevice->device->class_dev,
"attempted to write-free more bytes than have been write-allocated.\n");
nbytes = async->buf_write_alloc_count - async->buf_write_count; nbytes = async->buf_write_alloc_count - async->buf_write_count;
} }
async->buf_write_count += nbytes; async->buf_write_count += nbytes;
...@@ -711,8 +710,8 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) ...@@ -711,8 +710,8 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
smp_mb(); smp_mb();
if ((int)(async->buf_read_count + nbytes - if ((int)(async->buf_read_count + nbytes -
async->buf_read_alloc_count) > 0) { async->buf_read_alloc_count) > 0) {
printk(KERN_INFO dev_info(async->subdevice->device->class_dev,
"comedi: attempted to read-free more bytes than have been read-allocated.\n"); "attempted to read-free more bytes than have been read-allocated.\n");
nbytes = async->buf_read_alloc_count - async->buf_read_count; nbytes = async->buf_read_alloc_count - async->buf_read_count;
} }
async->buf_read_count += nbytes; async->buf_read_count += nbytes;
...@@ -861,10 +860,9 @@ comedi_auto_config_helper(struct device *hardware_device, ...@@ -861,10 +860,9 @@ comedi_auto_config_helper(struct device *hardware_device,
mutex_lock(&comedi_dev->mutex); mutex_lock(&comedi_dev->mutex);
if (comedi_dev->attached) if (comedi_dev->attached)
ret = -EBUSY; ret = -EBUSY;
else if (!try_module_get(driver->module)) { else if (!try_module_get(driver->module))
printk(KERN_INFO "comedi: failed to increment module count\n");
ret = -EIO; ret = -EIO;
} else { else {
/* set comedi_dev->driver here for attach wrapper */ /* set comedi_dev->driver here for attach wrapper */
comedi_dev->driver = driver; comedi_dev->driver = driver;
ret = (*attach_wrapper)(comedi_dev, context); ret = (*attach_wrapper)(comedi_dev, context);
...@@ -892,17 +890,17 @@ static int comedi_auto_config_wrapper(struct comedi_device *dev, void *context) ...@@ -892,17 +890,17 @@ static int comedi_auto_config_wrapper(struct comedi_device *dev, void *context)
* has already been copied to it->board_name */ * has already been copied to it->board_name */
dev->board_ptr = comedi_recognize(driv, it->board_name); dev->board_ptr = comedi_recognize(driv, it->board_name);
if (dev->board_ptr == NULL) { if (dev->board_ptr == NULL) {
printk(KERN_WARNING dev_warn(dev->class_dev,
"comedi: auto config failed to find board entry '%s' for driver '%s'\n", "auto config failed to find board entry '%s' for driver '%s'\n",
it->board_name, driv->driver_name); it->board_name, driv->driver_name);
comedi_report_boards(driv); comedi_report_boards(driv);
return -EINVAL; return -EINVAL;
} }
} }
if (!driv->attach) { if (!driv->attach) {
printk(KERN_WARNING dev_warn(dev->class_dev,
"comedi: BUG! driver '%s' using old-style auto config but has no attach handler\n", "BUG! driver '%s' using old-style auto config but has no attach handler\n",
driv->driver_name); driv->driver_name);
return -EINVAL; return -EINVAL;
} }
return driv->attach(dev, it); return driv->attach(dev, it);
......
...@@ -131,6 +131,7 @@ static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec) ...@@ -131,6 +131,7 @@ static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec)
int comedi_check_chanlist(struct comedi_subdevice *s, int n, int comedi_check_chanlist(struct comedi_subdevice *s, int n,
unsigned int *chanlist) unsigned int *chanlist)
{ {
struct comedi_device *dev = s->device;
int i; int i;
int chan; int chan;
...@@ -139,10 +140,10 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, ...@@ -139,10 +140,10 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n,
if (CR_CHAN(chanlist[i]) >= s->n_chan || if (CR_CHAN(chanlist[i]) >= s->n_chan ||
CR_RANGE(chanlist[i]) >= s->range_table->length CR_RANGE(chanlist[i]) >= s->range_table->length
|| aref_invalid(s, chanlist[i])) { || aref_invalid(s, chanlist[i])) {
printk(KERN_ERR "bad chanlist[%d]=0x%08x " dev_warn(dev->class_dev,
"in_chan=%d range length=%d\n", i, "bad chanlist[%d]=0x%08x in_chan=%d range length=%d\n",
chanlist[i], s->n_chan, i, chanlist[i], s->n_chan,
s->range_table->length); s->range_table->length);
return -EINVAL; return -EINVAL;
} }
} else if (s->range_table_list) { } else if (s->range_table_list) {
...@@ -152,13 +153,14 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, ...@@ -152,13 +153,14 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n,
CR_RANGE(chanlist[i]) >= CR_RANGE(chanlist[i]) >=
s->range_table_list[chan]->length s->range_table_list[chan]->length
|| aref_invalid(s, chanlist[i])) { || aref_invalid(s, chanlist[i])) {
printk(KERN_ERR "bad chanlist[%d]=0x%08x\n", dev_warn(dev->class_dev,
i, chanlist[i]); "bad chanlist[%d]=0x%08x\n",
i, chanlist[i]);
return -EINVAL; return -EINVAL;
} }
} }
} else { } else {
printk(KERN_ERR "comedi: (bug) no range type list!\n"); dev_err(dev->class_dev, "(bug) no range type list!\n");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment