/* * Checks if media is still valid. */ static int sd_revalidate_disk(struct gendisk *disk) { struct sd_host *host = disk->private_data; int retval = 0; /* report missing medium for zombies */ if (!host) { retval = -ENOMEDIUM; goto out; } /* the block layer likes to call us multiple times... */ if (!sd_media_changed(host->disk)) goto out; /* get the card into a known status */ retval = sd_welcome_card(host); if (retval < 0 || sd_card_is_bad(host)) { retval = -ENOMEDIUM; goto out; } /* inform the block layer about various sizes */ blk_queue_logical_block_size(host->queue, 1 << KERNEL_SECTOR_SHIFT); set_capacity(host->disk, host->card.csd.capacity /*<< (host->card.csd.read_blkbits - KERNEL_SECTOR_SHIFT)*/); clear_bit(__SD_MEDIA_CHANGED, &host->flags); out: 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; }