diff options
author | Ben Chan <benchan@chromium.org> | 2012-09-12 11:43:41 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-13 20:15:41 -0700 |
commit | 129575f2a8958a1e90780b0d5b80702bb45b5aac (patch) | |
tree | e79b0a0f7f5cd7c6051893cc08bfc1c7d2816a74 /drivers/staging/gdm72xx/gdm_sdio.c | |
parent | staging: comedi: 8255_pci: move ni_pcidio 8255 board support (diff) | |
download | linux-dev-129575f2a8958a1e90780b0d5b80702bb45b5aac.tar.xz linux-dev-129575f2a8958a1e90780b0d5b80702bb45b5aac.zip |
staging: gdm72xx: simplify alloc_tx_struct and alloc_rx_struct
This patch simplifies alloc_tx_struct and alloc_rx_struct in gdm_sdio.c
and gdm_usb.c by replacing kmalloc+memset with kzalloc and reorganizing
the code.
Signed-off-by: Ben Chan <benchan@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gdm72xx/gdm_sdio.c')
-rw-r--r-- | drivers/staging/gdm72xx/gdm_sdio.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c index a0621d9c2198..ca38d719a1f8 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ b/drivers/staging/gdm72xx/gdm_sdio.c @@ -60,25 +60,20 @@ static void hexdump(char *title, u8 *data, int len) static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx) { - struct sdio_tx *t = NULL; + struct sdio_tx *t = kzalloc(sizeof(*t), GFP_ATOMIC); - t = kzalloc(sizeof(*t), GFP_ATOMIC); - if (t == NULL) - goto out; + if (!t) + return NULL; t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC); - if (t->buf == NULL) - goto out; + if (!t->buf) { + kfree(t); + return NULL; + } t->tx_cxt = tx; return t; -out: - if (t) { - kfree(t->buf); - kfree(t); - } - return NULL; } static void free_tx_struct(struct sdio_tx *t) @@ -91,15 +86,10 @@ static void free_tx_struct(struct sdio_tx *t) static struct sdio_rx *alloc_rx_struct(struct rx_cxt *rx) { - struct sdio_rx *r = NULL; - - r = kmalloc(sizeof(*r), GFP_ATOMIC); - if (!r) - return NULL; - - memset(r, 0, sizeof(*r)); + struct sdio_rx *r = kzalloc(sizeof(*r), GFP_ATOMIC); - r->rx_cxt = rx; + if (r) + r->rx_cxt = rx; return r; } |