You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[PATCH] USB: kzalloc() conversion for rest of drivers/usb
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d54a5cb648
commit
80b6ca4832
@@ -220,13 +220,9 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
|
||||
ehci->periodic [i] = EHCI_LIST_END;
|
||||
|
||||
/* software shadow of hardware table */
|
||||
ehci->pshadow = kmalloc (ehci->periodic_size * sizeof (void *), flags);
|
||||
if (ehci->pshadow == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
memset (ehci->pshadow, 0, ehci->periodic_size * sizeof (void *));
|
||||
|
||||
return 0;
|
||||
ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags);
|
||||
if (ehci->pshadow != NULL)
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ehci_dbg (ehci, "couldn't init memory\n");
|
||||
|
||||
@@ -864,9 +864,8 @@ iso_sched_alloc (unsigned packets, gfp_t mem_flags)
|
||||
int size = sizeof *iso_sched;
|
||||
|
||||
size += packets * sizeof (struct ehci_iso_packet);
|
||||
iso_sched = kmalloc (size, mem_flags);
|
||||
iso_sched = kzalloc(size, mem_flags);
|
||||
if (likely (iso_sched != NULL)) {
|
||||
memset(iso_sched, 0, size);
|
||||
INIT_LIST_HEAD (&iso_sched->td_list);
|
||||
}
|
||||
return iso_sched;
|
||||
|
||||
@@ -2137,10 +2137,9 @@ static int etrax_usb_submit_bulk_urb(struct urb *urb)
|
||||
urb->status = -EINPROGRESS;
|
||||
|
||||
/* Setup the hcpriv data. */
|
||||
urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
|
||||
urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
|
||||
assert(urb_priv != NULL);
|
||||
/* This sets rx_offset to 0. */
|
||||
memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
|
||||
urb_priv->urb_state = NOT_STARTED;
|
||||
urb->hcpriv = urb_priv;
|
||||
|
||||
@@ -2475,10 +2474,9 @@ static int etrax_usb_submit_ctrl_urb(struct urb *urb)
|
||||
urb->status = -EINPROGRESS;
|
||||
|
||||
/* Setup the hcpriv data. */
|
||||
urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
|
||||
urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
|
||||
assert(urb_priv != NULL);
|
||||
/* This sets rx_offset to 0. */
|
||||
memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
|
||||
urb_priv->urb_state = NOT_STARTED;
|
||||
urb->hcpriv = urb_priv;
|
||||
|
||||
@@ -2767,9 +2765,8 @@ static void etrax_usb_add_to_intr_sb_list(struct urb *urb, int epid)
|
||||
maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
|
||||
interval = urb->interval;
|
||||
|
||||
urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
|
||||
urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
|
||||
assert(urb_priv != NULL);
|
||||
memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
|
||||
urb->hcpriv = urb_priv;
|
||||
|
||||
first_ep = &TxIntrEPList[0];
|
||||
@@ -2997,9 +2994,8 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
|
||||
|
||||
prev_sb_desc = next_sb_desc = temp_sb_desc = NULL;
|
||||
|
||||
urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
|
||||
urb_priv = kzalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
|
||||
assert(urb_priv != NULL);
|
||||
memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
|
||||
|
||||
urb->hcpriv = urb_priv;
|
||||
urb_priv->epid = epid;
|
||||
|
||||
@@ -5686,13 +5686,11 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||
if (idesc->bInterfaceSubClass != 0x00)
|
||||
return -ENODEV;
|
||||
|
||||
if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
|
||||
if ((ov = kzalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
|
||||
err("couldn't kmalloc ov struct");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
memset(ov, 0, sizeof(*ov));
|
||||
|
||||
ov->dev = dev;
|
||||
ov->iface = idesc->bInterfaceNumber;
|
||||
ov->led_policy = led;
|
||||
|
||||
@@ -1867,12 +1867,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
|
||||
Info("Warning: more than 1 configuration available.\n");
|
||||
|
||||
/* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */
|
||||
pdev = kmalloc(sizeof(struct pwc_device), GFP_KERNEL);
|
||||
pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL);
|
||||
if (pdev == NULL) {
|
||||
Err("Oops, could not allocate memory for pwc_device.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(pdev, 0, sizeof(struct pwc_device));
|
||||
pdev->type = type_id;
|
||||
pdev->vsize = default_size;
|
||||
pdev->vframes = default_fps;
|
||||
|
||||
@@ -1345,13 +1345,11 @@ static int se401_probe(struct usb_interface *intf,
|
||||
/* We found one */
|
||||
info("SE401 camera found: %s", camera_name);
|
||||
|
||||
if ((se401 = kmalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
|
||||
if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
|
||||
err("couldn't kmalloc se401 struct");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memset(se401, 0, sizeof(*se401));
|
||||
|
||||
se401->dev = dev;
|
||||
se401->iface = interface->bInterfaceNumber;
|
||||
se401->camera_name = camera_name;
|
||||
|
||||
@@ -318,12 +318,11 @@ static int stv_init (struct usb_stv *stv680)
|
||||
unsigned char *buffer;
|
||||
unsigned long int bufsize;
|
||||
|
||||
buffer = kmalloc (40, GFP_KERNEL);
|
||||
buffer = kzalloc (40, GFP_KERNEL);
|
||||
if (buffer == NULL) {
|
||||
PDEBUG (0, "STV(e): Out of (small buf) memory");
|
||||
return -1;
|
||||
}
|
||||
memset (buffer, 0, 40);
|
||||
udelay (100);
|
||||
|
||||
/* set config 1, interface 0, alternate 0 */
|
||||
@@ -1388,14 +1387,12 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
|
||||
goto error;
|
||||
}
|
||||
/* We found one */
|
||||
if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
|
||||
if ((stv680 = kzalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
|
||||
PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
|
||||
retval = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
memset (stv680, 0, sizeof (*stv680));
|
||||
|
||||
stv680->udev = dev;
|
||||
stv680->camera_name = camera_name;
|
||||
|
||||
|
||||
@@ -570,10 +570,9 @@ static int auerchain_setup (pauerchain_t acp, unsigned int numElements)
|
||||
|
||||
/* fill the list of free elements */
|
||||
for (;numElements; numElements--) {
|
||||
acep = (pauerchainelement_t) kmalloc (sizeof (auerchainelement_t), GFP_KERNEL);
|
||||
acep = kzalloc(sizeof(auerchainelement_t), GFP_KERNEL);
|
||||
if (!acep)
|
||||
goto ac_fail;
|
||||
memset (acep, 0, sizeof (auerchainelement_t));
|
||||
INIT_LIST_HEAD (&acep->list);
|
||||
list_add_tail (&acep->list, &acp->free_list);
|
||||
}
|
||||
@@ -761,10 +760,9 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
|
||||
|
||||
/* fill the list of free elements */
|
||||
for (;numElements; numElements--) {
|
||||
bep = (pauerbuf_t) kmalloc (sizeof (auerbuf_t), GFP_KERNEL);
|
||||
bep = kzalloc(sizeof(auerbuf_t), GFP_KERNEL);
|
||||
if (!bep)
|
||||
goto bl_fail;
|
||||
memset (bep, 0, sizeof (auerbuf_t));
|
||||
bep->list = bcp;
|
||||
INIT_LIST_HEAD (&bep->buff_list);
|
||||
bep->bufp = kmalloc (bufsize, GFP_KERNEL);
|
||||
|
||||
@@ -270,12 +270,11 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id
|
||||
int retval = -ENOMEM;
|
||||
|
||||
/* allocate memory for our device state and initialize it */
|
||||
dev = kmalloc(sizeof(*dev), GFP_KERNEL);
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (dev == NULL) {
|
||||
err("Out of memory");
|
||||
goto error;
|
||||
}
|
||||
memset(dev, 0x00, sizeof(*dev));
|
||||
kref_init(&dev->kref);
|
||||
|
||||
dev->udev = usb_get_dev(interface_to_usbdev(interface));
|
||||
|
||||
@@ -382,12 +382,11 @@ alloc_sglist (int nents, int max, int vary)
|
||||
for (i = 0; i < nents; i++) {
|
||||
char *buf;
|
||||
|
||||
buf = kmalloc (size, SLAB_KERNEL);
|
||||
buf = kzalloc (size, SLAB_KERNEL);
|
||||
if (!buf) {
|
||||
free_sglist (sg, i);
|
||||
return NULL;
|
||||
}
|
||||
memset (buf, 0, size);
|
||||
|
||||
/* kmalloc pages are always physically contiguous! */
|
||||
sg_init_one(&sg[i], buf, size);
|
||||
@@ -842,10 +841,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
|
||||
* as with bulk/intr sglists, sglen is the queue depth; it also
|
||||
* controls which subtests run (more tests than sglen) or rerun.
|
||||
*/
|
||||
urb = kmalloc (param->sglen * sizeof (struct urb *), SLAB_KERNEL);
|
||||
urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL);
|
||||
if (!urb)
|
||||
return -ENOMEM;
|
||||
memset (urb, 0, param->sglen * sizeof (struct urb *));
|
||||
for (i = 0; i < param->sglen; i++) {
|
||||
int pipe = usb_rcvctrlpipe (udev, 0);
|
||||
unsigned len;
|
||||
@@ -1865,10 +1863,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
|
||||
}
|
||||
#endif
|
||||
|
||||
dev = kmalloc (sizeof *dev, SLAB_KERNEL);
|
||||
dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
|
||||
if (!dev)
|
||||
return -ENOMEM;
|
||||
memset (dev, 0, sizeof *dev);
|
||||
info = (struct usbtest_info *) id->driver_info;
|
||||
dev->info = info;
|
||||
init_MUTEX (&dev->sem);
|
||||
|
||||
@@ -277,9 +277,8 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus)
|
||||
char name[NAMESZ];
|
||||
int rc;
|
||||
|
||||
if ((mbus = kmalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL)
|
||||
if ((mbus = kzalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL)
|
||||
goto err_alloc;
|
||||
memset(mbus, 0, sizeof(struct mon_bus));
|
||||
kref_init(&mbus->ref);
|
||||
spin_lock_init(&mbus->lock);
|
||||
INIT_LIST_HEAD(&mbus->r_list);
|
||||
|
||||
@@ -213,12 +213,11 @@ static int mon_text_open(struct inode *inode, struct file *file)
|
||||
mbus = inode->u.generic_ip;
|
||||
ubus = mbus->u_bus;
|
||||
|
||||
rp = kmalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
|
||||
rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
|
||||
if (rp == NULL) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
memset(rp, 0, sizeof(struct mon_reader_text));
|
||||
INIT_LIST_HEAD(&rp->e_list);
|
||||
init_waitqueue_head(&rp->wait);
|
||||
mutex_init(&rp->printf_lock);
|
||||
|
||||
@@ -621,10 +621,9 @@ static int zd1201_drvr_start(struct zd1201 *zd)
|
||||
__le16 zdmax;
|
||||
unsigned char *buffer;
|
||||
|
||||
buffer = kmalloc(ZD1201_RXSIZE, GFP_KERNEL);
|
||||
buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL);
|
||||
if (!buffer)
|
||||
return -ENOMEM;
|
||||
memset(buffer, 0, ZD1201_RXSIZE);
|
||||
|
||||
usb_fill_bulk_urb(zd->rx_urb, zd->usb,
|
||||
usb_rcvbulkpipe(zd->usb, zd->endp_in), buffer, ZD1201_RXSIZE,
|
||||
@@ -1750,11 +1749,9 @@ static int zd1201_probe(struct usb_interface *interface,
|
||||
|
||||
usb = interface_to_usbdev(interface);
|
||||
|
||||
zd = kmalloc(sizeof(struct zd1201), GFP_KERNEL);
|
||||
if (!zd) {
|
||||
zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
|
||||
if (!zd)
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(zd, 0, sizeof(struct zd1201));
|
||||
zd->ap = ap;
|
||||
zd->usb = usb;
|
||||
zd->removed = 0;
|
||||
|
||||
@@ -169,9 +169,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
|
||||
/* Number of integers required to contain the array */
|
||||
length = (((size - 1) | 3) + 1)/4;
|
||||
|
||||
buf = kmalloc (length * sizeof(u32), GFP_KERNEL);
|
||||
memset(buf, 0, length * sizeof(u32));
|
||||
|
||||
buf = kcalloc(length, sizeof(u32), GFP_KERNEL);
|
||||
if (!buf) {
|
||||
dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -435,11 +435,10 @@ static int generic_startup (struct usb_serial *serial)
|
||||
|
||||
dbg("%s - port %d", __FUNCTION__, serial->port[0]->number);
|
||||
|
||||
priv = kmalloc(sizeof (struct cypress_private), GFP_KERNEL);
|
||||
priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(priv, 0x00, sizeof (struct cypress_private));
|
||||
spin_lock_init(&priv->lock);
|
||||
priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE);
|
||||
if (priv->buf == NULL) {
|
||||
|
||||
@@ -1141,12 +1141,11 @@ static int ftdi_sio_attach (struct usb_serial *serial)
|
||||
|
||||
dbg("%s",__FUNCTION__);
|
||||
|
||||
priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL);
|
||||
priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
|
||||
if (!priv){
|
||||
err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(priv, 0, sizeof(*priv));
|
||||
|
||||
spin_lock_init(&priv->rx_lock);
|
||||
init_waitqueue_head(&priv->delta_msr_wait);
|
||||
|
||||
@@ -1422,12 +1422,11 @@ static int garmin_attach (struct usb_serial *serial)
|
||||
|
||||
dbg("%s", __FUNCTION__);
|
||||
|
||||
garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL);
|
||||
garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
|
||||
if (garmin_data_p == NULL) {
|
||||
dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset (garmin_data_p, 0, sizeof(struct garmin_data));
|
||||
init_timer(&garmin_data_p->timer);
|
||||
spin_lock_init(&garmin_data_p->lock);
|
||||
INIT_LIST_HEAD(&garmin_data_p->pktlist);
|
||||
|
||||
@@ -2725,12 +2725,11 @@ static int edge_startup (struct usb_serial *serial)
|
||||
dev = serial->dev;
|
||||
|
||||
/* create our private serial structure */
|
||||
edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
|
||||
edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
|
||||
if (edge_serial == NULL) {
|
||||
dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset (edge_serial, 0, sizeof(struct edgeport_serial));
|
||||
spin_lock_init(&edge_serial->es_lock);
|
||||
edge_serial->serial = serial;
|
||||
usb_set_serial_data(serial, edge_serial);
|
||||
|
||||
@@ -2727,12 +2727,11 @@ static int edge_startup (struct usb_serial *serial)
|
||||
dev = serial->dev;
|
||||
|
||||
/* create our private serial structure */
|
||||
edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
|
||||
edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
|
||||
if (edge_serial == NULL) {
|
||||
dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset (edge_serial, 0, sizeof(struct edgeport_serial));
|
||||
sema_init(&edge_serial->es_sem, 1);
|
||||
edge_serial->serial = serial;
|
||||
usb_set_serial_data(serial, edge_serial);
|
||||
@@ -2745,12 +2744,11 @@ static int edge_startup (struct usb_serial *serial)
|
||||
|
||||
/* set up our port private structures */
|
||||
for (i = 0; i < serial->num_ports; ++i) {
|
||||
edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
|
||||
edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
|
||||
if (edge_port == NULL) {
|
||||
dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
|
||||
goto cleanup;
|
||||
}
|
||||
memset (edge_port, 0, sizeof(struct edgeport_port));
|
||||
spin_lock_init(&edge_port->ep_lock);
|
||||
edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE);
|
||||
if (edge_port->ep_out_buf == NULL) {
|
||||
|
||||
@@ -184,10 +184,9 @@ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev,
|
||||
struct irda_class_desc *desc;
|
||||
int ret;
|
||||
|
||||
desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
|
||||
desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
|
||||
if (desc == NULL)
|
||||
return NULL;
|
||||
memset(desc, 0, sizeof(struct irda_class_desc));
|
||||
|
||||
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0),
|
||||
IU_REQ_GET_CLASS_DESC,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user