platform/msm_shared/mmc.c
static unsigned int
mmc_boot_decode_and_save_cid(struct mmc_boot_card *card, unsigned int *raw_cid)
{
	struct mmc_boot_cid mmc_cid;
	unsigned int mmc_sizeof = 0;
	int i = 0;

	if ((card == NULL) || (raw_cid == NULL)) {
		return MMC_BOOT_E_INVAL;
	}

	mmc_sizeof = sizeof(unsigned int) * 8;

	if ((card->type == MMC_BOOT_TYPE_SDHC)
	    || (card->type == MMC_BOOT_TYPE_STD_SD)) {
		mmc_cid.mid = UNPACK_BITS(raw_cid, 120, 8, mmc_sizeof);
		mmc_cid.oid = UNPACK_BITS(raw_cid, 104, 16, mmc_sizeof);

		for (i = 0; i < 5; i++) {
			mmc_cid.pnm[i] = (unsigned char)UNPACK_BITS(raw_cid,
								    (104 -
								     8 * (i +
									  1)),
								    8,
								    mmc_sizeof);
		}
		mmc_cid.pnm[5] = 0;
		mmc_cid.pnm[6] = 0;

		mmc_cid.prv = UNPACK_BITS(raw_cid, 56, 8, mmc_sizeof);
		mmc_cid.psn = UNPACK_BITS(raw_cid, 24, 32, mmc_sizeof);
		mmc_cid.month = UNPACK_BITS(raw_cid, 8, 4, mmc_sizeof);
		mmc_cid.year = UNPACK_BITS(raw_cid, 12, 8, mmc_sizeof);
		mmc_cid.year += 2000;
	} else {
		mmc_cid.mid = UNPACK_BITS(raw_cid, 120, 8, mmc_sizeof);
		mmc_cid.oid = UNPACK_BITS(raw_cid, 104, 16, mmc_sizeof);

		for (i = 0; i < 6; i++) {
			mmc_cid.pnm[i] = (unsigned char)UNPACK_BITS(raw_cid,
								    (104 -
								     8 * (i +
									  1)),
								    8,
								    mmc_sizeof);
		}
		mmc_cid.pnm[6] = 0;

		mmc_cid.prv = UNPACK_BITS(raw_cid, 48, 8, mmc_sizeof);
		mmc_cid.psn = UNPACK_BITS(raw_cid, 16, 32, mmc_sizeof);
		mmc_cid.month = UNPACK_BITS(raw_cid, 8, 4, mmc_sizeof);
		mmc_cid.year = UNPACK_BITS(raw_cid, 12, 4, mmc_sizeof);
		mmc_cid.year += 1997;
	}

	/* save it in card database */
	memcpy((struct mmc_boot_cid *)&card->cid,
	       (struct mmc_boot_cid *)&mmc_cid, sizeof(struct mmc_boot_cid));

	dprintf(SPEW, "Decoded CID fields:\n");
	dprintf(SPEW, "Manufacturer ID: %x\n", mmc_cid.mid);
	dprintf(SPEW, "OEM ID: 0x%x\n", mmc_cid.oid);
	dprintf(SPEW, "Product Name: %s\n", mmc_cid.pnm);
	dprintf(SPEW, "Product revision: %d.%d\n", (mmc_cid.prv >> 4),
		(mmc_cid.prv & 0xF));
	dprintf(SPEW, "Product serial number: %X\n", mmc_cid.psn);
	dprintf(SPEW, "Manufacturing date: %d %d\n", mmc_cid.month,
		mmc_cid.year);

	return MMC_BOOT_E_SUCCESS;
}
/*
 * Decode CID sent by the card.
 */
