From 0159f76d9f5839c3c92bc3a91c865e94d5e489a8 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sat, 25 Jun 2005 14:59:14 -0700 Subject: [PATCH] [PATCH] kfree cleanups in ixj.c This patch removes redundant checks for NULL pointer before kfree() in drivers/telephony/ Signed-off-by: Jesper Juhl Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/telephony/ixj.c | 52 +++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c index d5863b8b56ee..f2c9fa423d40 100644 --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -329,10 +329,8 @@ static IXJ *ixj_alloc() static void ixj_fsk_free(IXJ *j) { - if(j->fskdata != NULL) { - kfree(j->fskdata); - j->fskdata = NULL; - } + kfree(j->fskdata); + j->fskdata = NULL; } static void ixj_fsk_alloc(IXJ *j) @@ -3867,13 +3865,11 @@ static int set_rec_codec(IXJ *j, int rate) j->rec_mode = 7; break; default: + kfree(j->read_buffer); j->rec_frame_size = 0; j->rec_mode = -1; - if (j->read_buffer) { - kfree(j->read_buffer); - j->read_buffer = NULL; - j->read_buffer_size = 0; - } + j->read_buffer = NULL; + j->read_buffer_size = 0; retval = 1; break; } @@ -3991,14 +3987,12 @@ static int ixj_record_start(IXJ *j) static void ixj_record_stop(IXJ *j) { - if(ixjdebug & 0x0002) + if (ixjdebug & 0x0002) printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies); - if (j->read_buffer) { - kfree(j->read_buffer); - j->read_buffer = NULL; - j->read_buffer_size = 0; - } + kfree(j->read_buffer); + j->read_buffer = NULL; + j->read_buffer_size = 0; if (j->rec_mode > -1) { ixj_WriteDSPCommand(0x5120, j); j->rec_mode = -1; @@ -4449,13 +4443,11 @@ static int set_play_codec(IXJ *j, int rate) j->play_mode = 5; break; default: + kfree(j->write_buffer); j->play_frame_size = 0; j->play_mode = -1; - if (j->write_buffer) { - kfree(j->write_buffer); - j->write_buffer = NULL; - j->write_buffer_size = 0; - } + j->write_buffer = NULL; + j->write_buffer_size = 0; retval = 1; break; } @@ -4578,14 +4570,12 @@ static int ixj_play_start(IXJ *j) static void ixj_play_stop(IXJ *j) { - if(ixjdebug & 0x0002) + if (ixjdebug & 0x0002) printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies); - if (j->write_buffer) { - kfree(j->write_buffer); - j->write_buffer = NULL; - j->write_buffer_size = 0; - } + kfree(j->write_buffer); + j->write_buffer = NULL; + j->write_buffer_size = 0; if (j->play_mode > -1) { ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */ @@ -5810,9 +5800,7 @@ static void ixj_cpt_stop(IXJ *j) ixj_play_tone(j, 0); j->tone_state = j->tone_cadence_state = 0; if (j->cadence_t) { - if (j->cadence_t->ce) { - kfree(j->cadence_t->ce); - } + kfree(j->cadence_t->ce); kfree(j->cadence_t); j->cadence_t = NULL; } @@ -7497,10 +7485,8 @@ static void cleanup(void) printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt); release_region(j->XILINXbase, 4); } - if (j->read_buffer) - kfree(j->read_buffer); - if (j->write_buffer) - kfree(j->write_buffer); + kfree(j->read_buffer); + kfree(j->write_buffer); if (j->dev) pnp_device_detach(j->dev); if (ixjdebug & 0x0002) -- 2.30.2