Commit bc252fd1 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: comedi_fops: fix a number of sizeof(struct foo) forms

As mentioned in CodingStyle, the prefered form is:

	p = kmalloc(sizeof(*p), ...);
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 76cca89f
...@@ -451,7 +451,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev, ...@@ -451,7 +451,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
return 0; return 0;
} }
if (copy_from_user(&it, arg, sizeof(struct comedi_devconfig))) if (copy_from_user(&it, arg, sizeof(it)))
return -EFAULT; return -EFAULT;
it.board_name[COMEDI_NAMELEN - 1] = 0; it.board_name[COMEDI_NAMELEN - 1] = 0;
...@@ -519,7 +519,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, ...@@ -519,7 +519,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev,
struct comedi_subdevice *s; struct comedi_subdevice *s;
int retval = 0; int retval = 0;
if (copy_from_user(&bc, arg, sizeof(struct comedi_bufconfig))) if (copy_from_user(&bc, arg, sizeof(bc)))
return -EFAULT; return -EFAULT;
if (bc.subdevice >= dev->n_subdevices || bc.subdevice < 0) if (bc.subdevice >= dev->n_subdevices || bc.subdevice < 0)
...@@ -552,7 +552,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, ...@@ -552,7 +552,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev,
bc.maximum_size = async->max_bufsize; bc.maximum_size = async->max_bufsize;
copyback: copyback:
if (copy_to_user(arg, &bc, sizeof(struct comedi_bufconfig))) if (copy_to_user(arg, &bc, sizeof(bc)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -601,7 +601,7 @@ static int do_devinfo_ioctl(struct comedi_device *dev, ...@@ -601,7 +601,7 @@ static int do_devinfo_ioctl(struct comedi_device *dev,
else else
devinfo.write_subdevice = -1; devinfo.write_subdevice = -1;
if (copy_to_user(arg, &devinfo, sizeof(struct comedi_devinfo))) if (copy_to_user(arg, &devinfo, sizeof(devinfo)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -628,9 +628,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, ...@@ -628,9 +628,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev,
struct comedi_subdinfo *tmp, *us; struct comedi_subdinfo *tmp, *us;
struct comedi_subdevice *s; struct comedi_subdevice *s;
tmp = tmp = kcalloc(dev->n_subdevices, sizeof(*tmp), GFP_KERNEL);
kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo),
GFP_KERNEL);
if (!tmp) if (!tmp)
return -ENOMEM; return -ENOMEM;
...@@ -681,8 +679,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, ...@@ -681,8 +679,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev,
us->settling_time_0 = s->settling_time_0; us->settling_time_0 = s->settling_time_0;
} }
ret = copy_to_user(arg, tmp, ret = copy_to_user(arg, tmp, dev->n_subdevices * sizeof(*tmp));
dev->n_subdevices * sizeof(struct comedi_subdinfo));
kfree(tmp); kfree(tmp);
...@@ -709,7 +706,7 @@ static int do_chaninfo_ioctl(struct comedi_device *dev, ...@@ -709,7 +706,7 @@ static int do_chaninfo_ioctl(struct comedi_device *dev,
struct comedi_subdevice *s; struct comedi_subdevice *s;
struct comedi_chaninfo it; struct comedi_chaninfo it;
if (copy_from_user(&it, arg, sizeof(struct comedi_chaninfo))) if (copy_from_user(&it, arg, sizeof(it)))
return -EFAULT; return -EFAULT;
if (it.subdev >= dev->n_subdevices) if (it.subdev >= dev->n_subdevices)
...@@ -776,7 +773,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, ...@@ -776,7 +773,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
struct comedi_subdevice *s; struct comedi_subdevice *s;
struct comedi_async *async; struct comedi_async *async;
if (copy_from_user(&bi, arg, sizeof(struct comedi_bufinfo))) if (copy_from_user(&bi, arg, sizeof(bi)))
return -EFAULT; return -EFAULT;
if (bi.subdevice >= dev->n_subdevices || bi.subdevice < 0) if (bi.subdevice >= dev->n_subdevices || bi.subdevice < 0)
...@@ -831,7 +828,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, ...@@ -831,7 +828,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
bi.buf_read_ptr = async->buf_read_ptr; bi.buf_read_ptr = async->buf_read_ptr;
copyback: copyback:
if (copy_to_user(arg, &bi, sizeof(struct comedi_bufinfo))) if (copy_to_user(arg, &bi, sizeof(bi)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -865,7 +862,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev, ...@@ -865,7 +862,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev,
int i = 0; int i = 0;
int ret = 0; int ret = 0;
if (copy_from_user(&insnlist, arg, sizeof(struct comedi_insnlist))) if (copy_from_user(&insnlist, arg, sizeof(insnlist)))
return -EFAULT; return -EFAULT;
data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL); data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL);
...@@ -875,8 +872,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev, ...@@ -875,8 +872,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev,
goto error; goto error;
} }
insns = insns = kcalloc(insnlist.n_insns, sizeof(*insns), GFP_KERNEL);
kcalloc(insnlist.n_insns, sizeof(struct comedi_insn), GFP_KERNEL);
if (!insns) { if (!insns) {
DPRINTK("kmalloc failed\n"); DPRINTK("kmalloc failed\n");
ret = -ENOMEM; ret = -ENOMEM;
...@@ -884,7 +880,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev, ...@@ -884,7 +880,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev,
} }
if (copy_from_user(insns, insnlist.insns, if (copy_from_user(insns, insnlist.insns,
sizeof(struct comedi_insn) * insnlist.n_insns)) { sizeof(*insns) * insnlist.n_insns)) {
DPRINTK("copy_from_user failed\n"); DPRINTK("copy_from_user failed\n");
ret = -EFAULT; ret = -EFAULT;
goto error; goto error;
...@@ -1185,7 +1181,7 @@ static int do_insn_ioctl(struct comedi_device *dev, ...@@ -1185,7 +1181,7 @@ static int do_insn_ioctl(struct comedi_device *dev,
goto error; goto error;
} }
if (copy_from_user(&insn, arg, sizeof(struct comedi_insn))) { if (copy_from_user(&insn, arg, sizeof(insn))) {
ret = -EFAULT; ret = -EFAULT;
goto error; goto error;
} }
...@@ -1229,7 +1225,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, ...@@ -1229,7 +1225,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
int ret = 0; int ret = 0;
unsigned int __user *user_chanlist; unsigned int __user *user_chanlist;
if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) { if (copy_from_user(&cmd, arg, sizeof(cmd))) {
DPRINTK("bad cmd address\n"); DPRINTK("bad cmd address\n");
return -EFAULT; return -EFAULT;
} }
...@@ -1319,7 +1315,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, ...@@ -1319,7 +1315,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
/* restore chanlist pointer before copying back */ /* restore chanlist pointer before copying back */
cmd.chanlist = (unsigned int __force *)user_chanlist; cmd.chanlist = (unsigned int __force *)user_chanlist;
cmd.data = NULL; cmd.data = NULL;
if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) { if (copy_to_user(arg, &cmd, sizeof(cmd))) {
DPRINTK("fault writing cmd\n"); DPRINTK("fault writing cmd\n");
ret = -EFAULT; ret = -EFAULT;
goto cleanup; goto cleanup;
...@@ -1378,7 +1374,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, ...@@ -1378,7 +1374,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
unsigned int *chanlist = NULL; unsigned int *chanlist = NULL;
unsigned int __user *user_chanlist; unsigned int __user *user_chanlist;
if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) { if (copy_from_user(&cmd, arg, sizeof(cmd))) {
DPRINTK("bad cmd address\n"); DPRINTK("bad cmd address\n");
return -EFAULT; return -EFAULT;
} }
...@@ -1442,7 +1438,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, ...@@ -1442,7 +1438,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
/* restore chanlist pointer before copying back */ /* restore chanlist pointer before copying back */
cmd.chanlist = (unsigned int __force *)user_chanlist; cmd.chanlist = (unsigned int __force *)user_chanlist;
if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) { if (copy_to_user(arg, &cmd, sizeof(cmd))) {
DPRINTK("bad cmd address\n"); DPRINTK("bad cmd address\n");
ret = -EFAULT; ret = -EFAULT;
goto cleanup; goto cleanup;
...@@ -2260,7 +2256,7 @@ EXPORT_SYMBOL(comedi_get_subdevice_runflags); ...@@ -2260,7 +2256,7 @@ EXPORT_SYMBOL(comedi_get_subdevice_runflags);
static void comedi_device_init(struct comedi_device *dev) static void comedi_device_init(struct comedi_device *dev)
{ {
memset(dev, 0, sizeof(struct comedi_device)); memset(dev, 0, sizeof(*dev));
spin_lock_init(&dev->spinlock); spin_lock_init(&dev->spinlock);
mutex_init(&dev->mutex); mutex_init(&dev->mutex);
dev->minor = -1; dev->minor = -1;
...@@ -2282,7 +2278,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) ...@@ -2282,7 +2278,7 @@ int comedi_alloc_board_minor(struct device *hardware_device)
struct device *csdev; struct device *csdev;
unsigned i; unsigned i;
info = kzalloc(sizeof(struct comedi_file_info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) if (info == NULL)
return -ENOMEM; return -ENOMEM;
info->device = kzalloc(sizeof(struct comedi_device), GFP_KERNEL); info->device = kzalloc(sizeof(struct comedi_device), GFP_KERNEL);
...@@ -2365,7 +2361,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, ...@@ -2365,7 +2361,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
struct device *csdev; struct device *csdev;
unsigned i; unsigned i;
info = kmalloc(sizeof(struct comedi_file_info), GFP_KERNEL); info = kmalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) if (info == NULL)
return -ENOMEM; return -ENOMEM;
info->device = dev; info->device = dev;
......
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