aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorEric Sesterhenn <snakebyte@gmx.de>2006-02-27 16:34:10 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:59 -0500
commit7039f4224d4e40b06308d5c1a97427af1a142459 (patch)
tree4529171195b1008e8615bb4b39a129ddda463b16 /drivers/usb/gadget
parent80b6ca48321974a6566a1c9048ba34f60420bca6 (diff)
[PATCH] USB: kzalloc() conversion in drivers/usb/gadget
this patch converts drivers/usb to kzalloc usage. Compile tested with allyes config. I think there was a bug in drivers/usb/gadget/inode.c because it used sizeof(*data) for the kmalloc() and sizeof(data) for the memset(), since sizeof(data) just returns the size for a pointer. Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/dummy_hcd.c3
-rw-r--r--drivers/usb/gadget/goku_udc.c3
-rw-r--r--drivers/usb/gadget/inode.c6
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c3
-rw-r--r--drivers/usb/gadget/net2280.c3
-rw-r--r--drivers/usb/gadget/omap_udc.c6
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c3
-rw-r--r--drivers/usb/gadget/serial.c3
-rw-r--r--drivers/usb/gadget/zero.c3
9 files changed, 11 insertions, 22 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 9734cb76dd6c..42ce41d71b7f 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -478,10 +478,9 @@ dummy_alloc_request (struct usb_ep *_ep, gfp_t mem_flags)
478 return NULL; 478 return NULL;
479 ep = usb_ep_to_dummy_ep (_ep); 479 ep = usb_ep_to_dummy_ep (_ep);
480 480
481 req = kmalloc (sizeof *req, mem_flags); 481 req = kzalloc(sizeof(*req), mem_flags);
482 if (!req) 482 if (!req)
483 return NULL; 483 return NULL;
484 memset (req, 0, sizeof *req);
485 INIT_LIST_HEAD (&req->queue); 484 INIT_LIST_HEAD (&req->queue);
486 return &req->req; 485 return &req->req;
487} 486}
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index b0f3cd63e3b9..66b81bbf6bee 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -275,11 +275,10 @@ goku_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
275 275
276 if (!_ep) 276 if (!_ep)
277 return NULL; 277 return NULL;
278 req = kmalloc(sizeof *req, gfp_flags); 278 req = kzalloc(sizeof *req, gfp_flags);
279 if (!req) 279 if (!req)
280 return NULL; 280 return NULL;
281 281
282 memset(req, 0, sizeof *req);
283 req->req.dma = DMA_ADDR_INVALID; 282 req->req.dma = DMA_ADDR_INVALID;
284 INIT_LIST_HEAD(&req->queue); 283 INIT_LIST_HEAD(&req->queue);
285 return &req->req; 284 return &req->req;
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 0aab7d24c768..b44cfda76b61 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -170,10 +170,9 @@ static struct dev_data *dev_new (void)
170{ 170{
171 struct dev_data *dev; 171 struct dev_data *dev;
172 172
173 dev = kmalloc (sizeof *dev, GFP_KERNEL); 173 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
174 if (!dev) 174 if (!dev)
175 return NULL; 175 return NULL;
176 memset (dev, 0, sizeof *dev);
177 dev->state = STATE_DEV_DISABLED; 176 dev->state = STATE_DEV_DISABLED;
178 atomic_set (&dev->count, 1); 177 atomic_set (&dev->count, 1);
179 spin_lock_init (&dev->lock); 178 spin_lock_init (&dev->lock);
@@ -1592,10 +1591,9 @@ static int activate_ep_files (struct dev_data *dev)
1592 gadget_for_each_ep (ep, dev->gadget) { 1591 gadget_for_each_ep (ep, dev->gadget) {
1593 struct ep_data *data; 1592 struct ep_data *data;
1594 1593
1595 data = kmalloc (sizeof *data, GFP_KERNEL); 1594 data = kzalloc(sizeof(*data), GFP_KERNEL);
1596 if (!data) 1595 if (!data)
1597 goto enomem; 1596 goto enomem;
1598 memset (data, 0, sizeof data);
1599 data->state = STATE_EP_DISABLED; 1597 data->state = STATE_EP_DISABLED;
1600 init_MUTEX (&data->lock); 1598 init_MUTEX (&data->lock);
1601 init_waitqueue_head (&data->wait); 1599 init_waitqueue_head (&data->wait);
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 1a362c5e7f3d..0d3424eda038 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -1114,11 +1114,10 @@ static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep,
1114 1114
1115 DEBUG("%s, %p\n", __FUNCTION__, ep); 1115 DEBUG("%s, %p\n", __FUNCTION__, ep);
1116 1116
1117 req = kmalloc(sizeof *req, gfp_flags); 1117 req = kzalloc(sizeof(*req), gfp_flags);
1118 if (!req) 1118 if (!req)
1119 return 0; 1119 return 0;
1120 1120
1121 memset(req, 0, sizeof *req);
1122 INIT_LIST_HEAD(&req->queue); 1121 INIT_LIST_HEAD(&req->queue);
1123 1122
1124 return &req->req; 1123 return &req->req;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 67b13ab2f3f5..fb73dc100535 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -386,11 +386,10 @@ net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
386 return NULL; 386 return NULL;
387 ep = container_of (_ep, struct net2280_ep, ep); 387 ep = container_of (_ep, struct net2280_ep, ep);
388 388
389 req = kmalloc (sizeof *req, gfp_flags); 389 req = kzalloc(sizeof(*req), gfp_flags);
390 if (!req) 390 if (!req)
391 return NULL; 391 return NULL;
392 392
393 memset (req, 0, sizeof *req);
394 req->req.dma = DMA_ADDR_INVALID; 393 req->req.dma = DMA_ADDR_INVALID;
395 INIT_LIST_HEAD (&req->queue); 394 INIT_LIST_HEAD (&req->queue);
396 395
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index a8972d7c97be..fbea51448909 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -273,9 +273,8 @@ omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
273{ 273{
274 struct omap_req *req; 274 struct omap_req *req;
275 275
276 req = kmalloc(sizeof *req, gfp_flags); 276 req = kzalloc(sizeof(*req), gfp_flags);
277 if (req) { 277 if (req) {
278 memset (req, 0, sizeof *req);
279 req->req.dma = DMA_ADDR_INVALID; 278 req->req.dma = DMA_ADDR_INVALID;
280 INIT_LIST_HEAD (&req->queue); 279 INIT_LIST_HEAD (&req->queue);
281 } 280 }
@@ -2586,11 +2585,10 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2586 /* UDC_PULLUP_EN gates the chip clock */ 2585 /* UDC_PULLUP_EN gates the chip clock */
2587 // OTG_SYSCON_1_REG |= DEV_IDLE_EN; 2586 // OTG_SYSCON_1_REG |= DEV_IDLE_EN;
2588 2587
2589 udc = kmalloc (sizeof *udc, SLAB_KERNEL); 2588 udc = kzalloc(sizeof(*udc), SLAB_KERNEL);
2590 if (!udc) 2589 if (!udc)
2591 return -ENOMEM; 2590 return -ENOMEM;
2592 2591
2593 memset(udc, 0, sizeof *udc);
2594 spin_lock_init (&udc->lock); 2592 spin_lock_init (&udc->lock);
2595 2593
2596 udc->gadget.ops = &omap_gadget_ops; 2594 udc->gadget.ops = &omap_gadget_ops;
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index bb028c5b8952..680f7fc5b171 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -335,11 +335,10 @@ pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
335{ 335{
336 struct pxa2xx_request *req; 336 struct pxa2xx_request *req;
337 337
338 req = kmalloc (sizeof *req, gfp_flags); 338 req = kzalloc(sizeof(*req), gfp_flags);
339 if (!req) 339 if (!req)
340 return NULL; 340 return NULL;
341 341
342 memset (req, 0, sizeof *req);
343 INIT_LIST_HEAD (&req->queue); 342 INIT_LIST_HEAD (&req->queue);
344 return &req->req; 343 return &req->req;
345} 344}
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 548feaac4553..b992546c394d 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -2178,10 +2178,9 @@ static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags)
2178 return -EIO; 2178 return -EIO;
2179 2179
2180 for (i=0; i<GS_NUM_PORTS; i++) { 2180 for (i=0; i<GS_NUM_PORTS; i++) {
2181 if ((port=(struct gs_port *)kmalloc(sizeof(struct gs_port), kmalloc_flags)) == NULL) 2181 if ((port=kzalloc(sizeof(struct gs_port), kmalloc_flags)) == NULL)
2182 return -ENOMEM; 2182 return -ENOMEM;
2183 2183
2184 memset(port, 0, sizeof(struct gs_port));
2185 port->port_dev = dev; 2184 port->port_dev = dev;
2186 port->port_num = i; 2185 port->port_num = i;
2187 port->port_line_coding.dwDTERate = cpu_to_le32(GS_DEFAULT_DTE_RATE); 2186 port->port_line_coding.dwDTERate = cpu_to_le32(GS_DEFAULT_DTE_RATE);
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 44d8e5e77da7..51424f66a765 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1188,10 +1188,9 @@ autoconf_fail:
1188 1188
1189 1189
1190 /* ok, we made sense of the hardware ... */ 1190 /* ok, we made sense of the hardware ... */
1191 dev = kmalloc (sizeof *dev, SLAB_KERNEL); 1191 dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
1192 if (!dev) 1192 if (!dev)
1193 return -ENOMEM; 1193 return -ENOMEM;
1194 memset (dev, 0, sizeof *dev);
1195 spin_lock_init (&dev->lock); 1194 spin_lock_init (&dev->lock);
1196 dev->gadget = gadget; 1195 dev->gadget = gadget;
1197 set_gadget_data (gadget, dev); 1196 set_gadget_data (gadget, dev);