Decode CID sent by the card.
Decode CID sent by the card .
static unsigned int
mmc_boot_decode_and_save_cid(struct mmc_boot_card *card, unsigned int *raw_cid)
{
	struct mmc_boot_cid mmc_cid;
	unsigned int mmc_sizeof = 0;
	int i = 0;
	if ((card == NULL) || (raw_cid == NULL)) {
		return MMC_BOOT_E_INVAL;
	}
	mmc_sizeof = sizeof(unsigned int) * 8;
	if ((card->type == MMC_BOOT_TYPE_SDHC)
	    || (card->type == MMC_BOOT_TYPE_STD_SD)) {
		mmc_cid.mid = UNPACK_BITS(raw_cid, 120, 8, mmc_sizeof);
		mmc_cid.oid = UNPACK_BITS(raw_cid, 104, 16, mmc_sizeof);
		for (i = 0; i < 5; i++) {
			mmc_cid.pnm[i] = (unsigned char)UNPACK_BITS(raw_cid,
								    (104 -
								     8 * (i +
									  1)),
								    8,
								    mmc_sizeof);
		}
		mmc_cid.pnm[5] = 0;
		mmc_cid.pnm[6] = 0;
		mmc_cid.prv = UNPACK_BITS(raw_cid, 56, 8, mmc_sizeof);
		mmc_cid.psn = UNPACK_BITS(raw_cid, 24, 32, mmc_sizeof);
		mmc_cid.month = UNPACK_BITS(raw_cid, 8, 4, mmc_sizeof);
		mmc_cid.year = UNPACK_BITS(raw_cid, 12, 8, mmc_sizeof);
		mmc_cid.year += 2000;
	} else {
		mmc_cid.mid = UNPACK_BITS(raw_cid, 120, 8, mmc_sizeof);
		mmc_cid.oid = UNPACK_BITS(raw_cid, 104, 16, mmc_sizeof);
		for (i = 0; i < 6; i++) {
			mmc_cid.pnm[i] = (unsigned char)UNPACK_BITS(raw_cid,
								    (104 -
								     8 * (i +
									  1)),
								    8,
								    mmc_sizeof);
		}
		mmc_cid.pnm[6] = 0;
		mmc_cid.prv = UNPACK_BITS(raw_cid, 48, 8, mmc_sizeof);
		mmc_cid.psn = UNPACK_BITS(raw_cid, 16, 32, mmc_sizeof);
		mmc_cid.month = UNPACK_BITS(raw_cid, 8, 4, mmc_sizeof);
		mmc_cid.year = UNPACK_BITS(raw_cid, 12, 4, mmc_sizeof);
		mmc_cid.year += 1997;
	}
	memcpy((struct mmc_boot_cid *)&card->cid,
	       (struct mmc_boot_cid *)&mmc_cid, sizeof(struct mmc_boot_cid));
	dprintf(SPEW, "Decoded CID fields:\n");
	dprintf(SPEW, "Manufacturer ID: %x\n", mmc_cid.mid);
	dprintf(SPEW, "OEM ID: 0x%x\n", mmc_cid.oid);
	dprintf(SPEW, "Product Name: %s\n", mmc_cid.pnm);
	dprintf(SPEW, "Product revision: %d.%d\n", (mmc_cid.prv >> 4),
		(mmc_cid.prv & 0xF));
	dprintf(SPEW, "Product serial number: %X\n", mmc_cid.psn);
	dprintf(SPEW, "Manufacturing date: %d %d\n", mmc_cid.month,
		mmc_cid.year);
	return MMC_BOOT_E_SUCCESS;
}
static unsigned int mmc_boot_decode_and_save_cid ( struct mmc_boot_card * card , unsigned int * raw_cid ) { struct mmc_boot_cid mmc_cid ; unsigned int mmc_sizeof = 0 ; int i = 0 ; if ( ( card == NULL ) || ( raw_cid == NULL ) ) { return MMC_BOOT_E_INVAL ; } mmc_sizeof = sizeof ( unsigned int ) * 8 ; if ( ( card -> type == MMC_BOOT_TYPE_SDHC ) || ( card -> type == MMC_BOOT_TYPE_STD_SD ) ) { mmc_cid . mid = UNPACK_BITS ( raw_cid , 120 , 8 , mmc_sizeof ) ; mmc_cid . oid = UNPACK_BITS ( raw_cid , 104 , 16 , mmc_sizeof ) ; for ( i = 0 ; i < 5 ; i ++ ) { mmc_cid . pnm [ i ] = ( unsigned char ) UNPACK_BITS ( raw_cid , ( 104 - 8 * ( i + 1 ) ) , 8 , mmc_sizeof ) ; } mmc_cid . pnm [ 5 ] = 0 ; mmc_cid . pnm [ 6 ] = 0 ; mmc_cid . prv = UNPACK_BITS ( raw_cid , 56 , 8 , mmc_sizeof ) ; mmc_cid . psn = UNPACK_BITS ( raw_cid , 24 , 32 , mmc_sizeof ) ; mmc_cid . month = UNPACK_BITS ( raw_cid , 8 , 4 , mmc_sizeof ) ; mmc_cid . year = UNPACK_BITS ( raw_cid , 12 , 8 , mmc_sizeof ) ; mmc_cid . year += 2000 ; } else { mmc_cid . mid = UNPACK_BITS ( raw_cid , 120 , 8 , mmc_sizeof ) ; mmc_cid . oid = UNPACK_BITS ( raw_cid , 104 , 16 , mmc_sizeof ) ; for ( i = 0 ; i < 6 ; i ++ ) { mmc_cid . pnm [ i ] = ( unsigned char ) UNPACK_BITS ( raw_cid , ( 104 - 8 * ( i + 1 ) ) , 8 , mmc_sizeof ) ; } mmc_cid . pnm [ 6 ] = 0 ; mmc_cid . prv = UNPACK_BITS ( raw_cid , 48 , 8 , mmc_sizeof ) ; mmc_cid . psn = UNPACK_BITS ( raw_cid , 16 , 32 , mmc_sizeof ) ; mmc_cid . month = UNPACK_BITS ( raw_cid , 8 , 4 , mmc_sizeof ) ; mmc_cid . year = UNPACK_BITS ( raw_cid , 12 , 4 , mmc_sizeof ) ; mmc_cid . year += 1997 ; } memcpy ( ( struct mmc_boot_cid * ) & card -> cid , ( struct mmc_boot_cid * ) & mmc_cid , sizeof ( struct mmc_boot_cid ) ) ; dprintf ( SPEW , " \n " ) ; dprintf ( SPEW , " \n " , mmc_cid . mid ) ; dprintf ( SPEW , " \n " , mmc_cid . oid ) ; dprintf ( SPEW , " \n " , mmc_cid . pnm ) ; dprintf ( SPEW , " \n " , ( mmc_cid . prv >> 4 ) , ( mmc_cid . prv & 0xF ) ) ; dprintf ( SPEW , " \n " , mmc_cid . psn ) ; dprintf ( SPEW , " \n " , mmc_cid . month , mmc_cid . year ) ; return MMC_BOOT_E_SUCCESS ; }
Decode CID sent by the card.
Decode CID sent by the card .
/* save it in card database */