From ba311c0eac7e0eda6be52fe3c6d0dfd90b66907a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 17 Oct 2007 15:24:40 +0000 Subject: [PATCH] Replaced kmalloc/memset sequence with kzalloc or kcalloc. Removed call to memset after alloc_subdevices to avoid clobbering spinlocks. --- comedi/drivers/pcmmio.c | 5 +---- comedi/drivers/pcmuio.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/comedi/drivers/pcmmio.c b/comedi/drivers/pcmmio.c index 28b270da..2c493c79 100644 --- a/comedi/drivers/pcmmio.c +++ b/comedi/drivers/pcmmio.c @@ -366,12 +366,11 @@ static int pcmmio_attach(comedi_device *dev, comedi_devconfig *it) chans_left = CHANS_PER_ASIC * thisboard->dio_num_asics; n_dio_subdevs = CALC_N_DIO_SUBDEVS(chans_left); n_subdevs = n_dio_subdevs + 2; - devpriv->sprivs = (pcmmio_subdev_private *)kmalloc(sizeof(pcmmio_subdev_private) * n_subdevs, GFP_KERNEL); + devpriv->sprivs = kcalloc(n_subdevs, sizeof(pcmmio_subdev_private), GFP_KERNEL); if (!devpriv->sprivs) { printk("cannot allocate subdevice private data structures\n"); return -ENOMEM; } - memset(devpriv->sprivs, 0, sizeof(pcmmio_subdev_private) * n_subdevs); /* * Allocate the subdevice structures. alloc_subdevice() is a * convenient macro defined in comedidev.h. @@ -383,8 +382,6 @@ static int pcmmio_attach(comedi_device *dev, comedi_devconfig *it) return -ENOMEM; } - memset(dev->subdevices, 0, sizeof(*dev->subdevices) * n_subdevs); - /* First, AI */ sdev_no = 0; s = dev->subdevices + sdev_no; diff --git a/comedi/drivers/pcmuio.c b/comedi/drivers/pcmuio.c index 03d52abf..13b24462 100644 --- a/comedi/drivers/pcmuio.c +++ b/comedi/drivers/pcmuio.c @@ -331,12 +331,11 @@ static int pcmuio_attach(comedi_device *dev, comedi_devconfig *it) chans_left = CHANS_PER_ASIC * thisboard->num_asics; n_subdevs = CALC_N_SUBDEVS(chans_left); - devpriv->sprivs = (pcmuio_subdev_private *)kmalloc(sizeof(pcmuio_subdev_private) * n_subdevs, GFP_KERNEL); + devpriv->sprivs = kcalloc(n_subdevs, sizeof(pcmuio_subdev_private), GFP_KERNEL); if (!devpriv->sprivs) { printk("cannot allocate subdevice private data structures\n"); return -ENOMEM; } - memset(devpriv->sprivs, 0, sizeof(pcmuio_subdev_private) * n_subdevs); /* * Allocate the subdevice structures. alloc_subdevice() is a * convenient macro defined in comedidev.h. @@ -349,8 +348,6 @@ static int pcmuio_attach(comedi_device *dev, comedi_devconfig *it) return -ENOMEM; } - memset(dev->subdevices, 0, sizeof(*dev->subdevices) * n_subdevs); - port = 0; asic = 0; for (sdev_no = 0; sdev_no < (int)dev->n_subdevices; ++sdev_no) -- 2.26.2