Staging: comedi: fix checkpatch.pl issues in comedi_bond.c

This fixes a number of the issues found by checkpatch.pl in the
comedi_bond.c file.

Cc: Calin A. Culianu <calin@ajvar.org>
Cc: David Schleef <ds@schleef.org>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2008-11-19 09:58:28 -08:00
parent e55c95a3be
commit e7f2aa3455

View file

@ -23,7 +23,8 @@
*/ */
/* /*
Driver: comedi_bond Driver: comedi_bond
Description: A driver to 'bond' (merge) multiple subdevices from multiple devices together as one. Description: A driver to 'bond' (merge) multiple subdevices from multiple
devices together as one.
Devices: Devices:
Author: ds Author: ds
Updated: Mon, 10 Oct 00:18:25 -0500 Updated: Mon, 10 Oct 00:18:25 -0500
@ -102,18 +103,23 @@ MODULE_LICENSE("GPL");
# define STR(x) STR1(x) # define STR(x) STR1(x)
#endif #endif
int debug = 0; int debug;
module_param(debug, int, 0644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, MODULE_PARM_DESC(debug, "If true, print extra cryptic debugging output useful"
"If true, print extra cryptic debugging output useful only to developers probably."); "only to developers.");
#define LOG_MSG(x...) printk(KERN_INFO MODULE_NAME": "x) #define LOG_MSG(x...) printk(KERN_INFO MODULE_NAME": "x)
#define DEBUG(x...) do { if(debug) printk(KERN_DEBUG MODULE_NAME": DEBUG: "x); } while(0) #define DEBUG(x...) \
do { \
if (debug) \
printk(KERN_DEBUG MODULE_NAME": DEBUG: "x); \
} while (0)
#define WARNING(x...) printk(KERN_WARNING MODULE_NAME ": WARNING: "x) #define WARNING(x...) printk(KERN_WARNING MODULE_NAME ": WARNING: "x)
#define ERROR(x...) printk(KERN_ERR MODULE_NAME ": INTERNAL ERROR: "x) #define ERROR(x...) printk(KERN_ERR MODULE_NAME ": INTERNAL ERROR: "x)
MODULE_AUTHOR("Calin A. Culianu"); MODULE_AUTHOR("Calin A. Culianu");
MODULE_DESCRIPTION(MODULE_NAME MODULE_DESCRIPTION(MODULE_NAME "A driver for COMEDI to bond multiple COMEDI "
": A driver for COMEDI to bond multiple COMEDI devices together as one. In the words of John Lennon: 'And the world will live as one...'"); "devices together as one. In the words of John Lennon: "
"'And the world will live as one...'");
/* /*
* Board descriptions for two imaginary boards. Describing the * Board descriptions for two imaginary boards. Describing the
@ -127,7 +133,7 @@ typedef struct BondingBoard BondingBoard;
static const BondingBoard bondingBoards[] = { static const BondingBoard bondingBoards[] = {
{ {
name: MODULE_NAME, .name = MODULE_NAME,
}, },
}; };
@ -142,8 +148,9 @@ struct BondedDevice {
unsigned subdev; unsigned subdev;
unsigned subdev_type; unsigned subdev_type;
unsigned nchans; unsigned nchans;
unsigned chanid_offset; /* The offset into our unified linear channel-id's unsigned chanid_offset; /* The offset into our unified linear
of chanid 0 on this subdevice. */ channel-id's of chanid 0 on this
subdevice. */
}; };
typedef struct BondedDevice BondedDevice; typedef struct BondedDevice BondedDevice;
@ -177,14 +184,15 @@ static int bonding_detach(comedi_device * dev);
/** Build Private array of all devices.. */ /** Build Private array of all devices.. */
static int doDevConfig(comedi_device *dev, comedi_devconfig *it); static int doDevConfig(comedi_device *dev, comedi_devconfig *it);
static void doDevUnconfig(comedi_device *dev); static void doDevUnconfig(comedi_device *dev);
/* Ugly implementation of realloc that always copies memory around -- I'm lazy, what can I say? I like to do wasteful memcopies.. :) */ /* Ugly implementation of realloc that always copies memory around -- I'm lazy,
* what can I say? I like to do wasteful memcopies.. :) */
static void *Realloc(const void *ptr, size_t len, size_t old_len); static void *Realloc(const void *ptr, size_t len, size_t old_len);
static comedi_driver driver_bonding = { static comedi_driver driver_bonding = {
driver_name:MODULE_NAME, .driver_name = MODULE_NAME,
module:THIS_MODULE, .module = THIS_MODULE,
attach:bonding_attach, .attach = bonding_attach,
detach:bonding_detach, .detach = bonding_detach,
/* It is not necessary to implement the following members if you are /* It is not necessary to implement the following members if you are
* writing a driver for a ISA PnP or PCI card */ * writing a driver for a ISA PnP or PCI card */
/* Most drivers will support multiple types of boards by /* Most drivers will support multiple types of boards by
@ -203,9 +211,9 @@ static comedi_driver driver_bonding = {
* the type of board in software. ISA PnP, PCI, and PCMCIA * the type of board in software. ISA PnP, PCI, and PCMCIA
* devices are such boards. * devices are such boards.
*/ */
board_name:&bondingBoards[0].name, .board_name = &bondingBoards[0].name,
offset:sizeof(BondingBoard), .offset = sizeof(BondingBoard),
num_names:sizeof(bondingBoards) / sizeof(BondingBoard), .num_names = sizeof(bondingBoards) / sizeof(BondingBoard),
}; };
static int bonding_dio_insn_bits(comedi_device *dev, comedi_subdevice *s, static int bonding_dio_insn_bits(comedi_device *dev, comedi_subdevice *s,
@ -260,7 +268,10 @@ static int bonding_attach(comedi_device * dev, comedi_devconfig * it)
s->insn_bits = bonding_dio_insn_bits; s->insn_bits = bonding_dio_insn_bits;
s->insn_config = bonding_dio_insn_config; s->insn_config = bonding_dio_insn_config;
LOG_MSG("attached with %u DIO channels coming from %u different subdevices all bonded together. John Lennon would be proud!\n", devpriv->nchans, devpriv->ndevs); LOG_MSG("attached with %u DIO channels coming from %u different "
"subdevices all bonded together. "
"John Lennon would be proud!\n",
devpriv->nchans, devpriv->ndevs);
return 1; return 1;
} }
@ -303,8 +314,8 @@ static int bonding_dio_insn_bits(comedi_device * dev, comedi_subdevice * s,
/* Grab the channel mask and data of only the bits corresponding /* Grab the channel mask and data of only the bits corresponding
to this subdevice.. need to shift them to zero position of to this subdevice.. need to shift them to zero position of
course. */ course. */
lsampl_t subdevMask = ((1 << bdev->nchans) - 1); /* Bits corresponding /* Bits corresponding to this subdev. */
to this subdev. */ lsampl_t subdevMask = ((1 << bdev->nchans) - 1);
lsampl_t writeMask, dataBits; lsampl_t writeMask, dataBits;
/* Argh, we have >= LSAMPL_BITS chans.. take all bits */ /* Argh, we have >= LSAMPL_BITS chans.. take all bits */
@ -365,7 +376,8 @@ static int bonding_dio_insn_config(comedi_device * dev, comedi_subdevice * s,
return -EINVAL; return -EINVAL;
break; break;
} }
chan -= bdev->chanid_offset; /* 'real' channel id for this subdev.. */ /* 'real' channel id for this subdev.. */
chan -= bdev->chanid_offset;
ret = comedi_dio_config(bdev->dev, bdev->subdev, chan, io); ret = comedi_dio_config(bdev->dev, bdev->subdev, chan, io);
if (ret != 1) if (ret != 1)
return -EINVAL; return -EINVAL;
@ -377,11 +389,10 @@ static int bonding_dio_insn_config(comedi_device * dev, comedi_subdevice * s,
static void *Realloc(const void *oldmem, size_t newlen, size_t oldlen) static void *Realloc(const void *oldmem, size_t newlen, size_t oldlen)
{ {
#define MIN(a,b) (a < b ? a : b)
void *newmem = kmalloc(newlen, GFP_KERNEL); void *newmem = kmalloc(newlen, GFP_KERNEL);
if (newmem && oldmem) if (newmem && oldmem)
memcpy(newmem, oldmem, MIN(oldlen, newlen)); memcpy(newmem, oldmem, min(oldlen, newlen));
if (oldmem)
kfree(oldmem); kfree(oldmem);
return newmem; return newmem;
} }
@ -428,8 +439,11 @@ static int doDevConfig(comedi_device * dev, comedi_devconfig * it)
/* Do DIO, as that's all we support now.. */ /* Do DIO, as that's all we support now.. */
while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO, while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO,
sdev + 1)) > -1) { sdev + 1)) > -1) {
if ((nchans = comedi_get_n_channels(d, sdev)) <= 0) { nchans = comedi_get_n_channels(d, sdev);
ERROR("comedi_get_n_channels() returned %d on minor %u subdev %d!\n", nchans, minor, sdev); if (nchans <= 0) {
ERROR("comedi_get_n_channels() returned %d "
"on minor %u subdev %d!\n",
nchans, minor, sdev);
return 0; return 0;
} }
bdev = kmalloc(sizeof(*bdev), GFP_KERNEL); bdev = kmalloc(sizeof(*bdev), GFP_KERNEL);
@ -448,7 +462,8 @@ static int doDevConfig(comedi_device * dev, comedi_devconfig * it)
while (nchans--) while (nchans--)
devpriv->chanIdDevMap[devpriv->nchans++] = bdev; devpriv->chanIdDevMap[devpriv->nchans++] = bdev;
/* Now put bdev pointer at end of devpriv->devs array list.. */ /* Now put bdev pointer at end of devpriv->devs array
* list.. */
/* ergh.. ugly.. we need to realloc :( */ /* ergh.. ugly.. we need to realloc :( */
tmp = devpriv->ndevs * sizeof(bdev); tmp = devpriv->ndevs * sizeof(bdev);
@ -456,7 +471,8 @@ static int doDevConfig(comedi_device * dev, comedi_devconfig * it)
Realloc(devpriv->devs, Realloc(devpriv->devs,
++devpriv->ndevs * sizeof(bdev), tmp); ++devpriv->ndevs * sizeof(bdev), tmp);
if (!devpriv->devs) { if (!devpriv->devs) {
ERROR("Could not allocate memory. Out of memory?"); ERROR("Could not allocate memory. "
"Out of memory?");
return 0; return 0;
} }
@ -499,10 +515,8 @@ static void doDevUnconfig(comedi_device * dev)
} }
kfree(bdev); kfree(bdev);
} }
if (devpriv->devs) {
kfree(devpriv->devs); kfree(devpriv->devs);
devpriv->devs = 0; devpriv->devs = 0;
}
kfree(devpriv); kfree(devpriv);
dev->private = 0; dev->private = 0;
} }