Esempio n. 1
0
/*
 * remove mmc card
 */
static __exit void mmc_card_exit(void)
{
	/*
	 * remove all mmc card
	 */
	mmc_card_remove();
}
Esempio n. 2
0
/*
 * probe all mmc card
 */
void mmc_card_probe(void)
{
	struct mmc_host_list * list;
	struct list_head * pos;
	struct mmc_host * host;
	struct mmc_card_info * info;
	struct mmc_card * card;
	s32_t i;

	/*
	 * remove all mmc card
	 */
	mmc_card_remove();

	/*
	 * probe all mmc card by mmc host controller
	 */
	for(pos = (&mmc_host_list->entry)->next; pos != (&mmc_host_list->entry); pos = pos->next)
	{
		list = list_entry(pos, struct mmc_host_list, entry);
		host = list->host;

		if(!host)
			continue;

		/*
		 * malloc mmc card information buffer.
		 */
		info = malloc(sizeof(struct mmc_card_info));
		if(!info)
		{
			LOG_E("can not malloc buffer for mmc card information");
			continue;
		}

		/*
		 * initialize mmc host controller
		 */
		if(host->init)
			host->init();

		if(!host->probe(info))
		{
			if(host->exit)
				host->exit();

			free(info);

			continue;
		}

		/*
		 * malloc mmc card buffer.
		 */
		card = malloc(sizeof(struct mmc_card));
		if(!card)
		{
			LOG_E("can not malloc buffer for mmc card");

			if(host->exit)
				host->exit();

			free(info);

			continue;
		}

		/*
		 * alloc mmc card's name
		 */
		i = 0;
		while(1)
		{
			snprintf((char *)card->name, 32, (const char *)"mmc%ld", i++);
			if(search_mmc_card(card->name) == NULL)
				break;
		}

		/*
		 * initialize mmc card's parameters
		 */
		card->info = info;
		card->host = host;

		/*
		 * decode mmc card information
		 */
		if(!mmc_card_decode(card))
		{
			LOG_E("fail to decode mmc card '%s' (%s)", card->name, card->host->name);
			free(card);
			free(info);
		}

		/*
		 * register mmc card
		 */
		if(register_mmc_card(card) == TRUE)
			LOG_I("found mmc card '%s' (%s)", card->name, card->host->name);
		else
		{
			LOG_E("fail to register mmc card '%s' (%s)", card->name, card->host->name);
			free(card);
			free(info);
		}
	}
}