Skip to content

Commit

Permalink
staging: rts5139: fixed issues when config to built-in object
Browse files Browse the repository at this point in the history
Fixed two issues when CONFIG_RTS5139=y :

  - Makefile doesn't take $(CONFIG_RTS5139). It always uses obj-m and built as
    a loadable module.
  - Rename some symbols with prefix 'rts51x_' to prevent symbol name collisions
    with drivers/staging/rts_pstor when both are configured to be built-in
    objects.

  drivers/staging/rts5139/built-in.o: In function `xd_cleanup_work':
  (.text+0x1435d): multiple definition of `xd_cleanup_work'
  drivers/staging/rts_pstor/built-in.o:(.text+0x2b96a): first defined here
  drivers/staging/rts5139/built-in.o: In function `release_xd_card':
  (.text+0x14393): multiple definition of `release_xd_card'
  drivers/staging/rts_pstor/built-in.o:(.text+0x2c491): first defined here
  drivers/staging/rts5139/built-in.o: In function `set_sense_data':
  (.text+0x1e02): multiple definition of `set_sense_data'
  drivers/staging/rts_pstor/built-in.o:(.text+0xa79f): first defined here
  drivers/staging/rts5139/built-in.o: In function `ms_delay_write':
  ...

Signed-off-by: Roger Tseng <rogerable@realtek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Roger Tseng authored and Greg Kroah-Hartman committed Oct 22, 2012
1 parent 9f3059c commit 355d8ae
Show file tree
Hide file tree
Showing 19 changed files with 464 additions and 458 deletions.
22 changes: 14 additions & 8 deletions drivers/staging/rts5139/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@
# Makefile for the RTS51xx USB Card Reader drivers.
#

TARGET_MODULE := rts5139
obj-$(CONFIG_RTS5139) := rts5139.o

EXTRA_CFLAGS := -Idrivers/scsi -I$(PWD)
ccflags-y := -Idrivers/scsi

obj-m += $(TARGET_MODULE).o

common-obj := rts51x_transport.o rts51x_scsi.o rts51x_fop.o

$(TARGET_MODULE)-objs := $(common-obj) rts51x.o rts51x_chip.o rts51x_card.o \
xd.o sd.o ms.o sd_cprm.o ms_mg.o
rts5139-y := \
rts51x_transport.o \
rts51x_scsi.o \
rts51x_fop.o \
rts51x.o \
rts51x_chip.o \
rts51x_card.o \
xd.o \
sd.o \
ms.o \
sd_cprm.o \
ms_mg.o
96 changes: 48 additions & 48 deletions drivers/staging/rts5139/ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int ms_transfer_data(struct rts51x_chip *chip, u8 trans_mode, u8 tpc,
rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, MS_2K_SECTOR_MODE,
0);

trans_dma_enable(dir, chip, sec_cnt * 512, DMA_512);
rts51x_trans_dma_enable(dir, chip, sec_cnt * 512, DMA_512);

rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF,
MS_TRANSFER_START | trans_mode);
Expand Down Expand Up @@ -602,7 +602,7 @@ static int ms_prepare_reset(struct rts51x_chip *chip)
if (!chip->option.FT2_fast_mode) {
wait_timeout(250);

card_power_on(chip, MS_CARD);
rts51x_card_power_on(chip, MS_CARD);
wait_timeout(150);

#ifdef SUPPORT_OCP
Expand Down Expand Up @@ -872,7 +872,7 @@ static int msxc_change_power(struct rts51x_chip *chip, u8 mode)
int retval;
u8 buf[6];

ms_cleanup_work(chip);
rts51x_ms_cleanup_work(chip);

/* Set Parameter Register */
retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6);
Expand Down Expand Up @@ -2600,14 +2600,14 @@ static int ms_build_l2p_tbl(struct rts51x_chip *chip, int seg_no)
return STATUS_FAIL;
}

int reset_ms_card(struct rts51x_chip *chip)
int rts51x_reset_ms_card(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
int retval;

memset(ms_card, 0, sizeof(struct ms_info));

enable_card_clock(chip, MS_CARD);
rts51x_enable_card_clock(chip, MS_CARD);

retval = rts51x_select_card(chip, MS_CARD);
if (retval != STATUS_SUCCESS)
Expand Down Expand Up @@ -2936,7 +2936,7 @@ static int mspro_read_format_progress(struct rts51x_chip *chip,
return STATUS_SUCCESS;
}

void mspro_polling_format_status(struct rts51x_chip *chip)
void rts51x_mspro_polling_format_status(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
int i;
Expand All @@ -2952,25 +2952,25 @@ void mspro_polling_format_status(struct rts51x_chip *chip)
return;
}

void mspro_format_sense(struct rts51x_chip *chip, unsigned int lun)
void rts51x_mspro_format_sense(struct rts51x_chip *chip, unsigned int lun)
{
struct ms_info *ms_card = &(chip->ms_card);

if (CHK_FORMAT_STATUS(ms_card, FORMAT_SUCCESS)) {
set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE);
rts51x_set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE);
ms_card->pro_under_formatting = 0;
ms_card->progress = 0;
} else if (CHK_FORMAT_STATUS(ms_card, FORMAT_IN_PROGRESS)) {
set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04,
rts51x_set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04,
0, (u16) (ms_card->progress));
} else {
set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED);
rts51x_set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED);
ms_card->pro_under_formatting = 0;
ms_card->progress = 0;
}
}

int mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip,
int rts51x_mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip,
int short_data_len, int quick_format)
{
struct ms_info *ms_card = &(chip->ms_card);
Expand Down Expand Up @@ -3035,7 +3035,7 @@ int mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip,
ms_card->pro_under_formatting = 0;
ms_card->progress = 0;
ms_card->format_status = FORMAT_SUCCESS;
set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_NO_SENSE);
rts51x_set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_NO_SENSE);
return STATUS_SUCCESS;
}

Expand Down Expand Up @@ -3103,7 +3103,7 @@ static int ms_read_multiple_pages(struct rts51x_chip *chip, u16 phy_blk,
rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, 0);
rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, READ_PAGE_DATA);

trans_dma_enable(DMA_FROM_DEVICE, chip, 512 * page_cnt, DMA_512);
rts51x_trans_dma_enable(DMA_FROM_DEVICE, chip, 512 * page_cnt, DMA_512);

rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF,
MS_TRANSFER_START | MS_TM_MULTI_READ);
Expand Down Expand Up @@ -3307,7 +3307,7 @@ static int ms_write_multiple_pages(struct rts51x_chip *chip, u16 old_blk,
rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01,
RING_BUFFER);

trans_dma_enable(DMA_TO_DEVICE, chip, 512 * page_cnt, DMA_512);
rts51x_trans_dma_enable(DMA_TO_DEVICE, chip, 512 * page_cnt, DMA_512);

rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF,
MS_TRANSFER_START | MS_TM_MULTI_WRITE);
Expand Down Expand Up @@ -3467,7 +3467,7 @@ static int ms_read_multiple_pages(struct rts51x_chip *chip, u16 phy_blk,
rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF,
trans_cfg);

trans_dma_enable(DMA_FROM_DEVICE, chip, 512, DMA_512);
rts51x_trans_dma_enable(DMA_FROM_DEVICE, chip, 512, DMA_512);

rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF,
MS_TRANSFER_START | MS_TM_NORMAL_READ);
Expand Down Expand Up @@ -3670,7 +3670,7 @@ static int ms_write_multiple_pages(struct rts51x_chip *chip, u16 old_blk,
rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF,
WAIT_INT);

trans_dma_enable(DMA_TO_DEVICE, chip, 512, DMA_512);
rts51x_trans_dma_enable(DMA_TO_DEVICE, chip, 512, DMA_512);

rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF,
MS_TRANSFER_START | MS_TM_NORMAL_WRITE);
Expand Down Expand Up @@ -3803,10 +3803,10 @@ static int ms_prepare_write(struct rts51x_chip *chip, u16 old_blk, u16 new_blk,
return STATUS_SUCCESS;
}

int ms_delay_write(struct rts51x_chip *chip)
int rts51x_ms_delay_write(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
struct ms_delay_write_tag *delay_write = &(ms_card->delay_write);
struct rts51x_ms_delay_write_tag *delay_write = &(ms_card->delay_write);
int retval;

if (delay_write->delay_write_flag) {
Expand All @@ -3827,16 +3827,16 @@ int ms_delay_write(struct rts51x_chip *chip)
return STATUS_SUCCESS;
}

static inline void ms_rw_fail(struct scsi_cmnd *srb, struct rts51x_chip *chip)
static inline void rts51x_ms_rw_fail(struct scsi_cmnd *srb, struct rts51x_chip *chip)
{
if (srb->sc_data_direction == DMA_FROM_DEVICE)
set_sense_type(chip, SCSI_LUN(srb),
rts51x_set_sense_type(chip, SCSI_LUN(srb),
SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
else
set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
rts51x_set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
}

static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
static int rts51x_ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
u32 start_sector, u16 sector_cnt)
{
struct ms_info *ms_card = &(chip->ms_card);
Expand All @@ -3847,7 +3847,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
u8 start_page, end_page = 0, page_cnt;
u8 *buf;
void *ptr = NULL;
struct ms_delay_write_tag *delay_write = &(ms_card->delay_write);
struct rts51x_ms_delay_write_tag *delay_write = &(ms_card->delay_write);

ms_set_err_code(chip, MS_NO_ERROR);

Expand All @@ -3857,7 +3857,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,

retval = ms_switch_clock(chip);
if (retval != STATUS_SUCCESS) {
ms_rw_fail(srb, chip);
rts51x_ms_rw_fail(srb, chip);
TRACE_RET(chip, retval);
}

Expand All @@ -3873,7 +3873,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
retval = ms_build_l2p_tbl(chip, seg_no);
if (retval != STATUS_SUCCESS) {
chip->card_fail |= MS_CARD;
set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
TRACE_RET(chip, retval);
}
}
Expand All @@ -3898,7 +3898,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
start_page);
#endif
if (retval != STATUS_SUCCESS) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_WRITE_ERR);
TRACE_RET(chip, retval);
}
Expand All @@ -3911,9 +3911,9 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
old_blk = delay_write->old_phyblock;
new_blk = delay_write->new_phyblock;
} else {
retval = ms_delay_write(chip);
retval = rts51x_ms_delay_write(chip);
if (retval != STATUS_SUCCESS) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_WRITE_ERR);
TRACE_RET(chip, retval);
}
Expand All @@ -3922,7 +3922,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
log_blk - ms_start_idx[seg_no]);
new_blk = ms_get_unused_block(chip, seg_no);
if ((old_blk == 0xFFFF) || (new_blk == 0xFFFF)) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_WRITE_ERR);
TRACE_RET(chip, STATUS_FAIL);
}
Expand All @@ -3933,34 +3933,34 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
if (retval != STATUS_SUCCESS) {
if (monitor_card_cd(chip, MS_CARD) ==
CD_NOT_EXIST) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_NOT_PRESENT);
TRACE_RET(chip, STATUS_FAIL);
}

set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_WRITE_ERR);
TRACE_RET(chip, retval);
}
}
} else {
retval = ms_delay_write(chip);
retval = rts51x_ms_delay_write(chip);
if (retval != STATUS_SUCCESS) {
if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_NOT_PRESENT);
TRACE_RET(chip, STATUS_FAIL);
}

set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
TRACE_RET(chip, retval);
}
old_blk =
ms_get_l2p_tbl(chip, seg_no,
log_blk - ms_start_idx[seg_no]);
if (old_blk == 0xFFFF) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
TRACE_RET(chip, STATUS_FAIL);
}
Expand Down Expand Up @@ -3993,12 +3993,12 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,

if (retval != STATUS_SUCCESS) {
if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) {
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_NOT_PRESENT);
TRACE_RET(chip, STATUS_FAIL);
}

ms_rw_fail(srb, chip);
rts51x_ms_rw_fail(srb, chip);
TRACE_RET(chip, retval);
}
/* Update L2P table if need */
Expand Down Expand Up @@ -4030,7 +4030,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
retval = ms_build_l2p_tbl(chip, seg_no);
if (retval != STATUS_SUCCESS) {
chip->card_fail |= MS_CARD;
set_sense_type(chip, lun,
rts51x_set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_NOT_PRESENT);
TRACE_RET(chip, retval);
}
Expand All @@ -4040,14 +4040,14 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
ms_get_l2p_tbl(chip, seg_no,
log_blk - ms_start_idx[seg_no]);
if (old_blk == 0xFFFF) {
ms_rw_fail(srb, chip);
rts51x_ms_rw_fail(srb, chip);
TRACE_RET(chip, STATUS_FAIL);
}

if (srb->sc_data_direction == DMA_TO_DEVICE) {
new_blk = ms_get_unused_block(chip, seg_no);
if (new_blk == 0xFFFF) {
ms_rw_fail(srb, chip);
rts51x_ms_rw_fail(srb, chip);
TRACE_RET(chip, STATUS_FAIL);
}
}
Expand All @@ -4073,7 +4073,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
return STATUS_SUCCESS;
}

int ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
int rts51x_ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
u16 sector_cnt)
{
struct ms_info *ms_card = &(chip->ms_card);
Expand All @@ -4084,12 +4084,12 @@ int ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
mspro_rw_multi_sector(srb, chip, start_sector, sector_cnt);
else
retval =
ms_rw_multi_sector(srb, chip, start_sector, sector_cnt);
rts51x_ms_rw_multi_sector(srb, chip, start_sector, sector_cnt);

return retval;
}

void ms_free_l2p_tbl(struct rts51x_chip *chip)
void rts51x_ms_free_l2p_tbl(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
int i = 0;
Expand All @@ -4110,7 +4110,7 @@ void ms_free_l2p_tbl(struct rts51x_chip *chip)
}
}

void ms_cleanup_work(struct rts51x_chip *chip)
void rts51x_ms_cleanup_work(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);

Expand All @@ -4130,7 +4130,7 @@ void ms_cleanup_work(struct rts51x_chip *chip)
} else if ((!CHK_MSPRO(ms_card))
&& ms_card->delay_write.delay_write_flag) {
RTS51X_DEBUGP("MS: delay write\n");
ms_delay_write(chip);
rts51x_ms_delay_write(chip);
ms_card->counter = 0;
}
}
Expand Down Expand Up @@ -4161,12 +4161,12 @@ static int ms_power_off_card3v3(struct rts51x_chip *chip)
return STATUS_SUCCESS;
}

int release_ms_card(struct rts51x_chip *chip)
int rts51x_release_ms_card(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
int retval;

RTS51X_DEBUGP("release_ms_card\n");
RTS51X_DEBUGP("rts51x_release_ms_card\n");

ms_card->delay_write.delay_write_flag = 0;
ms_card->pro_under_formatting = 0;
Expand All @@ -4175,7 +4175,7 @@ int release_ms_card(struct rts51x_chip *chip)
chip->card_fail &= ~MS_CARD;
chip->card_wp &= ~MS_CARD;

ms_free_l2p_tbl(chip);
rts51x_ms_free_l2p_tbl(chip);

rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP);

Expand Down
Loading

0 comments on commit 355d8ae

Please sign in to comment.