/* * Initializes a host. */ static int sd_init(struct sd_host *host) { int retval; spin_lock_init(&host->lock); host->refcnt = 0; set_bit(__SD_MEDIA_CHANGED, &host->flags); host->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; sd_set_clock(host, SD_SPI_CLK); sd_calc_timeouts(host); retval = sd_init_blk_dev(host); if (!retval) { retval = sd_revalidate_disk(host->disk); if (retval < 0 || !mmc_card_present(&host->card)) { retval = -ENODEV; goto err_blk_dev; } retval = sd_init_io_thread(host); if (retval) goto err_blk_dev; add_disk(host->disk); } return retval; err_blk_dev: sd_exit_blk_dev(host); return retval; }
static int sd_welcome_card(struct sd_host *host) { int retval; /* soft reset the card */ retval = sd_reset_sequence(host); if (retval < 0 || sd_card_is_bad(host)) goto out; /* read Operating Conditions Register */ retval = sd_read_ocr(host); if (retval < 0) goto err_bad_card; /* refuse to drive cards reporting voltage ranges out of scope */ if (!(host->ocr & host->ocr_avail)) { sd_printk(KERN_WARNING, "reported OCR (%08x)" " indicates that it is not safe to use this" " card with a GameCube\n", host->ocr); retval = -ENODEV; goto err_bad_card; } /* read and decode the Card Specific Data */ retval = sd_read_csd(host); if (retval < 0) goto err_bad_card; mmc_decode_csd(&host->card); /* calculate some card access related timeouts */ sd_calc_timeouts(host); /* read and decode the Card Identification Data */ retval = sd_read_cid(host); if (retval < 0) goto err_bad_card; mmc_decode_cid(&host->card); sd_printk(KERN_INFO, "slot%d: descr \"%s\", size %luk, block %ub," " serial %08x\n", to_channel(exi_get_exi_channel(host->exi_device)), host->card.cid.prod_name, (unsigned long)((host->card.csd.capacity * (1 << host->card.csd.read_blkbits)) / 1024), 1 << host->card.csd.read_blkbits, host->card.cid.serial); retval = 0; goto out; err_bad_card: sd_card_set_bad(host); out: return retval; }