From f7468e2995dbd914817c780941750f0ac668ac50 Mon Sep 17 00:00:00 2001 From: Alexander Beregalov Date: Sat, 26 Mar 2011 20:18:11 +0300 Subject: Staging: rts_pstor: s/rtsx_free_dma_buf/kfree/ Signed-off-by: Alexander Beregalov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/ms.c | 38 +++++++++++++++++++------------------- drivers/staging/rts_pstor/rtsx.h | 1 - drivers/staging/rts_pstor/spi.c | 26 +++++++++++++------------- drivers/staging/rts_pstor/xd.c | 2 +- 4 files changed, 33 insertions(+), 34 deletions(-) (limited to 'drivers/staging/rts_pstor') diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c index 810e170..58fc7e0 100644 --- a/drivers/staging/rts_pstor/ms.c +++ b/drivers/staging/rts_pstor/ms.c @@ -875,11 +875,11 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) } retval = rtsx_read_register(chip, MS_TRANS_CFG, &val); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if (!(val & MS_INT_BREQ)) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, @@ -891,7 +891,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) } } if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -899,7 +899,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) do { retval = rtsx_read_register(chip, MS_TRANS_CFG, &val); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -908,7 +908,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) retval = ms_transfer_tpc(chip, MS_TM_NORMAL_READ, PRO_READ_LONG_DATA, 0, WAIT_INT); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -916,18 +916,18 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) } while (i < 1024); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if ((buf[0] != 0xa5) && (buf[1] != 0xc3)) { /* Signature code is wrong */ - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if ((buf[4] < 1) || (buf[4] > 12)) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -949,15 +949,15 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) RTSX_DEBUGP("sys_info_addr = 0x%x, sys_info_size = 0x%x\n", sys_info_addr, sys_info_size); if (sys_info_size != 96) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if (sys_info_addr < 0x1A0) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if ((sys_info_size + sys_info_addr) > 0x8000) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -983,15 +983,15 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) RTSX_DEBUGP("model_name_addr = 0x%x, model_name_size = 0x%x\n", model_name_addr, model_name_size); if (model_name_size != 48) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if (model_name_addr < 0x1A0) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } if ((model_name_size + model_name_addr) > 0x8000) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -1004,7 +1004,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) } if (i == buf[4]) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -1041,7 +1041,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) memcpy(ms_card->raw_model_name, buf + model_name_addr, 48); #endif - rtsx_free_dma_buf(chip, buf); + kfree(buf); #ifdef SUPPORT_MSXC if (CHK_MSXC(ms_card)) { @@ -3817,7 +3817,7 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip) GetEKBFinish: if (buf) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); } return retval; } @@ -4055,7 +4055,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) GetICVFinish: if (buf) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); } return retval; } @@ -4156,7 +4156,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) SetICVFinish: if (buf) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); } return retval; } diff --git a/drivers/staging/rts_pstor/rtsx.h b/drivers/staging/rts_pstor/rtsx.h index 4d5ddf6..263524c 100644 --- a/drivers/staging/rts_pstor/rtsx.h +++ b/drivers/staging/rts_pstor/rtsx.h @@ -99,7 +99,6 @@ do { \ #define SCSI_LUN(srb) ((srb)->device->lun) #define rtsx_alloc_dma_buf(chip, size, flag) kmalloc((size), (flag)) -#define rtsx_free_dma_buf(chip, ptr) kfree((ptr)) typedef unsigned long DELAY_PARA_T; diff --git a/drivers/staging/rts_pstor/spi.c b/drivers/staging/rts_pstor/spi.c index 8a8689b..3daab9a 100644 --- a/drivers/staging/rts_pstor/spi.c +++ b/drivers/staging/rts_pstor/spi.c @@ -543,7 +543,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_transfer_data(chip, 0, buf, pagelen, 0, DMA_FROM_DEVICE, 10000); if (retval < 0) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); TRACE_RET(chip, STATUS_FAIL); @@ -556,7 +556,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) } scsi_set_resid(srb, 0); - rtsx_free_dma_buf(chip, buf); + kfree(buf); return STATUS_SUCCESS; } @@ -591,7 +591,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) while (len) { retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -605,7 +605,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); TRACE_RET(chip, STATUS_FAIL); @@ -613,7 +613,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -621,7 +621,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) len--; } - rtsx_free_dma_buf(chip, buf); + kfree(buf); } else if (program_mode == AAI_PROGRAM) { int first_byte = 1; @@ -650,7 +650,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_send_cmd(chip, 0, 100); if (retval < 0) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); TRACE_RET(chip, STATUS_FAIL); @@ -658,14 +658,14 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } len--; } - rtsx_free_dma_buf(chip, buf); + kfree(buf); retval = sf_disable_write(chip, SPI_WRDI); if (retval != STATUS_SUCCESS) @@ -687,7 +687,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_enable_write(chip, SPI_WREN); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -702,7 +702,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = rtsx_transfer_data(chip, 0, buf, pagelen, 0, DMA_TO_DEVICE, 100); if (retval < 0) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); rtsx_clear_spi_error(chip); spi_set_err_code(chip, SPI_HW_ERR); TRACE_RET(chip, STATUS_FAIL); @@ -710,7 +710,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) retval = sf_polling_status(chip, 100); if (retval != STATUS_SUCCESS) { - rtsx_free_dma_buf(chip, buf); + kfree(buf); TRACE_RET(chip, STATUS_FAIL); } @@ -718,7 +718,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) len -= pagelen; } - rtsx_free_dma_buf(chip, buf); + kfree(buf); } else { spi_set_err_code(chip, SPI_INVALID_COMMAND); TRACE_RET(chip, STATUS_FAIL); diff --git a/drivers/staging/rts_pstor/xd.c b/drivers/staging/rts_pstor/xd.c index 7bcd468..b9eb072 100644 --- a/drivers/staging/rts_pstor/xd.c +++ b/drivers/staging/rts_pstor/xd.c @@ -426,7 +426,7 @@ static void xd_clear_dma_buffer(struct rtsx_chip *chip) rtsx_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR); } - rtsx_free_dma_buf(chip, buf); + kfree(buf); if (chip->asic_code) { rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, 0x55); -- cgit v1.1 From 389fe985f27b5334110639146016bb6dd273c3f6 Mon Sep 17 00:00:00 2001 From: Alexander Beregalov Date: Sun, 27 Mar 2011 04:06:43 +0400 Subject: Staging: rts_pstor: s/rtsx_alloc_dma_buf/kmalloc/ Replace rtsx_alloc_dma_buf() with kfree() back, chip parameter is not used; remove casts. Signed-off-by: Alexander Beregalov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/ms.c | 8 ++++---- drivers/staging/rts_pstor/rtsx.h | 2 -- drivers/staging/rts_pstor/spi.c | 8 ++++---- drivers/staging/rts_pstor/xd.c | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to 'drivers/staging/rts_pstor') diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c index 58fc7e0..9975a59 100644 --- a/drivers/staging/rts_pstor/ms.c +++ b/drivers/staging/rts_pstor/ms.c @@ -863,7 +863,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); } - buf = (u8 *)rtsx_alloc_dma_buf(chip, 64 * 512, GFP_KERNEL); + buf = kmalloc(64 * 512, GFP_KERNEL); if (buf == NULL) { TRACE_RET(chip, STATUS_ERROR); } @@ -3783,7 +3783,7 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); } - buf = (u8 *)rtsx_alloc_dma_buf(chip, 1540, GFP_KERNEL); + buf = kmalloc(1540, GFP_KERNEL); if (!buf) { TRACE_RET(chip, STATUS_ERROR); } @@ -4021,7 +4021,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); } - buf = (u8 *)rtsx_alloc_dma_buf(chip, 1028, GFP_KERNEL); + buf = kmalloc(1028, GFP_KERNEL); if (!buf) { TRACE_RET(chip, STATUS_ERROR); } @@ -4080,7 +4080,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); } - buf = (u8 *)rtsx_alloc_dma_buf(chip, 1028, GFP_KERNEL); + buf = kmalloc(1028, GFP_KERNEL); if (!buf) { TRACE_RET(chip, STATUS_ERROR); } diff --git a/drivers/staging/rts_pstor/rtsx.h b/drivers/staging/rts_pstor/rtsx.h index 263524c..6afb635 100644 --- a/drivers/staging/rts_pstor/rtsx.h +++ b/drivers/staging/rts_pstor/rtsx.h @@ -98,8 +98,6 @@ do { \ #define SCSI_LUN(srb) ((srb)->device->lun) -#define rtsx_alloc_dma_buf(chip, size, flag) kmalloc((size), (flag)) - typedef unsigned long DELAY_PARA_T; struct rtsx_chip; diff --git a/drivers/staging/rts_pstor/spi.c b/drivers/staging/rts_pstor/spi.c index 3daab9a..c803ba6 100644 --- a/drivers/staging/rts_pstor/spi.c +++ b/drivers/staging/rts_pstor/spi.c @@ -505,7 +505,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) TRACE_RET(chip, STATUS_FAIL); } - buf = (u8 *)rtsx_alloc_dma_buf(chip, SF_PAGE_LEN, GFP_KERNEL); + buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL); if (buf == NULL) TRACE_RET(chip, STATUS_ERROR); @@ -584,7 +584,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) } if (program_mode == BYTE_PROGRAM) { - buf = rtsx_alloc_dma_buf(chip, 4, GFP_KERNEL); + buf = kmalloc(4, GFP_KERNEL); if (!buf) TRACE_RET(chip, STATUS_ERROR); @@ -630,7 +630,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); - buf = rtsx_alloc_dma_buf(chip, 4, GFP_KERNEL); + buf = kmalloc(4, GFP_KERNEL); if (!buf) TRACE_RET(chip, STATUS_ERROR); @@ -675,7 +675,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) if (retval != STATUS_SUCCESS) TRACE_RET(chip, STATUS_FAIL); } else if (program_mode == PAGE_PROGRAM) { - buf = rtsx_alloc_dma_buf(chip, SF_PAGE_LEN, GFP_KERNEL); + buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL); if (!buf) TRACE_RET(chip, STATUS_NOMEM); diff --git a/drivers/staging/rts_pstor/xd.c b/drivers/staging/rts_pstor/xd.c index b9eb072..a58a689 100644 --- a/drivers/staging/rts_pstor/xd.c +++ b/drivers/staging/rts_pstor/xd.c @@ -379,7 +379,7 @@ static void xd_clear_dma_buffer(struct rtsx_chip *chip) RTSX_DEBUGP("xD ECC error, dummy write!\n"); - buf = (u8 *)rtsx_alloc_dma_buf(chip, 512, GFP_KERNEL); + buf = kmalloc(512, GFP_KERNEL); if (!buf) return; -- cgit v1.1 From cc614b6970ed9957d51255682c2784c2310623af Mon Sep 17 00:00:00 2001 From: Alexander Beregalov Date: Sat, 26 Mar 2011 20:18:13 +0300 Subject: Staging: rts_pstor: redundant null check before kfree() Signed-off-by: Alexander Beregalov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/ms.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'drivers/staging/rts_pstor') diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c index 9975a59..2fd2932 100644 --- a/drivers/staging/rts_pstor/ms.c +++ b/drivers/staging/rts_pstor/ms.c @@ -3816,9 +3816,7 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip) rtsx_stor_set_xfer_buf(buf, bufflen, srb); GetEKBFinish: - if (buf) { - kfree(buf); - } + kfree(buf); return retval; } @@ -4054,9 +4052,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) rtsx_stor_set_xfer_buf(buf, bufflen, srb); GetICVFinish: - if (buf) { - kfree(buf); - } + kfree(buf); return retval; } @@ -4155,9 +4151,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) #endif SetICVFinish: - if (buf) { - kfree(buf); - } + kfree(buf); return retval; } -- cgit v1.1 From e0ce58d7b05eba3d79ea8124d417224dae65c71f Mon Sep 17 00:00:00 2001 From: wwang Date: Wed, 20 Apr 2011 15:14:05 +0800 Subject: staging: rts_pstor: clear error when read sd lba0 fail Call rtsx_clear_sd_error if sd_read_data fail when reading sd lba0. Signed-off-by: wwang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/sd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging/rts_pstor') diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c index 8d066bd..fbcc148 100644 --- a/drivers/staging/rts_pstor/sd.c +++ b/drivers/staging/rts_pstor/sd.c @@ -2227,6 +2227,7 @@ static int sd_read_lba0(struct rtsx_chip *chip) retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 512, 1, bus_width, NULL, 0, 100); if (retval != STATUS_SUCCESS) { + rtsx_clear_sd_error(chip); TRACE_RET(chip, STATUS_FAIL); } -- cgit v1.1 From da548cb3f1ec3b1fd4ec2a848401398462ce3124 Mon Sep 17 00:00:00 2001 From: "Cho, Yu-Chen" Date: Tue, 3 May 2011 17:53:35 +0800 Subject: staging/rts_pstor: fix Polling thread wakeups CPU RealTek PCI-E Card Reader rts_pstor driver causes CPU wakeup very frequently, thatt's bad for power consumption. Signed-off-by: Cho, Yu-Chen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts_pstor/rtsx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/staging/rts_pstor') diff --git a/drivers/staging/rts_pstor/rtsx.c b/drivers/staging/rts_pstor/rtsx.c index 02525d5..5ff59f2 100644 --- a/drivers/staging/rts_pstor/rtsx.c +++ b/drivers/staging/rts_pstor/rtsx.c @@ -594,7 +594,9 @@ static int rtsx_polling_thread(void *__dev) wait_timeout((delay_use + 5) * 1000); for (;;) { - wait_timeout(POLLING_INTERVAL); + + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(POLLING_INTERVAL); /* lock the device pointers */ mutex_lock(&(dev->dev_mutex)); -- cgit v1.1