diff options
Diffstat (limited to 'drivers/staging/rts5208')
-rw-r--r-- | drivers/staging/rts5208/ms.c | 140 | ||||
-rw-r--r-- | drivers/staging/rts5208/rtsx.c | 20 | ||||
-rw-r--r-- | drivers/staging/rts5208/rtsx_scsi.c | 31 | ||||
-rw-r--r-- | drivers/staging/rts5208/rtsx_transport.c | 163 | ||||
-rw-r--r-- | drivers/staging/rts5208/sd.c | 28 | ||||
-rw-r--r-- | drivers/staging/rts5208/spi.c | 4 | ||||
-rw-r--r-- | drivers/staging/rts5208/xd.c | 40 |
7 files changed, 199 insertions, 227 deletions
diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index cdaa1aba50ed..a780185a3754 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -30,14 +30,14 @@ static inline void ms_set_err_code(struct rtsx_chip *chip, u8 err_code) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; ms_card->err_code = err_code; } static inline int ms_check_err_code(struct rtsx_chip *chip, u8 err_code) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; return (ms_card->err_code == err_code); } @@ -51,7 +51,7 @@ static int ms_parse_err_code(struct rtsx_chip *chip) static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode, u8 tpc, u8 cnt, u8 cfg) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; u8 *ptr; @@ -185,7 +185,7 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode, static int ms_write_bytes(struct rtsx_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, int data_len) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; if (!data || (data_len < cnt)) { @@ -255,7 +255,7 @@ static int ms_write_bytes(struct rtsx_chip *chip, static int ms_read_bytes(struct rtsx_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, int data_len) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 *ptr; @@ -369,7 +369,7 @@ static int ms_send_cmd(struct rtsx_chip *chip, u8 cmd, u8 cfg) static int ms_set_init_para(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; if (CHK_HG8BIT(ms_card)) { @@ -408,7 +408,7 @@ static int ms_set_init_para(struct rtsx_chip *chip) static int ms_switch_clock(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; retval = select_card(chip, MS_CARD); @@ -542,7 +542,7 @@ static int ms_pull_ctl_enable(struct rtsx_chip *chip) static int ms_prepare_reset(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; u8 oc_mask = 0; @@ -653,7 +653,7 @@ static int ms_prepare_reset(struct rtsx_chip *chip) static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 val; @@ -829,7 +829,7 @@ static int ms_switch_parallel_bus(struct rtsx_chip *chip) static int ms_switch_8bit_bus(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 data[2]; @@ -873,7 +873,7 @@ static int ms_switch_8bit_bus(struct rtsx_chip *chip) static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; for (i = 0; i < 3; i++) { @@ -994,7 +994,7 @@ static int msxc_change_power(struct rtsx_chip *chip, u8 mode) static int ms_read_attribute_info(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 val, *buf, class_code, device_type, sub_class, data[16]; u16 total_blk = 0, blk_size = 0; @@ -1039,7 +1039,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) } buf = kmalloc(64 * 512, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return STATUS_ERROR; } @@ -1303,7 +1303,7 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, static int reset_ms_pro(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; #ifdef XC_POWERCLASS u8 change_power_class; @@ -1421,7 +1421,7 @@ static int ms_read_status_reg(struct rtsx_chip *chip) static int ms_read_extra_data(struct rtsx_chip *chip, u16 block_addr, u8 page_num, u8 *buf, int buf_len) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 val, data[10]; @@ -1516,7 +1516,7 @@ static int ms_read_extra_data(struct rtsx_chip *chip, static int ms_write_extra_data(struct rtsx_chip *chip, u16 block_addr, u8 page_num, u8 *buf, int buf_len) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 val, data[16]; @@ -1585,7 +1585,7 @@ static int ms_write_extra_data(struct rtsx_chip *chip, static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; u8 val, data[6]; @@ -1670,7 +1670,7 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; u8 val, data[8], extra[MS_EXTRA_SIZE]; @@ -1741,7 +1741,7 @@ static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk) static int ms_erase_block(struct rtsx_chip *chip, u16 phy_blk) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i = 0; u8 val, data[6]; @@ -1862,7 +1862,7 @@ static int ms_init_page(struct rtsx_chip *chip, u16 phy_blk, u16 log_blk, static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, u16 log_blk, u8 start_page, u8 end_page) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; bool uncorrect_flag = false; int retval, rty_cnt; u8 extra[MS_EXTRA_SIZE], val, i, j, data[16]; @@ -2155,7 +2155,7 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, static int reset_ms(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; u16 i, reg_addr, block_size; u8 val, extra[MS_EXTRA_SIZE], j, *ptr; @@ -2394,7 +2394,7 @@ RE_SEARCH: static int ms_init_l2p_tbl(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int size, i, seg_no, retval; u16 defect_block, reg_addr; u8 val1, val2; @@ -2405,7 +2405,7 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip) size = ms_card->segment_cnt * sizeof(struct zone_entry); ms_card->segment = vzalloc(size); - if (ms_card->segment == NULL) { + if (!ms_card->segment) { rtsx_trace(chip); return STATUS_FAIL; } @@ -2457,20 +2457,18 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip) return STATUS_SUCCESS; INIT_FAIL: - if (ms_card->segment) { - vfree(ms_card->segment); - ms_card->segment = NULL; - } + vfree(ms_card->segment); + ms_card->segment = NULL; return STATUS_FAIL; } static u16 ms_get_l2p_tbl(struct rtsx_chip *chip, int seg_no, u16 log_off) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct zone_entry *segment; - if (ms_card->segment == NULL) + if (!ms_card->segment) return 0xFFFF; segment = &(ms_card->segment[seg_no]); @@ -2484,10 +2482,10 @@ static u16 ms_get_l2p_tbl(struct rtsx_chip *chip, int seg_no, u16 log_off) static void ms_set_l2p_tbl(struct rtsx_chip *chip, int seg_no, u16 log_off, u16 phy_blk) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct zone_entry *segment; - if (ms_card->segment == NULL) + if (!ms_card->segment) return; segment = &(ms_card->segment[seg_no]); @@ -2497,7 +2495,7 @@ static void ms_set_l2p_tbl(struct rtsx_chip *chip, static void ms_set_unused_block(struct rtsx_chip *chip, u16 phy_blk) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct zone_entry *segment; int seg_no; @@ -2513,7 +2511,7 @@ static void ms_set_unused_block(struct rtsx_chip *chip, u16 phy_blk) static u16 ms_get_unused_block(struct rtsx_chip *chip, int seg_no) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct zone_entry *segment; u16 phy_blk; @@ -2540,7 +2538,7 @@ static const unsigned short ms_start_idx[] = {0, 494, 990, 1486, 1982, 2478, static int ms_arbitrate_l2p(struct rtsx_chip *chip, u16 phy_blk, u16 log_off, u8 us1, u8 us2) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct zone_entry *segment; int seg_no; u16 tmp_blk; @@ -2582,7 +2580,7 @@ static int ms_arbitrate_l2p(struct rtsx_chip *chip, u16 phy_blk, static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct zone_entry *segment; bool defect_flag; int retval, table_size, disable_cnt, i; @@ -2591,7 +2589,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) dev_dbg(rtsx_dev(chip), "ms_build_l2p_tbl: %d\n", seg_no); - if (ms_card->segment == NULL) { + if (!ms_card->segment) { retval = ms_init_l2p_tbl(chip); if (retval != STATUS_SUCCESS) { rtsx_trace(chip); @@ -2612,18 +2610,18 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) segment = &(ms_card->segment[seg_no]); - if (segment->l2p_table == NULL) { + if (!segment->l2p_table) { segment->l2p_table = vmalloc(table_size * 2); - if (segment->l2p_table == NULL) { + if (!segment->l2p_table) { rtsx_trace(chip); goto BUILD_FAIL; } } memset((u8 *)(segment->l2p_table), 0xff, table_size * 2); - if (segment->free_table == NULL) { + if (!segment->free_table) { segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2); - if (segment->free_table == NULL) { + if (!segment->free_table) { rtsx_trace(chip); goto BUILD_FAIL; } @@ -2803,14 +2801,10 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) BUILD_FAIL: segment->build_flag = 0; - if (segment->l2p_table) { - vfree(segment->l2p_table); - segment->l2p_table = NULL; - } - if (segment->free_table) { - vfree(segment->free_table); - segment->free_table = NULL; - } + vfree(segment->l2p_table); + segment->l2p_table = NULL; + vfree(segment->free_table); + segment->free_table = NULL; return STATUS_FAIL; } @@ -2818,7 +2812,7 @@ BUILD_FAIL: int reset_ms_card(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; memset(ms_card, 0, sizeof(struct ms_info)); @@ -2905,7 +2899,7 @@ static int mspro_set_rw_cmd(struct rtsx_chip *chip, void mspro_stop_seq_mode(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; if (ms_card->seq_mode) { @@ -2923,7 +2917,7 @@ void mspro_stop_seq_mode(struct rtsx_chip *chip) static inline int ms_auto_tune_clock(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; if (chip->asic_code) { @@ -2949,7 +2943,7 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 sector_cnt) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; bool mode_2k = false; int retval; u16 count; @@ -3092,7 +3086,7 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb, static int mspro_read_format_progress(struct rtsx_chip *chip, const int short_data_len) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u32 total_progress, cur_progress; u8 cnt, tmp; @@ -3214,7 +3208,7 @@ static int mspro_read_format_progress(struct rtsx_chip *chip, void mspro_polling_format_status(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int i; if (ms_card->pro_under_formatting && @@ -3232,7 +3226,7 @@ void mspro_polling_format_status(struct rtsx_chip *chip) int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip, int short_data_len, bool quick_format) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 buf[8], tmp; u16 para; @@ -3324,7 +3318,7 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, u8 *buf, unsigned int *index, unsigned int *offset) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 extra[MS_EXTRA_SIZE], page_addr, val, trans_cfg, data[6]; u8 *ptr; @@ -3508,7 +3502,7 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, u8 end_page, u8 *buf, unsigned int *index, unsigned int *offset) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, i; u8 page_addr, val, data[16]; u8 *ptr; @@ -3729,7 +3723,7 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, static int ms_finish_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, u16 log_blk, u8 page_off) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval, seg_no; retval = ms_copy_page(chip, old_blk, new_blk, log_blk, @@ -3775,7 +3769,7 @@ static int ms_prepare_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, #ifdef MS_DELAY_WRITE int ms_delay_write(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; struct ms_delay_write_tag *delay_write = &(ms_card->delay_write); int retval; @@ -3814,7 +3808,7 @@ static inline void ms_rw_fail(struct scsi_cmnd *srb, struct rtsx_chip *chip) static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 sector_cnt) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; unsigned int lun = SCSI_LUN(srb); int retval, seg_no; unsigned int index = 0, offset = 0; @@ -4075,7 +4069,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip, int ms_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, u16 sector_cnt) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; if (CHK_MSPRO(ms_card)) @@ -4091,19 +4085,15 @@ int ms_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, void ms_free_l2p_tbl(struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int i = 0; if (ms_card->segment != NULL) { for (i = 0; i < ms_card->segment_cnt; i++) { - if (ms_card->segment[i].l2p_table != NULL) { - vfree(ms_card->segment[i].l2p_table); - ms_card->segment[i].l2p_table = NULL; - } - if (ms_card->segment[i].free_table != NULL) { - vfree(ms_card->segment[i].free_table); - ms_card->segment[i].free_table = NULL; - } + vfree(ms_card->segment[i].l2p_table); + ms_card->segment[i].l2p_table = NULL; + vfree(ms_card->segment[i].free_table); + ms_card->segment[i].free_table = NULL; } vfree(ms_card->segment); ms_card->segment = NULL; @@ -4351,7 +4341,7 @@ GetEKBFinish: int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; int bufflen; int i; @@ -4435,7 +4425,7 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; int bufflen; unsigned int lun = SCSI_LUN(srb); @@ -4495,7 +4485,7 @@ int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip) int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; int i; int bufflen; @@ -4547,7 +4537,7 @@ int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip) int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; int bufflen; unsigned int lun = SCSI_LUN(srb); @@ -4604,7 +4594,7 @@ GetICVFinish: int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) { - struct ms_info *ms_card = &(chip->ms_card); + struct ms_info *ms_card = &chip->ms_card; int retval; int bufflen; #ifdef MG_SET_ICV_SLOW diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 1fe8e3e0a3fb..25d095a5ade7 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -320,7 +320,6 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) rtsx_do_before_power_down(chip, PM_S3); if (dev->irq >= 0) { - synchronize_irq(dev->irq); free_irq(dev->irq, (void *)dev); dev->irq = -1; } @@ -398,7 +397,6 @@ static void rtsx_shutdown(struct pci_dev *pci) rtsx_do_before_power_down(chip, PM_S1); if (dev->irq >= 0) { - synchronize_irq(dev->irq); free_irq(dev->irq, (void *)dev); dev->irq = -1; } @@ -658,9 +656,6 @@ static void rtsx_release_resources(struct rtsx_dev *dev) if (dev->remap_addr) iounmap(dev->remap_addr); - pci_disable_device(dev->pci); - pci_release_regions(dev->pci); - rtsx_release_chip(dev->chip); kfree(dev->chip); } @@ -715,7 +710,7 @@ static void release_everything(struct rtsx_dev *dev) /* Thread to carry out delayed SCSI-device scanning */ static int rtsx_scan_thread(void *__dev) { - struct rtsx_dev *dev = (struct rtsx_dev *)__dev; + struct rtsx_dev *dev = __dev; struct rtsx_chip *chip = dev->chip; /* Wait for the timeout to expire or for a disconnect */ @@ -852,7 +847,7 @@ static int rtsx_probe(struct pci_dev *pci, dev_dbg(&pci->dev, "Realtek PCI-E card reader detected\n"); - err = pci_enable_device(pci); + err = pcim_enable_device(pci); if (err < 0) { dev_err(&pci->dev, "PCI enable device failed!\n"); return err; @@ -862,7 +857,6 @@ static int rtsx_probe(struct pci_dev *pci, if (err < 0) { dev_err(&pci->dev, "PCI request regions for %s failed!\n", CR_DRIVER_NAME); - pci_disable_device(pci); return err; } @@ -873,8 +867,6 @@ static int rtsx_probe(struct pci_dev *pci, host = scsi_host_alloc(&rtsx_host_template, sizeof(*dev)); if (!host) { dev_err(&pci->dev, "Unable to allocate the scsi host\n"); - pci_release_regions(pci); - pci_disable_device(pci); return -ENOMEM; } @@ -882,7 +874,7 @@ static int rtsx_probe(struct pci_dev *pci, memset(dev, 0, sizeof(struct rtsx_dev)); dev->chip = kzalloc(sizeof(struct rtsx_chip), GFP_KERNEL); - if (dev->chip == NULL) { + if (!dev->chip) { err = -ENOMEM; goto errout; } @@ -903,7 +895,7 @@ static int rtsx_probe(struct pci_dev *pci, (unsigned int)pci_resource_len(pci, 0)); dev->addr = pci_resource_start(pci, 0); dev->remap_addr = ioremap_nocache(dev->addr, pci_resource_len(pci, 0)); - if (dev->remap_addr == NULL) { + if (!dev->remap_addr) { dev_err(&pci->dev, "ioremap error\n"); err = -ENXIO; goto errout; @@ -918,7 +910,7 @@ static int rtsx_probe(struct pci_dev *pci, dev->rtsx_resv_buf = dmam_alloc_coherent(&pci->dev, RTSX_RESV_BUF_LEN, &dev->rtsx_resv_buf_addr, GFP_KERNEL); - if (dev->rtsx_resv_buf == NULL) { + if (!dev->rtsx_resv_buf) { dev_err(&pci->dev, "alloc dma buffer fail\n"); err = -ENXIO; goto errout; @@ -1011,8 +1003,6 @@ static void rtsx_remove(struct pci_dev *pci) quiesce_and_remove_host(dev); release_everything(dev); - - pci_set_drvdata(pci, NULL); } /* PCI IDs */ diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index 60871f3022b1..d2031044ea34 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -507,7 +507,7 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf = vmalloc(scsi_bufflen(srb)); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -644,7 +644,7 @@ static int request_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf = vmalloc(scsi_bufflen(srb)); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -792,7 +792,7 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip) #endif buf = kmalloc(dataSize, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1017,7 +1017,7 @@ static int read_format_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip) buf_len = (scsi_bufflen(srb) > 12) ? 0x14 : 12; buf = kmalloc(buf_len, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1096,7 +1096,7 @@ static int read_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf = kmalloc(8, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1206,7 +1206,7 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1315,7 +1315,7 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1410,7 +1410,7 @@ static int trace_msg_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) clear = srb->cmnd[2]; buf = vmalloc(scsi_bufflen(srb)); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -1931,20 +1931,15 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip) static int suit_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip) { - int result; - switch (srb->cmnd[3]) { case INIT_BATCHCMD: case ADD_BATCHCMD: case SEND_BATCHCMD: case GET_BATCHRSP: - result = rw_mem_cmd_buf(srb, chip); - break; + return rw_mem_cmd_buf(srb, chip); default: - result = TRANSPORT_ERROR; + return TRANSPORT_ERROR; } - - return result; } static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) @@ -2035,7 +2030,7 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip) len); buf = vmalloc(len); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2191,7 +2186,7 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -2295,7 +2290,7 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip) len = (u8)min_t(unsigned int, scsi_bufflen(srb), len); buf = vmalloc(len); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index f27491e802ed..4d8e7c5c26d5 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -1,4 +1,5 @@ -/* Driver for Realtek PCI-Express card reader +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * @@ -30,74 +31,76 @@ * Scatter-gather transfer buffer access routines ***********************************************************************/ -/* Copy a buffer of length buflen to/from the srb's transfer buffer. +/* + * Copy a buffer of length buflen to/from the srb's transfer buffer. * (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * points to a list of s-g entries and we ignore srb->request_bufflen. * For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will - * pick up from where this one left off. */ + * pick up from where this one left off. + */ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index, - unsigned int *offset, enum xfer_buf_dir dir) + unsigned int buflen, + struct scsi_cmnd *srb, + unsigned int *index, + unsigned int *offset, + enum xfer_buf_dir dir) { unsigned int cnt; - /* If not using scatter-gather, just transfer the data directly. - * Make certain it will fit in the available buffer space. */ + /* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count(srb) == 0) { + unsigned char *sgbuffer; + if (*offset >= scsi_bufflen(srb)) return 0; cnt = min(buflen, scsi_bufflen(srb) - *offset); + + sgbuffer = (unsigned char *)scsi_sglist(srb) + *offset; + if (dir == TO_XFER_BUF) - memcpy((unsigned char *) scsi_sglist(srb) + *offset, - buffer, cnt); + memcpy(sgbuffer, buffer, cnt); else - memcpy(buffer, (unsigned char *) scsi_sglist(srb) + - *offset, cnt); + memcpy(buffer, sgbuffer, cnt); *offset += cnt; - /* Using scatter-gather. We have to go through the list one entry + /* + * Using scatter-gather. We have to go through the list one entry * at a time. Each s-g entry contains some number of pages, and - * each page has to be kmap()'ed separately. If the page is already - * in kernel-addressable memory then kmap() will return its address. - * If the page is not directly accessible -- such as a user buffer - * located in high memory -- then kmap() will map it to a temporary - * position in the kernel's virtual address space. */ + * each page has to be kmap()'ed separately. + */ } else { struct scatterlist *sg = - (struct scatterlist *) scsi_sglist(srb) + (struct scatterlist *)scsi_sglist(srb) + *index; - /* This loop handles a single s-g list entry, which may + /* + * This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update - * the *offset and *index values for the next loop. */ + * the *offset and *index values for the next loop. + */ cnt = 0; while (cnt < buflen && *index < scsi_sg_count(srb)) { struct page *page = sg_page(sg) + ((sg->offset + *offset) >> PAGE_SHIFT); - unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE-1); + unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE - 1); unsigned int sglen = sg->length - *offset; if (sglen > buflen - cnt) { - /* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; } else { - /* Transfer continues to next s-g entry */ *offset = 0; ++*index; ++sg; } - /* Transfer the data for all the pages in this - * s-g entry. For each page: call kmap(), do the - * transfer, and call kunmap() immediately after. */ while (sglen > 0) { unsigned int plen = min(sglen, (unsigned int) PAGE_SIZE - poff); @@ -122,10 +125,12 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +/* + * Store the contents of buffer into srb's transfer buffer and set the + * SCSI residue. + */ void rtsx_stor_set_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb) + unsigned int buflen, struct scsi_cmnd *srb) { unsigned int index = 0, offset = 0; @@ -136,7 +141,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, } void rtsx_stor_get_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb) + unsigned int buflen, struct scsi_cmnd *srb) { unsigned int index = 0, offset = 0; @@ -146,12 +151,12 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer, scsi_set_resid(srb, scsi_bufflen(srb) - buflen); } - /*********************************************************************** * Transport routines ***********************************************************************/ -/* Invoke the transport and basic error-handling/recovery methods +/* + * Invoke the transport and basic error-handling/recovery methods * * This is used to send the message to the device and receive the response. */ @@ -161,20 +166,21 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) result = rtsx_scsi_handler(srb, chip); - /* if the command gets aborted by the higher layers, we need to - * short-circuit all other processing + /* + * if the command gets aborted by the higher layers, we need to + * short-circuit all other processing. */ if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) { dev_dbg(rtsx_dev(chip), "-- command was aborted\n"); srb->result = DID_ABORT << 16; - goto Handle_Errors; + goto handle_errors; } /* if there is a transport error, reset and don't auto-sense */ if (result == TRANSPORT_ERROR) { dev_dbg(rtsx_dev(chip), "-- transport indicates error, resetting\n"); srb->result = DID_ERROR << 16; - goto Handle_Errors; + goto handle_errors; } srb->result = SAM_STAT_GOOD; @@ -188,21 +194,18 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) /* set the result so the higher layers expect this data */ srb->result = SAM_STAT_CHECK_CONDITION; memcpy(srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN(srb)]), - sizeof(struct sense_data_t)); + (unsigned char *)&chip->sense_buffer[SCSI_LUN(srb)], + sizeof(struct sense_data_t)); } return; - /* Error and abort processing: try to resynchronize with the device - * by issuing a port reset. If that fails, try a class-specific - * device reset. */ -Handle_Errors: +handle_errors: return; } void rtsx_add_cmd(struct rtsx_chip *chip, - u8 cmd_type, u16 reg_addr, u8 mask, u8 data) + u8 cmd_type, u16 reg_addr, u8 mask, u8 data) { u32 *cb = (u32 *)(chip->host_cmds_ptr); u32 val = 0; @@ -221,7 +224,7 @@ void rtsx_add_cmd(struct rtsx_chip *chip, void rtsx_send_cmd_no_wait(struct rtsx_chip *chip) { - u32 val = 1 << 31; + u32 val = BIT(31); rtsx_writel(chip, RTSX_HCBAR, chip->host_cmds_addr); @@ -235,7 +238,7 @@ int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; - u32 val = 1 << 31; + u32 val = BIT(31); long timeleft; int err = 0; @@ -321,9 +324,11 @@ static inline void rtsx_add_sg_tbl( } static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, - struct scatterlist *sg, int num_sg, unsigned int *index, - unsigned int *offset, int size, - enum dma_data_direction dma_dir, int timeout) + struct scatterlist *sg, int num_sg, + unsigned int *index, + unsigned int *offset, int size, + enum dma_data_direction dma_dir, + int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; @@ -334,7 +339,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, struct scatterlist *sg_ptr; u32 val = TRIG_DMA; - if ((sg == NULL) || (num_sg <= 0) || !offset || !index) + if (!sg || (num_sg <= 0) || !offset || !index) return -EIO; if (dma_dir == DMA_TO_DEVICE) @@ -363,15 +368,16 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, spin_unlock_irq(&rtsx->reg_lock); - sg_cnt = dma_map_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt = dma_map_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg; chip->sgi = 0; - /* Usually the next entry will be @sg@ + 1, but if this sg element + /* + * Usually the next entry will be @sg@ + 1, but if this sg element * is part of a chained scatterlist, it could jump to the start of * a new scatterlist array. So here we use sg_next to move to - * the proper sg + * the proper sg. */ for (i = 0; i < *index; i++) sg_ptr = sg_next(sg_ptr); @@ -476,7 +482,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done = NULL; rtsx->trans_state = STATE_TRANS_NONE; - dma_unmap_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + dma_unmap_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); if (err < 0) rtsx_stop_cmd(chip, card); @@ -485,8 +491,9 @@ out: } static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, - struct scatterlist *sg, int num_sg, - enum dma_data_direction dma_dir, int timeout) + struct scatterlist *sg, int num_sg, + enum dma_data_direction dma_dir, + int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; @@ -496,7 +503,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, long timeleft; struct scatterlist *sg_ptr; - if ((sg == NULL) || (num_sg <= 0)) + if (!sg || (num_sg <= 0)) return -EIO; if (dma_dir == DMA_TO_DEVICE) @@ -525,7 +532,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, spin_unlock_irq(&rtsx->reg_lock); - buf_cnt = dma_map_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt = dma_map_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg; @@ -623,7 +630,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done = NULL; rtsx->trans_state = STATE_TRANS_NONE; - dma_unmap_sg(&(rtsx->pci->dev), sg, num_sg, dma_dir); + dma_unmap_sg(&rtsx->pci->dev, sg, num_sg, dma_dir); if (err < 0) rtsx_stop_cmd(chip, card); @@ -632,17 +639,18 @@ out: } static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, - size_t len, enum dma_data_direction dma_dir, int timeout) + size_t len, enum dma_data_direction dma_dir, + int timeout) { struct rtsx_dev *rtsx = chip->rtsx; struct completion trans_done; dma_addr_t addr; u8 dir; int err = 0; - u32 val = 1 << 31; + u32 val = BIT(31); long timeleft; - if ((buf == NULL) || (len <= 0)) + if (!buf || (len <= 0)) return -EIO; if (dma_dir == DMA_TO_DEVICE) @@ -652,8 +660,8 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, else return -ENXIO; - addr = dma_map_single(&(rtsx->pci->dev), buf, len, dma_dir); - if (!addr) + addr = dma_map_single(&rtsx->pci->dev, buf, len, dma_dir); + if (dma_mapping_error(&rtsx->pci->dev, addr)) return -ENOMEM; if (card == SD_CARD) @@ -706,7 +714,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done = NULL; rtsx->trans_state = STATE_TRANS_NONE; - dma_unmap_single(&(rtsx->pci->dev), addr, len, dma_dir); + dma_unmap_single(&rtsx->pci->dev, addr, len, dma_dir); if (err < 0) rtsx_stop_cmd(chip, card); @@ -715,9 +723,9 @@ out: } int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, - void *buf, size_t len, int use_sg, unsigned int *index, - unsigned int *offset, enum dma_data_direction dma_dir, - int timeout) + void *buf, size_t len, int use_sg, + unsigned int *index, unsigned int *offset, + enum dma_data_direction dma_dir, int timeout) { int err = 0; @@ -725,13 +733,16 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, if (rtsx_chk_stat(chip, RTSX_STAT_ABORT)) return -EIO; - if (use_sg) - err = rtsx_transfer_sglist_adma_partial(chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int)len, dma_dir, timeout); - else + if (use_sg) { + struct scatterlist *sg = buf; + + err = rtsx_transfer_sglist_adma_partial(chip, card, sg, use_sg, + index, offset, (int)len, + dma_dir, timeout); + } else { err = rtsx_transfer_buf(chip, card, buf, len, dma_dir, timeout); + } if (err < 0) { if (RTSX_TST_DELINK(chip)) { RTSX_CLR_DELINK(chip); @@ -744,7 +755,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, } int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len, - int use_sg, enum dma_data_direction dma_dir, int timeout) + int use_sg, enum dma_data_direction dma_dir, int timeout) { int err = 0; @@ -756,8 +767,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len, if (use_sg) { err = rtsx_transfer_sglist_adma(chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); } else { err = rtsx_transfer_buf(chip, card, buf, len, dma_dir, timeout); } diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index d6c498209b2c..87d697623cba 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -303,7 +303,7 @@ static int sd_read_data(struct rtsx_chip *chip, if (cmd_len) { dev_dbg(rtsx_dev(chip), "SD/MMC CMD %d\n", cmd[0] - 0x40); - for (i = 0; i < (cmd_len < 6 ? cmd_len : 6); i++) + for (i = 0; i < (min(cmd_len, 6)); i++) rtsx_add_cmd(chip, WRITE_REG_CMD, REG_SD_CMD0 + i, 0xFF, cmd[i]); } @@ -383,7 +383,7 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode, if (cmd_len) { dev_dbg(rtsx_dev(chip), "SD/MMC CMD %d\n", cmd[0] - 0x40); - for (i = 0; i < (cmd_len < 6 ? cmd_len : 6); i++) { + for (i = 0; i < (min(cmd_len, 6)); i++) { rtsx_add_cmd(chip, WRITE_REG_CMD, REG_SD_CMD0 + i, 0xFF, cmd[i]); } @@ -4260,10 +4260,10 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) return TRANSPORT_FAILED; } - if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) || - (0x20 != srb->cmnd[4]) || (0x43 != srb->cmnd[5]) || - (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) || - (0x64 != srb->cmnd[8])) { + if ((srb->cmnd[2] != 0x53) || (srb->cmnd[3] != 0x44) || + (srb->cmnd[4] != 0x20) || (srb->cmnd[5] != 0x43) || + (srb->cmnd[6] != 0x61) || (srb->cmnd[7] != 0x72) || + (srb->cmnd[8] != 0x64)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); rtsx_trace(chip); return TRANSPORT_FAILED; @@ -4284,7 +4284,7 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip) return TRANSPORT_FAILED; } - buf[5] = (1 == CHK_SD(sd_card)) ? 0x01 : 0x02; + buf[5] = (CHK_SD(sd_card) == 1) ? 0x01 : 0x02; if (chip->card_wp & SD_CARD) buf[5] |= 0x80; @@ -4588,7 +4588,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) cmd[4] = srb->cmnd[6]; buf = kmalloc(data_len, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -4871,7 +4871,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) u8 *buf; buf = kmalloc(data_len, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return TRANSPORT_ERROR; } @@ -5176,10 +5176,10 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) return TRANSPORT_FAILED; } - if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) || - (0x20 != srb->cmnd[4]) || (0x43 != srb->cmnd[5]) || - (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) || - (0x64 != srb->cmnd[8])) { + if ((srb->cmnd[2] != 0x53) || (srb->cmnd[3] != 0x44) || + (srb->cmnd[4] != 0x20) || (srb->cmnd[5] != 0x43) || + (srb->cmnd[6] != 0x61) || (srb->cmnd[7] != 0x72) || + (srb->cmnd[8] != 0x64)) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); rtsx_trace(chip); return TRANSPORT_FAILED; @@ -5188,7 +5188,7 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) switch (srb->cmnd[1] & 0x0F) { case 0: #ifdef SUPPORT_SD_LOCK - if (0x64 == srb->cmnd[9]) + if (srb->cmnd[9] == 0x64) sd_card->sd_lock_status |= SD_SDR_RST; #endif retval = reset_sd_card(chip); diff --git a/drivers/staging/rts5208/spi.c b/drivers/staging/rts5208/spi.c index e67e7ecc2cbd..26eb2a184f91 100644 --- a/drivers/staging/rts5208/spi.c +++ b/drivers/staging/rts5208/spi.c @@ -420,7 +420,6 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr) return STATUS_SUCCESS; } - int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val) { int retval; @@ -516,7 +515,6 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val) return STATUS_SUCCESS; } - int spi_get_status(struct scsi_cmnd *srb, struct rtsx_chip *chip) { struct spi_info *spi = &(chip->spi); @@ -664,7 +662,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip) } buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL); - if (buf == NULL) { + if (!buf) { rtsx_trace(chip); return STATUS_ERROR; } diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index 10fea7bb8f30..fc1dfe0991d4 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -903,14 +903,10 @@ static inline void free_zone(struct zone_entry *zone) zone->set_index = 0; zone->get_index = 0; zone->unused_blk_cnt = 0; - if (zone->l2p_table) { - vfree(zone->l2p_table); - zone->l2p_table = NULL; - } - if (zone->free_table) { - vfree(zone->free_table); - zone->free_table = NULL; - } + vfree(zone->l2p_table); + zone->l2p_table = NULL; + vfree(zone->free_table); + zone->free_table = NULL; } static void xd_set_unused_block(struct rtsx_chip *chip, u32 phy_blk) @@ -1435,7 +1431,7 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no) if (zone->l2p_table == NULL) { zone->l2p_table = vmalloc(2000); - if (zone->l2p_table == NULL) { + if (!zone->l2p_table) { rtsx_trace(chip); goto Build_Fail; } @@ -1444,7 +1440,7 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no) if (zone->free_table == NULL) { zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2); - if (zone->free_table == NULL) { + if (!zone->free_table) { rtsx_trace(chip); goto Build_Fail; } @@ -1588,14 +1584,10 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no) return STATUS_SUCCESS; Build_Fail: - if (zone->l2p_table) { - vfree(zone->l2p_table); - zone->l2p_table = NULL; - } - if (zone->free_table) { - vfree(zone->free_table); - zone->free_table = NULL; - } + vfree(zone->l2p_table); + zone->l2p_table = NULL; + vfree(zone->free_table); + zone->free_table = NULL; return STATUS_FAIL; } @@ -2251,14 +2243,10 @@ void xd_free_l2p_tbl(struct rtsx_chip *chip) if (xd_card->zone != NULL) { for (i = 0; i < xd_card->zone_cnt; i++) { - if (xd_card->zone[i].l2p_table != NULL) { - vfree(xd_card->zone[i].l2p_table); - xd_card->zone[i].l2p_table = NULL; - } - if (xd_card->zone[i].free_table != NULL) { - vfree(xd_card->zone[i].free_table); - xd_card->zone[i].free_table = NULL; - } + vfree(xd_card->zone[i].l2p_table); + xd_card->zone[i].l2p_table = NULL; + vfree(xd_card->zone[i].free_table); + xd_card->zone[i].free_table = NULL; } vfree(xd_card->zone); xd_card->zone = NULL; |