Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7f2aa34 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e55c95a3
Loading
Loading
Loading
Loading
+80 −66
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@
*/
/*
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:
Author: ds
Updated: Mon, 10 Oct 00:18:25 -0500
@@ -102,18 +103,23 @@ MODULE_LICENSE("GPL");
#  define STR(x) STR1(x)
#endif

int debug = 0;
int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug,
	"If true, print extra cryptic debugging output useful only to developers probably.");
MODULE_PARM_DESC(debug, "If true, print extra cryptic debugging output useful"
		 "only to developers.");

#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 ERROR(x...)  printk(KERN_ERR MODULE_NAME ": INTERNAL ERROR: "x)
MODULE_AUTHOR("Calin A. Culianu");
MODULE_DESCRIPTION(MODULE_NAME
	": 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...'");
MODULE_DESCRIPTION(MODULE_NAME "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...'");

/*
 * Board descriptions for two imaginary boards.  Describing the
@@ -127,7 +133,7 @@ typedef struct BondingBoard BondingBoard;

static const BondingBoard bondingBoards[] = {
	{
	      name:	MODULE_NAME,
		.name =	MODULE_NAME,
	},
};

@@ -142,8 +148,9 @@ struct BondedDevice {
	unsigned subdev;
	unsigned subdev_type;
	unsigned nchans;
	unsigned chanid_offset;	/* The offset into our unified linear channel-id's
				   of chanid 0 on this subdevice. */
	unsigned chanid_offset;	/* The offset into our unified linear
				   channel-id's of chanid 0 on this
				   subdevice. */
};
typedef struct BondedDevice BondedDevice;

@@ -177,14 +184,15 @@ static int bonding_detach(comedi_device * dev);
/** Build Private array of all devices.. */
static int doDevConfig(comedi_device *dev, comedi_devconfig *it);
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 comedi_driver driver_bonding = {
      driver_name:MODULE_NAME,
      module:THIS_MODULE,
      attach:bonding_attach,
      detach:bonding_detach,
      .driver_name =	MODULE_NAME,
      .module =		THIS_MODULE,
      .attach =		bonding_attach,
      .detach =		bonding_detach,
	/* It is not necessary to implement the following members if you are
	 * writing a driver for a ISA PnP or PCI card */
	/* 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
	 * devices are such boards.
	 */
      board_name:&bondingBoards[0].name,
      offset:sizeof(BondingBoard),
      num_names:sizeof(bondingBoards) / sizeof(BondingBoard),
      .board_name =	&bondingBoards[0].name,
      .offset =		sizeof(BondingBoard),
      .num_names =	sizeof(bondingBoards) / sizeof(BondingBoard),
};

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_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;
}
@@ -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
		   to this subdevice.. need to shift them to zero position of
		   course. */
		lsampl_t subdevMask = ((1 << bdev->nchans) - 1);	/* Bits corresponding
									   to this subdev. */
		/* Bits corresponding to this subdev. */
		lsampl_t subdevMask = ((1 << bdev->nchans) - 1);
		lsampl_t writeMask, dataBits;

		/* 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;
		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);
	if (ret != 1)
		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)
{
#define MIN(a,b) (a < b ? a : b)
	void *newmem = kmalloc(newlen, GFP_KERNEL);

	if (newmem && oldmem)
		memcpy(newmem, oldmem, MIN(oldlen, newlen));
	if (oldmem)
		memcpy(newmem, oldmem, min(oldlen, newlen));
	kfree(oldmem);
	return newmem;
}
@@ -428,8 +439,11 @@ static int doDevConfig(comedi_device * dev, comedi_devconfig * it)
		/* Do DIO, as that's all we support now.. */
		while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO,
					sdev + 1)) > -1) {
			if ((nchans = comedi_get_n_channels(d, sdev)) <= 0) {
				ERROR("comedi_get_n_channels() returned %d on minor %u subdev %d!\n", nchans, minor, sdev);
			nchans = comedi_get_n_channels(d, sdev);
			if (nchans <= 0) {
				ERROR("comedi_get_n_channels() returned %d "
				      "on minor %u subdev %d!\n",
				      nchans, minor, sdev);
				return 0;
			}
			bdev = kmalloc(sizeof(*bdev), GFP_KERNEL);
@@ -448,7 +462,8 @@ static int doDevConfig(comedi_device * dev, comedi_devconfig * it)
			while (nchans--)
				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 :(  */
			tmp = devpriv->ndevs * sizeof(bdev);
@@ -456,7 +471,8 @@ static int doDevConfig(comedi_device * dev, comedi_devconfig * it)
				Realloc(devpriv->devs,
				++devpriv->ndevs * sizeof(bdev), tmp);
			if (!devpriv->devs) {
				ERROR("Could not allocate memory. Out of memory?");
				ERROR("Could not allocate memory. "
				      "Out of memory?");
				return 0;
			}

@@ -499,10 +515,8 @@ static void doDevUnconfig(comedi_device * dev)
			}
			kfree(bdev);
		}
		if (devpriv->devs) {
		kfree(devpriv->devs);
		devpriv->devs = 0;
		}
		kfree(devpriv);
		dev->private = 0;
	}