aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/memstick/core
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2008-03-19 20:01:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-03-19 21:53:37 -0400
commitead70773608a5d97f81cb492f117d20b5e9f323e (patch)
treefa71036f83c49c3b7aee99c11d152ddeb2b3599e /drivers/memstick/core
parent9df130392fb642ecd5564163b574ce69ffda1afa (diff)
memstick: automatically retrieve "INT" value from command response
MemoryStick storage cards, when in parallel mode, send several meaningful bits of their "INT" register as part of command response. This data is stored by host and can be used to spare invocation of "GET_INT" TPC on each data page transferred between host and card. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/memstick/core')
-rw-r--r--drivers/memstick/core/memstick.c9
-rw-r--r--drivers/memstick/core/mspro_block.c15
2 files changed, 12 insertions, 12 deletions
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index de80dba12f9b..946e3d3506ac 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -276,8 +276,6 @@ void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc,
276 mrq->need_card_int = 1; 276 mrq->need_card_int = 1;
277 else 277 else
278 mrq->need_card_int = 0; 278 mrq->need_card_int = 0;
279
280 mrq->get_int_reg = 0;
281} 279}
282EXPORT_SYMBOL(memstick_init_req_sg); 280EXPORT_SYMBOL(memstick_init_req_sg);
283 281
@@ -311,8 +309,6 @@ void memstick_init_req(struct memstick_request *mrq, unsigned char tpc,
311 mrq->need_card_int = 1; 309 mrq->need_card_int = 1;
312 else 310 else
313 mrq->need_card_int = 0; 311 mrq->need_card_int = 0;
314
315 mrq->get_int_reg = 0;
316} 312}
317EXPORT_SYMBOL(memstick_init_req); 313EXPORT_SYMBOL(memstick_init_req);
318 314
@@ -342,6 +338,7 @@ static int h_memstick_read_dev_id(struct memstick_dev *card,
342 card->id.class = id_reg.class; 338 card->id.class = id_reg.class;
343 } 339 }
344 complete(&card->mrq_complete); 340 complete(&card->mrq_complete);
341 dev_dbg(&card->dev, "if_mode = %02x\n", id_reg.if_mode);
345 return -EAGAIN; 342 return -EAGAIN;
346 } 343 }
347} 344}
@@ -422,7 +419,6 @@ static void memstick_power_on(struct memstick_host *host)
422{ 419{
423 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); 420 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON);
424 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); 421 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL);
425 msleep(1);
426} 422}
427 423
428static void memstick_check(struct work_struct *work) 424static void memstick_check(struct work_struct *work)
@@ -579,7 +575,8 @@ EXPORT_SYMBOL(memstick_suspend_host);
579void memstick_resume_host(struct memstick_host *host) 575void memstick_resume_host(struct memstick_host *host)
580{ 576{
581 mutex_lock(&host->lock); 577 mutex_lock(&host->lock);
582 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); 578 if (host->card)
579 memstick_power_on(host);
583 mutex_unlock(&host->lock); 580 mutex_unlock(&host->lock);
584 memstick_detect_change(host); 581 memstick_detect_change(host);
585} 582}
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 1d637e4561d3..e5356f97d076 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -133,6 +133,7 @@ struct mspro_devinfo {
133struct mspro_block_data { 133struct mspro_block_data {
134 struct memstick_dev *card; 134 struct memstick_dev *card;
135 unsigned int usage_count; 135 unsigned int usage_count;
136 unsigned int caps;
136 struct gendisk *disk; 137 struct gendisk *disk;
137 struct request_queue *queue; 138 struct request_queue *queue;
138 spinlock_t q_lock; 139 spinlock_t q_lock;
@@ -577,7 +578,6 @@ static int h_mspro_block_wait_for_ced(struct memstick_dev *card,
577static int h_mspro_block_transfer_data(struct memstick_dev *card, 578static int h_mspro_block_transfer_data(struct memstick_dev *card,
578 struct memstick_request **mrq) 579 struct memstick_request **mrq)
579{ 580{
580 struct memstick_host *host = card->host;
581 struct mspro_block_data *msb = memstick_get_drvdata(card); 581 struct mspro_block_data *msb = memstick_get_drvdata(card);
582 unsigned char t_val = 0; 582 unsigned char t_val = 0;
583 struct scatterlist t_sg = { 0 }; 583 struct scatterlist t_sg = { 0 };
@@ -591,12 +591,12 @@ static int h_mspro_block_transfer_data(struct memstick_dev *card,
591 switch ((*mrq)->tpc) { 591 switch ((*mrq)->tpc) {
592 case MS_TPC_WRITE_REG: 592 case MS_TPC_WRITE_REG:
593 memstick_init_req(*mrq, MS_TPC_SET_CMD, &msb->transfer_cmd, 1); 593 memstick_init_req(*mrq, MS_TPC_SET_CMD, &msb->transfer_cmd, 1);
594 (*mrq)->get_int_reg = 1; 594 (*mrq)->need_card_int = 1;
595 return 0; 595 return 0;
596 case MS_TPC_SET_CMD: 596 case MS_TPC_SET_CMD:
597 t_val = (*mrq)->int_reg; 597 t_val = (*mrq)->int_reg;
598 memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); 598 memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1);
599 if (host->caps & MEMSTICK_CAP_AUTO_GET_INT) 599 if (msb->caps & MEMSTICK_CAP_AUTO_GET_INT)
600 goto has_int_reg; 600 goto has_int_reg;
601 return 0; 601 return 0;
602 case MS_TPC_GET_INT: 602 case MS_TPC_GET_INT:
@@ -646,12 +646,12 @@ has_int_reg:
646 ? MS_TPC_READ_LONG_DATA 646 ? MS_TPC_READ_LONG_DATA
647 : MS_TPC_WRITE_LONG_DATA, 647 : MS_TPC_WRITE_LONG_DATA,
648 &t_sg); 648 &t_sg);
649 (*mrq)->get_int_reg = 1; 649 (*mrq)->need_card_int = 1;
650 return 0; 650 return 0;
651 case MS_TPC_READ_LONG_DATA: 651 case MS_TPC_READ_LONG_DATA:
652 case MS_TPC_WRITE_LONG_DATA: 652 case MS_TPC_WRITE_LONG_DATA:
653 msb->current_page++; 653 msb->current_page++;
654 if (host->caps & MEMSTICK_CAP_AUTO_GET_INT) { 654 if (msb->caps & MEMSTICK_CAP_AUTO_GET_INT) {
655 t_val = (*mrq)->int_reg; 655 t_val = (*mrq)->int_reg;
656 goto has_int_reg; 656 goto has_int_reg;
657 } else { 657 } else {
@@ -1052,7 +1052,8 @@ static int mspro_block_init_card(struct memstick_dev *card)
1052 if (memstick_set_rw_addr(card)) 1052 if (memstick_set_rw_addr(card))
1053 return -EIO; 1053 return -EIO;
1054 1054
1055 if (host->caps & MEMSTICK_CAP_PAR4) { 1055 msb->caps = host->caps;
1056 if (msb->caps & MEMSTICK_CAP_PAR4) {
1056 if (mspro_block_switch_to_parallel(card)) 1057 if (mspro_block_switch_to_parallel(card))
1057 printk(KERN_WARNING "%s: could not switch to " 1058 printk(KERN_WARNING "%s: could not switch to "
1058 "parallel interface\n", card->dev.bus_id); 1059 "parallel interface\n", card->dev.bus_id);
@@ -1062,6 +1063,8 @@ static int mspro_block_init_card(struct memstick_dev *card)
1062 if (rc) 1063 if (rc)
1063 return rc; 1064 return rc;
1064 dev_dbg(&card->dev, "card activated\n"); 1065 dev_dbg(&card->dev, "card activated\n");
1066 if (msb->system != MEMSTICK_SYS_SERIAL)
1067 msb->caps |= MEMSTICK_CAP_AUTO_GET_INT;
1065 1068
1066 card->next_request = h_mspro_block_req_init; 1069 card->next_request = h_mspro_block_req_init;
1067 msb->mrq_handler = h_mspro_block_get_ro; 1070 msb->mrq_handler = h_mspro_block_get_ro;