コード例 #1
0
static int card_blk_open(struct block_device *bdev, fmode_t mode)
{
	struct card_blk_data *card_data;
	int ret = -ENXIO;

	card_data = card_blk_get(bdev->bd_disk);
	if (card_data) {
		if (card_data->usage == 2)
			check_disk_change(bdev);
		ret = 0;

             /* 
               * it would return -EROFS when FS/USB open card with O_RDWR. 
               * set sd_mmc_info->write_protected_flag in func sd_mmc_check_wp
               * set card->state |= CARD_STATE_READONLY in func sd_open
               * set card_data->read_only = 1 in func card_blk_alloc
               */
		if ((mode & FMODE_WRITE) && card_data->read_only){
                             card_blk_put(bdev->bd_disk->private_data);
			ret = -EROFS;
                   }
	}

	return ret;
}
コード例 #2
0
static int card_blk_release(struct gendisk *disk, fmode_t mode)
{
	struct card_blk_data *card_data = disk->private_data;

	card_blk_put(card_data);
	return 0;
}
コード例 #3
0
static void card_blk_remove(struct memory_card *card)
{
	struct card_blk_data *card_data = card_get_drvdata(card);

	if (card_data) {
		int devidx;

		del_gendisk(card_data->disk);

		/*
		 * I think this is needed.
		 */
		
		queue_flag_set_unlocked(QUEUE_FLAG_DEAD, card_data->queue.queue);
		queue_flag_set_unlocked(QUEUE_FLAG_STOPPED, card_data->queue.queue);
		card_data->queue.queue->queuedata = NULL;
		card_cleanup_queue(&card_data->queue);
		//card_data->disk->queue = NULL;

		devidx = card_data->disk->first_minor >> CARD_SHIFT;
		__clear_bit(devidx, dev_use);
		card_blk_put(card_data);
	}
	card_set_drvdata(card, NULL);
}