예제 #1
0
void mmc_movi_sds_add_quirk(struct mmc_card *card, int data)
{
	u32 *buffer;
	int err;
	u32 date;

	/* Only production revision 0xf1 is affected */
	if (card->cid.prod_rev != 0xf1)
		return;

	/* Read and check firmware date from Smart Report */
	buffer = kmalloc(512, GFP_KERNEL);
	if (!buffer) {
		pr_err("%s: kmalloc failed.\n", __func__);
		return;
	}

	mmc_claim_host(card->host);
	err = mmc_samsung_smart_read(card, (u8 *)buffer);
	mmc_release_host(card->host);

	if (err) {
		pr_err("%s: Failed to read Smart Report.\n",
		       mmc_hostname(card->host));
		return;
	}

	date = le32_to_cpu(buffer[81]);
	kfree(buffer);

	if (date != 0x20120413)
		return;

	pr_warn("%s: SDS fixup is needed.\n", mmc_hostname(card->host));
	card->quirks |= data;

	/* We need to fixup now, since mmc_init_card was already called. */
	err = mmc_movi_sds_fixup(card);
	if (err)
		pr_err("%s: SDS fixup failed.\n", mmc_hostname(card->host));

	init_mmc_ram(card);
}
ssize_t mmc_samsung_smart_handle(struct mmc_card *card, char *buf) 
{ 
    int err; 
    u32 *buffer; 
    ssize_t len; 
 
    buffer = kmalloc(512, GFP_KERNEL); 
    if (!buffer) { 
        pr_err("Failed to alloc memory for Smart Report\n"); 
        return 0; 
    } 
     
    mmc_claim_host(card->host); 
    err = mmc_samsung_smart_read(card, (u8 *)buffer); 
    mmc_release_host(card->host); 

    if (err) 
        len = 0; 
    else 
        len = mmc_samsung_smart_parse(buffer, buf); 

    kfree(buffer); 
    return len; 
}