Commit 48e3eeb1a1a89a3ea256cf6d3c898e753787cfaa

Authored by Mariusz Kozlowski
Committed by David S. Miller
1 parent 1ee325438c

[IRDA] irda-usb.c: mostly kmalloc + memset conversion to k[cz]alloc

drivers/net/irda/irda-usb.c | 59694 -> 59541 (-153 bytes)
 drivers/net/irda/irda-usb.o | 170588 -> 169256 (-1332 bytes)

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 10 additions and 14 deletions Side-by-side Diff

drivers/net/irda/irda-usb.c
... ... @@ -1561,10 +1561,9 @@
1561 1561 struct irda_class_desc *desc;
1562 1562 int ret;
1563 1563  
1564   - desc = kmalloc(sizeof (*desc), GFP_KERNEL);
1565   - if (desc == NULL)
  1564 + desc = kzalloc(sizeof(*desc), GFP_KERNEL);
  1565 + if (!desc)
1566 1566 return NULL;
1567   - memset(desc, 0, sizeof(*desc));
1568 1567  
1569 1568 /* USB-IrDA class spec 1.0:
1570 1569 * 6.1.3: Standard "Get Descriptor" Device Request is not
... ... @@ -1617,7 +1616,7 @@
1617 1616 {
1618 1617 struct net_device *net;
1619 1618 struct usb_device *dev = interface_to_usbdev(intf);
1620   - struct irda_usb_cb *self = NULL;
  1619 + struct irda_usb_cb *self;
1621 1620 struct usb_host_interface *interface;
1622 1621 struct irda_class_desc *irda_desc;
1623 1622 int ret = -ENOMEM;
... ... @@ -1655,7 +1654,7 @@
1655 1654 self->header_length = USB_IRDA_HEADER;
1656 1655 }
1657 1656  
1658   - self->rx_urb = kzalloc(self->max_rx_urb * sizeof(struct urb *),
  1657 + self->rx_urb = kcalloc(self->max_rx_urb, sizeof(struct urb *),
1659 1658 GFP_KERNEL);
1660 1659  
1661 1660 for (i = 0; i < self->max_rx_urb; i++) {
... ... @@ -1715,7 +1714,7 @@
1715 1714 /* Find IrDA class descriptor */
1716 1715 irda_desc = irda_usb_find_class_desc(intf);
1717 1716 ret = -ENODEV;
1718   - if (irda_desc == NULL)
  1717 + if (!irda_desc)
1719 1718 goto err_out_3;
1720 1719  
1721 1720 if (self->needspatch) {
1722 1721  
1723 1722  
... ... @@ -1738,15 +1737,13 @@
1738 1737 /* Don't change this buffer size and allocation without doing
1739 1738 * some heavy and complete testing. Don't ask why :-(
1740 1739 * Jean II */
1741   - self->speed_buff = kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
1742   - if (self->speed_buff == NULL)
  1740 + self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
  1741 + if (!self->speed_buff)
1743 1742 goto err_out_3;
1744 1743  
1745   - memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU);
1746   -
1747 1744 self->tx_buff = kzalloc(IRDA_SKB_MAX_MTU + self->header_length,
1748 1745 GFP_KERNEL);
1749   - if (self->tx_buff == NULL)
  1746 + if (!self->tx_buff)
1750 1747 goto err_out_4;
1751 1748  
1752 1749 ret = irda_usb_open(self);
1753 1750  
... ... @@ -1767,12 +1764,11 @@
1767 1764  
1768 1765 /* replace IrDA class descriptor with what patched device is now reporting */
1769 1766 irda_desc = irda_usb_find_class_desc (self->usbintf);
1770   - if (irda_desc == NULL) {
  1767 + if (!irda_desc) {
1771 1768 ret = -ENODEV;
1772 1769 goto err_out_6;
1773 1770 }
1774   - if (self->irda_desc)
1775   - kfree (self->irda_desc);
  1771 + kfree(self->irda_desc);
1776 1772 self->irda_desc = irda_desc;
1777 1773 irda_usb_init_qos(self);
1778 1774 }