in core/ms_block.c [724:769]
static int msb_reset(struct msb_data *msb, bool full)
{
bool was_parallel = msb->regs.param.system & MEMSTICK_SYS_PAM;
struct memstick_dev *card = msb->card;
struct memstick_host *host = card->host;
int error;
/* Reset the card */
msb->regs.param.system = MEMSTICK_SYS_BAMD;
if (full) {
error = host->set_param(host,
MEMSTICK_POWER, MEMSTICK_POWER_OFF);
if (error)
goto out_error;
msb_invalidate_reg_window(msb);
error = host->set_param(host,
MEMSTICK_POWER, MEMSTICK_POWER_ON);
if (error)
goto out_error;
error = host->set_param(host,
MEMSTICK_INTERFACE, MEMSTICK_SERIAL);
if (error) {
out_error:
dbg("Failed to reset the host controller");
msb->read_only = true;
return -EFAULT;
}
}
error = msb_run_state_machine(msb, h_msb_reset);
if (error) {
dbg("Failed to reset the card");
msb->read_only = true;
return -ENODEV;
}
/* Set parallel mode */
if (was_parallel)
msb_switch_to_parallel(msb);
return 0;
}