summaryrefslogtreecommitdiff
path: root/drivers/usb/storage/realtek_cr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage/realtek_cr.c')
-rw-r--r--drivers/usb/storage/realtek_cr.c128
1 files changed, 45 insertions, 83 deletions
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 6c3586a4c956..4797228747fb 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -254,8 +254,8 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun,
/* check bulk status */
if (bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN)) {
- US_DEBUGP("Signature mismatch: got %08X, expecting %08X\n",
- le32_to_cpu(bcs->Signature), US_BULK_CS_SIGN);
+ usb_stor_dbg(us, "Signature mismatch: got %08X, expecting %08X\n",
+ le32_to_cpu(bcs->Signature), US_BULK_CS_SIGN);
return USB_STOR_TRANSPORT_ERROR;
}
@@ -351,8 +351,8 @@ static int rts51x_get_max_lun(struct us_data *us)
USB_RECIP_INTERFACE,
0, us->ifnum, us->iobuf, 1, 10 * HZ);
- US_DEBUGP("GetMaxLUN command result is %d, data is %d\n",
- result, us->iobuf[0]);
+ usb_stor_dbg(us, "GetMaxLUN command result is %d, data is %d\n",
+ result, us->iobuf[0]);
/* if we have a successful request, return the result */
if (result > 0)
@@ -371,7 +371,7 @@ static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
- US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);
+ usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
cmnd[0] = 0xF0;
cmnd[1] = 0x0D;
@@ -402,7 +402,7 @@ static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
- US_DEBUGP("%s, addr = 0x%x, len = %d\n", __func__, addr, len);
+ usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
cmnd[0] = 0xF0;
cmnd[1] = 0x0E;
@@ -431,7 +431,7 @@ static int rts51x_read_status(struct us_data *us,
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
- US_DEBUGP("%s, lun = %d\n", __func__, lun);
+ usb_stor_dbg(us, "lun = %d\n", lun);
cmnd[0] = 0xF0;
cmnd[1] = 0x09;
@@ -458,7 +458,7 @@ static int rts51x_check_status(struct us_data *us, u8 lun)
if (retval != STATUS_SUCCESS)
return -EIO;
- US_DEBUGP("chip->status_len = %d\n", chip->status_len);
+ usb_stor_dbg(us, "chip->status_len = %d\n", chip->status_len);
chip->status[lun].vid = ((u16) buf[0] << 8) | buf[1];
chip->status[lun].pid = ((u16) buf[2] << 8) | buf[3];
@@ -509,7 +509,7 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len)
u8 cmnd[12] = {0};
u8 *buf;
- US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len);
+ usb_stor_dbg(us, "addr = 0xfe47, len = %d\n", len);
buf = kmemdup(data, len, GFP_NOIO);
if (!buf)
@@ -549,7 +549,7 @@ static int do_config_autodelink(struct us_data *us, int enable, int force)
value &= ~0x03;
}
- US_DEBUGP("In %s,set 0xfe47 to 0x%x\n", __func__, value);
+ usb_stor_dbg(us, "set 0xfe47 to 0x%x\n", value);
/* retval = rts51x_write_mem(us, 0xFE47, &value, 1); */
retval = __do_config_autodelink(us, &value, 1);
@@ -565,8 +565,6 @@ static int config_autodelink_after_power_on(struct us_data *us)
int retval;
u8 value;
- US_DEBUGP("%s: <---\n", __func__);
-
if (!CHK_AUTO_DELINK(chip))
return 0;
@@ -624,8 +622,6 @@ static int config_autodelink_after_power_on(struct us_data *us)
}
}
- US_DEBUGP("%s: --->\n", __func__);
-
return 0;
}
@@ -635,8 +631,6 @@ static int config_autodelink_before_power_down(struct us_data *us)
int retval;
u8 value;
- US_DEBUGP("%s: <---\n", __func__);
-
if (!CHK_AUTO_DELINK(chip))
return 0;
@@ -698,8 +692,6 @@ static int config_autodelink_before_power_down(struct us_data *us)
}
}
- US_DEBUGP("%s: --->\n", __func__);
-
return 0;
}
@@ -709,23 +701,19 @@ static void fw5895_init(struct us_data *us)
int retval;
u8 val;
- US_DEBUGP("%s: <---\n", __func__);
-
if ((PRODUCT_ID(chip) != 0x0158) || (FW_VERSION(chip) != 0x5895)) {
- US_DEBUGP("Not the specified device, return immediately!\n");
+ usb_stor_dbg(us, "Not the specified device, return immediately!\n");
} else {
retval = rts51x_read_mem(us, 0xFD6F, &val, 1);
if (retval == STATUS_SUCCESS && (val & 0x1F) == 0) {
val = 0x1F;
retval = rts51x_write_mem(us, 0xFD70, &val, 1);
if (retval != STATUS_SUCCESS)
- US_DEBUGP("Write memory fail\n");
+ usb_stor_dbg(us, "Write memory fail\n");
} else {
- US_DEBUGP("Read memory fail, OR (val & 0x1F) != 0\n");
+ usb_stor_dbg(us, "Read memory fail, OR (val & 0x1F) != 0\n");
}
}
-
- US_DEBUGP("%s: --->\n", __func__);
}
#ifdef CONFIG_REALTEK_AUTOPM
@@ -735,10 +723,8 @@ static void fw5895_set_mmc_wp(struct us_data *us)
int retval;
u8 buf[13];
- US_DEBUGP("%s: <---\n", __func__);
-
if ((PRODUCT_ID(chip) != 0x0158) || (FW_VERSION(chip) != 0x5895)) {
- US_DEBUGP("Not the specified device, return immediately!\n");
+ usb_stor_dbg(us, "Not the specified device, return immediately!\n");
} else {
retval = rts51x_read_mem(us, 0xFD6F, buf, 1);
if (retval == STATUS_SUCCESS && (buf[0] & 0x24) == 0x24) {
@@ -748,26 +734,24 @@ static void fw5895_set_mmc_wp(struct us_data *us)
buf[0] |= 0x04;
retval = rts51x_write_mem(us, 0xFD70, buf, 1);
if (retval != STATUS_SUCCESS)
- US_DEBUGP("Write memory fail\n");
+ usb_stor_dbg(us, "Write memory fail\n");
} else {
- US_DEBUGP("Read memory fail\n");
+ usb_stor_dbg(us, "Read memory fail\n");
}
} else {
- US_DEBUGP("Read memory fail, OR (buf[0]&0x24)!=0x24\n");
+ usb_stor_dbg(us, "Read memory fail, OR (buf[0]&0x24)!=0x24\n");
}
}
-
- US_DEBUGP("%s: --->\n", __func__);
}
static void rts51x_modi_suspend_timer(struct rts51x_chip *chip)
{
- US_DEBUGP("%s: <---, state:%d\n", __func__, rts51x_get_stat(chip));
+ struct us_data *us = chip->us;
+
+ usb_stor_dbg(us, "state:%d\n", rts51x_get_stat(chip));
chip->timer_expires = jiffies + msecs_to_jiffies(1000*ss_delay);
mod_timer(&chip->rts51x_suspend_timer, chip->timer_expires);
-
- US_DEBUGP("%s: --->\n", __func__);
}
static void rts51x_suspend_timer_fn(unsigned long data)
@@ -775,8 +759,6 @@ static void rts51x_suspend_timer_fn(unsigned long data)
struct rts51x_chip *chip = (struct rts51x_chip *)data;
struct us_data *us = chip->us;
- US_DEBUGP("%s: <---\n", __func__);
-
switch (rts51x_get_stat(chip)) {
case RTS51X_STAT_INIT:
case RTS51X_STAT_RUN:
@@ -784,32 +766,25 @@ static void rts51x_suspend_timer_fn(unsigned long data)
break;
case RTS51X_STAT_IDLE:
case RTS51X_STAT_SS:
- US_DEBUGP("%s: RTS51X_STAT_SS, intf->pm_usage_cnt:%d,"
- "power.usage:%d\n", __func__,
- atomic_read(&us->pusb_intf->pm_usage_cnt),
- atomic_read(&us->pusb_intf->dev.power.usage_count));
+ usb_stor_dbg(us, "RTS51X_STAT_SS, intf->pm_usage_cnt:%d, power.usage:%d\n",
+ atomic_read(&us->pusb_intf->pm_usage_cnt),
+ atomic_read(&us->pusb_intf->dev.power.usage_count));
if (atomic_read(&us->pusb_intf->pm_usage_cnt) > 0) {
- US_DEBUGP("%s: Ready to enter SS state.\n",
- __func__);
+ usb_stor_dbg(us, "Ready to enter SS state\n");
rts51x_set_stat(chip, RTS51X_STAT_SS);
/* ignore mass storage interface's children */
pm_suspend_ignore_children(&us->pusb_intf->dev, true);
usb_autopm_put_interface_async(us->pusb_intf);
- US_DEBUGP("%s: RTS51X_STAT_SS 01,"
- "intf->pm_usage_cnt:%d, power.usage:%d\n",
- __func__,
- atomic_read(&us->pusb_intf->pm_usage_cnt),
- atomic_read(
- &us->pusb_intf->dev.power.usage_count));
+ usb_stor_dbg(us, "RTS51X_STAT_SS 01, intf->pm_usage_cnt:%d, power.usage:%d\n",
+ atomic_read(&us->pusb_intf->pm_usage_cnt),
+ atomic_read(&us->pusb_intf->dev.power.usage_count));
}
break;
default:
- US_DEBUGP("%s: Unknonwn state !!!\n", __func__);
+ usb_stor_dbg(us, "Unknown state !!!\n");
break;
}
-
- US_DEBUGP("%s: --->\n", __func__);
}
static inline int working_scsi(struct scsi_cmnd *srb)
@@ -834,24 +809,21 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
};
int ret;
- US_DEBUGP("%s: <---\n", __func__);
-
if (working_scsi(srb)) {
- US_DEBUGP("%s: working scsi, intf->pm_usage_cnt:%d,"
- "power.usage:%d\n", __func__,
- atomic_read(&us->pusb_intf->pm_usage_cnt),
- atomic_read(&us->pusb_intf->dev.power.usage_count));
+ usb_stor_dbg(us, "working scsi, intf->pm_usage_cnt:%d, power.usage:%d\n",
+ atomic_read(&us->pusb_intf->pm_usage_cnt),
+ atomic_read(&us->pusb_intf->dev.power.usage_count));
if (atomic_read(&us->pusb_intf->pm_usage_cnt) <= 0) {
ret = usb_autopm_get_interface(us->pusb_intf);
- US_DEBUGP("%s: working scsi, ret=%d\n", __func__, ret);
+ usb_stor_dbg(us, "working scsi, ret=%d\n", ret);
}
if (rts51x_get_stat(chip) != RTS51X_STAT_RUN)
rts51x_set_stat(chip, RTS51X_STAT_RUN);
chip->proto_handler_backup(srb, us);
} else {
if (rts51x_get_stat(chip) == RTS51X_STAT_SS) {
- US_DEBUGP("%s: NOT working scsi\n", __func__);
+ usb_stor_dbg(us, "NOT working scsi\n");
if ((srb->cmnd[0] == TEST_UNIT_READY) &&
(chip->pwr_state == US_SUSPEND)) {
if (TST_LUN_READY(chip, srb->device->lun)) {
@@ -862,8 +834,7 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
media_not_present,
US_SENSE_SIZE);
}
- US_DEBUGP("%s: TEST_UNIT_READY--->\n",
- __func__);
+ usb_stor_dbg(us, "TEST_UNIT_READY\n");
goto out;
}
if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
@@ -876,12 +847,11 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
} else {
srb->result = SAM_STAT_GOOD;
}
- US_DEBUGP("%s: ALLOW_MEDIUM_REMOVAL--->\n",
- __func__);
+ usb_stor_dbg(us, "ALLOW_MEDIUM_REMOVAL\n");
goto out;
}
} else {
- US_DEBUGP("%s: NOT working scsi, not SS\n", __func__);
+ usb_stor_dbg(us, "NOT working scsi, not SS\n");
chip->proto_handler_backup(srb, us);
/* Check whether card is plugged in */
if (srb->cmnd[0] == TEST_UNIT_READY) {
@@ -901,11 +871,9 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
}
}
out:
- US_DEBUGP("%s: state:%d\n", __func__, rts51x_get_stat(chip));
+ usb_stor_dbg(us, "state:%d\n", rts51x_get_stat(chip));
if (rts51x_get_stat(chip) == RTS51X_STAT_RUN)
rts51x_modi_suspend_timer(chip);
-
- US_DEBUGP("%s: --->\n", __func__);
}
static int realtek_cr_autosuspend_setup(struct us_data *us)
@@ -923,7 +891,7 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
retval = rts51x_read_status(us, 0, buf, 16, &(chip->status_len));
if (retval != STATUS_SUCCESS) {
- US_DEBUGP("Read status fail\n");
+ usb_stor_dbg(us, "Read status fail\n");
return -EIO;
}
status = chip->status;
@@ -966,11 +934,13 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
static void realtek_cr_destructor(void *extra)
{
struct rts51x_chip *chip = (struct rts51x_chip *)extra;
-
- US_DEBUGP("%s: <---\n", __func__);
+ struct us_data *us;
if (!chip)
return;
+
+ us = chip->us;
+
#ifdef CONFIG_REALTEK_AUTOPM
if (ss_en) {
del_timer(&chip->rts51x_suspend_timer);
@@ -985,8 +955,6 @@ static int realtek_cr_suspend(struct usb_interface *iface, pm_message_t message)
{
struct us_data *us = usb_get_intfdata(iface);
- US_DEBUGP("%s: <---\n", __func__);
-
/* wait until no command is running */
mutex_lock(&us->dev_mutex);
@@ -994,8 +962,6 @@ static int realtek_cr_suspend(struct usb_interface *iface, pm_message_t message)
mutex_unlock(&us->dev_mutex);
- US_DEBUGP("%s: --->\n", __func__);
-
return 0;
}
@@ -1003,13 +969,9 @@ static int realtek_cr_resume(struct usb_interface *iface)
{
struct us_data *us = usb_get_intfdata(iface);
- US_DEBUGP("%s: <---\n", __func__);
-
fw5895_init(us);
config_autodelink_after_power_on(us);
- US_DEBUGP("%s: --->\n", __func__);
-
return 0;
}
#else
@@ -1030,7 +992,7 @@ static int init_realtek_cr(struct us_data *us)
us->extra_destructor = realtek_cr_destructor;
us->max_lun = chip->max_lun = rts51x_get_max_lun(us);
- US_DEBUGP("chip->max_lun = %d\n", chip->max_lun);
+ usb_stor_dbg(us, "chip->max_lun = %d\n", chip->max_lun);
size = (chip->max_lun + 1) * sizeof(struct rts51x_status);
chip->status = kzalloc(size, GFP_KERNEL);
@@ -1057,7 +1019,7 @@ static int init_realtek_cr(struct us_data *us)
}
#endif
- US_DEBUGP("chip->flag = 0x%x\n", chip->flag);
+ usb_stor_dbg(us, "chip->flag = 0x%x\n", chip->flag);
(void)config_autodelink_after_power_on(us);
@@ -1079,7 +1041,7 @@ static int realtek_cr_probe(struct usb_interface *intf,
struct us_data *us;
int result;
- US_DEBUGP("Probe Realtek Card Reader!\n");
+ dev_dbg(&intf->dev, "Probe Realtek Card Reader!\n");
result = usb_stor_probe1(&us, intf, id,
(id - realtek_cr_ids) +