Lines Matching refs:card
139 struct memstick_dev *card; member
160 int (*mrq_handler)(struct memstick_dev *card,
167 void (*setup_transfer)(struct memstick_dev *card,
181 static int mspro_block_complete_req(struct memstick_dev *card, int error);
193 if (msb && msb->card) { in mspro_block_bd_open()
525 static int h_mspro_block_req_init(struct memstick_dev *card, in h_mspro_block_req_init() argument
528 struct mspro_block_data *msb = memstick_get_drvdata(card); in h_mspro_block_req_init()
530 *mrq = &card->current_mrq; in h_mspro_block_req_init()
531 card->next_request = msb->mrq_handler; in h_mspro_block_req_init()
535 static int h_mspro_block_default(struct memstick_dev *card, in h_mspro_block_default() argument
538 return mspro_block_complete_req(card, (*mrq)->error); in h_mspro_block_default()
541 static int h_mspro_block_default_bad(struct memstick_dev *card, in h_mspro_block_default_bad() argument
547 static int h_mspro_block_get_ro(struct memstick_dev *card, in h_mspro_block_get_ro() argument
550 struct mspro_block_data *msb = memstick_get_drvdata(card); in h_mspro_block_get_ro()
560 return mspro_block_complete_req(card, (*mrq)->error); in h_mspro_block_get_ro()
563 static int h_mspro_block_wait_for_ced(struct memstick_dev *card, in h_mspro_block_wait_for_ced() argument
566 dev_dbg(&card->dev, "wait for ced: value %x\n", (*mrq)->data[0]); in h_mspro_block_wait_for_ced()
575 return mspro_block_complete_req(card, (*mrq)->error); in h_mspro_block_wait_for_ced()
578 static int h_mspro_block_transfer_data(struct memstick_dev *card, in h_mspro_block_transfer_data() argument
581 struct mspro_block_data *msb = memstick_get_drvdata(card); in h_mspro_block_transfer_data()
587 return mspro_block_complete_req(card, (*mrq)->error); in h_mspro_block_transfer_data()
606 card->next_request = h_mspro_block_default; in h_mspro_block_transfer_data()
618 return mspro_block_complete_req(card, in h_mspro_block_transfer_data()
621 card->next_request in h_mspro_block_transfer_data()
674 static void h_mspro_block_setup_cmd(struct memstick_dev *card, u64 offset, in h_mspro_block_setup_cmd() argument
677 struct mspro_block_data *msb = memstick_get_drvdata(card); in h_mspro_block_setup_cmd()
689 card->next_request = h_mspro_block_req_init; in h_mspro_block_setup_cmd()
691 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, in h_mspro_block_setup_cmd()
697 static int mspro_block_issue_req(struct memstick_dev *card, int chunk) in mspro_block_issue_req() argument
699 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_issue_req()
720 msb->setup_transfer(card, t_off, count); in mspro_block_issue_req()
727 memstick_new_req(card->host); in mspro_block_issue_req()
731 dev_dbg(&card->dev, "blk_fetch\n"); in mspro_block_issue_req()
734 dev_dbg(&card->dev, "issue end\n"); in mspro_block_issue_req()
738 dev_dbg(&card->dev, "trying again\n"); in mspro_block_issue_req()
743 static int mspro_block_complete_req(struct memstick_dev *card, int error) in mspro_block_complete_req() argument
745 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_complete_req()
751 dev_dbg(&card->dev, "complete %d, %d\n", msb->has_request ? 1 : 0, in mspro_block_complete_req()
759 if (error || (card->current_mrq.tpc == MSPRO_CMD_STOP)) { in mspro_block_complete_req()
774 dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error); in mspro_block_complete_req()
781 error = mspro_block_issue_req(card, chunk); in mspro_block_complete_req()
792 card->next_request = h_mspro_block_default_bad; in mspro_block_complete_req()
793 complete_all(&card->mrq_complete); in mspro_block_complete_req()
799 static void mspro_block_stop(struct memstick_dev *card) in mspro_block_stop() argument
801 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_stop()
816 wait_for_completion(&card->mrq_complete); in mspro_block_stop()
820 static void mspro_block_start(struct memstick_dev *card) in mspro_block_start() argument
822 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_start()
845 struct memstick_dev *card = q->queuedata; in mspro_block_submit_req() local
846 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_submit_req()
860 if (mspro_block_issue_req(card, 0)) in mspro_block_submit_req()
866 static int mspro_block_wait_for_ced(struct memstick_dev *card) in mspro_block_wait_for_ced() argument
868 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_wait_for_ced()
870 card->next_request = h_mspro_block_req_init; in mspro_block_wait_for_ced()
872 memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); in mspro_block_wait_for_ced()
873 memstick_new_req(card->host); in mspro_block_wait_for_ced()
874 wait_for_completion(&card->mrq_complete); in mspro_block_wait_for_ced()
875 return card->current_mrq.error; in mspro_block_wait_for_ced()
878 static int mspro_block_set_interface(struct memstick_dev *card, in mspro_block_set_interface() argument
881 struct memstick_host *host = card->host; in mspro_block_set_interface()
882 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_set_interface()
890 card->next_request = h_mspro_block_req_init; in mspro_block_set_interface()
892 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, ¶m, in mspro_block_set_interface()
895 wait_for_completion(&card->mrq_complete); in mspro_block_set_interface()
896 return card->current_mrq.error; in mspro_block_set_interface()
899 static int mspro_block_switch_interface(struct memstick_dev *card) in mspro_block_switch_interface() argument
901 struct memstick_host *host = card->host; in mspro_block_switch_interface()
902 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_switch_interface()
907 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR4); in mspro_block_switch_interface()
914 dev_name(&card->dev), rc); in mspro_block_switch_interface()
921 dev_name(&card->dev)); in mspro_block_switch_interface()
924 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR8); in mspro_block_switch_interface()
932 dev_name(&card->dev)); in mspro_block_switch_interface()
936 dev_name(&card->dev), rc); in mspro_block_switch_interface()
939 card->next_request = h_mspro_block_req_init; in mspro_block_switch_interface()
941 memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); in mspro_block_switch_interface()
942 memstick_new_req(card->host); in mspro_block_switch_interface()
943 wait_for_completion(&card->mrq_complete); in mspro_block_switch_interface()
944 rc = card->current_mrq.error; in mspro_block_switch_interface()
949 dev_name(&card->dev)); in mspro_block_switch_interface()
956 rc = memstick_set_rw_addr(card); in mspro_block_switch_interface()
958 rc = mspro_block_set_interface(card, msb->system); in mspro_block_switch_interface()
962 rc = mspro_block_wait_for_ced(card); in mspro_block_switch_interface()
979 static int mspro_block_read_attributes(struct memstick_dev *card) in mspro_block_read_attributes() argument
981 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_read_attributes()
1004 msb->setup_transfer(card, attr_offset, attr_len); in mspro_block_read_attributes()
1006 memstick_new_req(card->host); in mspro_block_read_attributes()
1007 wait_for_completion(&card->mrq_complete); in mspro_block_read_attributes()
1008 if (card->current_mrq.error) { in mspro_block_read_attributes()
1009 rc = card->current_mrq.error; in mspro_block_read_attributes()
1015 dev_name(&card->dev), be16_to_cpu(attr->signature)); in mspro_block_read_attributes()
1022 dev_name(&card->dev)); in mspro_block_read_attributes()
1053 dev_dbg(&card->dev, "adding attribute %d: id %x, address %x, " in mspro_block_read_attributes()
1106 dev_dbg(&card->dev, "reading attribute range %x, %x\n", in mspro_block_read_attributes()
1109 msb->setup_transfer(card, attr_offset, attr_len); in mspro_block_read_attributes()
1110 memstick_new_req(card->host); in mspro_block_read_attributes()
1111 wait_for_completion(&card->mrq_complete); in mspro_block_read_attributes()
1112 if (card->current_mrq.error) { in mspro_block_read_attributes()
1113 rc = card->current_mrq.error; in mspro_block_read_attributes()
1129 static int mspro_block_init_card(struct memstick_dev *card) in mspro_block_init_card() argument
1131 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_init_card()
1132 struct memstick_host *host = card->host; in mspro_block_init_card()
1138 card->reg_addr.r_offset = offsetof(struct mspro_register, status); in mspro_block_init_card()
1139 card->reg_addr.r_length = sizeof(struct ms_status_register); in mspro_block_init_card()
1140 card->reg_addr.w_offset = offsetof(struct mspro_register, param); in mspro_block_init_card()
1141 card->reg_addr.w_length = sizeof(struct mspro_param_register); in mspro_block_init_card()
1143 if (memstick_set_rw_addr(card)) in mspro_block_init_card()
1149 rc = mspro_block_wait_for_ced(card); in mspro_block_init_card()
1153 rc = mspro_block_switch_interface(card); in mspro_block_init_card()
1157 dev_dbg(&card->dev, "card activated\n"); in mspro_block_init_card()
1161 card->next_request = h_mspro_block_req_init; in mspro_block_init_card()
1163 memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL, in mspro_block_init_card()
1165 memstick_new_req(card->host); in mspro_block_init_card()
1166 wait_for_completion(&card->mrq_complete); in mspro_block_init_card()
1167 if (card->current_mrq.error) in mspro_block_init_card()
1168 return card->current_mrq.error; in mspro_block_init_card()
1170 dev_dbg(&card->dev, "card r/w status %d\n", msb->read_only ? 0 : 1); in mspro_block_init_card()
1173 rc = mspro_block_read_attributes(card); in mspro_block_init_card()
1177 dev_dbg(&card->dev, "attributes loaded\n"); in mspro_block_init_card()
1182 static int mspro_block_init_disk(struct memstick_dev *card) in mspro_block_init_disk() argument
1184 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_init_disk()
1185 struct memstick_host *host = card->host; in mspro_block_init_disk()
1215 disk_id = idr_alloc(&mspro_block_disk_idr, card, 0, 256, GFP_KERNEL); in mspro_block_init_disk()
1232 msb->queue->queuedata = card; in mspro_block_init_disk()
1247 msb->disk->driverfs_dev = &card->dev; in mspro_block_init_disk()
1257 dev_dbg(&card->dev, "capacity set %ld\n", capacity); in mspro_block_init_disk()
1287 msb->card = NULL; in mspro_block_data_clear()
1290 static int mspro_block_check_card(struct memstick_dev *card) in mspro_block_check_card() argument
1292 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_check_card()
1297 static int mspro_block_probe(struct memstick_dev *card) in mspro_block_probe() argument
1305 memstick_set_drvdata(card, msb); in mspro_block_probe()
1306 msb->card = card; in mspro_block_probe()
1309 rc = mspro_block_init_card(card); in mspro_block_probe()
1314 rc = sysfs_create_group(&card->dev.kobj, &msb->attr_group); in mspro_block_probe()
1318 rc = mspro_block_init_disk(card); in mspro_block_probe()
1320 card->check = mspro_block_check_card; in mspro_block_probe()
1321 card->stop = mspro_block_stop; in mspro_block_probe()
1322 card->start = mspro_block_start; in mspro_block_probe()
1326 sysfs_remove_group(&card->dev.kobj, &msb->attr_group); in mspro_block_probe()
1328 memstick_set_drvdata(card, NULL); in mspro_block_probe()
1334 static void mspro_block_remove(struct memstick_dev *card) in mspro_block_remove() argument
1336 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_remove()
1345 dev_dbg(&card->dev, "mspro block remove\n"); in mspro_block_remove()
1350 sysfs_remove_group(&card->dev.kobj, &msb->attr_group); in mspro_block_remove()
1357 memstick_set_drvdata(card, NULL); in mspro_block_remove()
1362 static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state) in mspro_block_suspend() argument
1364 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_suspend()
1375 static int mspro_block_resume(struct memstick_dev *card) in mspro_block_resume() argument
1377 struct mspro_block_data *msb = memstick_get_drvdata(card); in mspro_block_resume()
1384 struct memstick_host *host = card->host; in mspro_block_resume()
1395 new_msb->card = card; in mspro_block_resume()
1396 memstick_set_drvdata(card, new_msb); in mspro_block_resume()
1397 if (mspro_block_init_card(card)) in mspro_block_resume()
1416 memstick_set_drvdata(card, msb); in mspro_block_resume()