Lines Matching full:new

340 int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)  in add_mtd_blktrans_dev()  argument
342 struct mtd_blktrans_ops *tr = new->tr; in add_mtd_blktrans_dev()
355 if (new->devnum == -1) { in add_mtd_blktrans_dev()
359 new->devnum = last_devnum+1; in add_mtd_blktrans_dev()
360 list_add_tail(&new->list, &d->list); in add_mtd_blktrans_dev()
363 } else if (d->devnum == new->devnum) { in add_mtd_blktrans_dev()
367 } else if (d->devnum > new->devnum) { in add_mtd_blktrans_dev()
369 list_add_tail(&new->list, &d->list); in add_mtd_blktrans_dev()
376 if (new->devnum == -1) in add_mtd_blktrans_dev()
377 new->devnum = last_devnum+1; in add_mtd_blktrans_dev()
382 if (new->devnum > (MINORMASK >> tr->part_bits) || in add_mtd_blktrans_dev()
383 (tr->part_bits && new->devnum >= 27 * 26)) { in add_mtd_blktrans_dev()
388 list_add_tail(&new->list, &tr->devs); in add_mtd_blktrans_dev()
392 mutex_init(&new->lock); in add_mtd_blktrans_dev()
393 kref_init(&new->ref); in add_mtd_blktrans_dev()
395 new->readonly = 1; in add_mtd_blktrans_dev()
404 new->disk = gd; in add_mtd_blktrans_dev()
405 gd->private_data = new; in add_mtd_blktrans_dev()
407 gd->first_minor = (new->devnum) << tr->part_bits; in add_mtd_blktrans_dev()
411 if (new->devnum < 26) in add_mtd_blktrans_dev()
413 "%s%c", tr->name, 'a' + new->devnum); in add_mtd_blktrans_dev()
417 'a' - 1 + new->devnum / 26, in add_mtd_blktrans_dev()
418 'a' + new->devnum % 26); in add_mtd_blktrans_dev()
421 "%s%d", tr->name, new->devnum); in add_mtd_blktrans_dev()
423 set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); in add_mtd_blktrans_dev()
426 spin_lock_init(&new->queue_lock); in add_mtd_blktrans_dev()
427 INIT_LIST_HEAD(&new->rq_list); in add_mtd_blktrans_dev()
429 new->tag_set = kzalloc(sizeof(*new->tag_set), GFP_KERNEL); in add_mtd_blktrans_dev()
430 if (!new->tag_set) in add_mtd_blktrans_dev()
433 new->rq = blk_mq_init_sq_queue(new->tag_set, &mtd_mq_ops, 2, in add_mtd_blktrans_dev()
435 if (IS_ERR(new->rq)) { in add_mtd_blktrans_dev()
436 ret = PTR_ERR(new->rq); in add_mtd_blktrans_dev()
437 new->rq = NULL; in add_mtd_blktrans_dev()
442 blk_queue_write_cache(new->rq, true, false); in add_mtd_blktrans_dev()
444 new->rq->queuedata = new; in add_mtd_blktrans_dev()
445 blk_queue_logical_block_size(new->rq, tr->blksize); in add_mtd_blktrans_dev()
447 blk_queue_flag_set(QUEUE_FLAG_NONROT, new->rq); in add_mtd_blktrans_dev()
448 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, new->rq); in add_mtd_blktrans_dev()
451 blk_queue_flag_set(QUEUE_FLAG_DISCARD, new->rq); in add_mtd_blktrans_dev()
452 blk_queue_max_discard_sectors(new->rq, UINT_MAX); in add_mtd_blktrans_dev()
455 gd->queue = new->rq; in add_mtd_blktrans_dev()
457 if (new->readonly) in add_mtd_blktrans_dev()
460 device_add_disk(&new->mtd->dev, gd, NULL); in add_mtd_blktrans_dev()
462 if (new->disk_attributes) { in add_mtd_blktrans_dev()
464 new->disk_attributes); in add_mtd_blktrans_dev()
469 kfree(new->tag_set); in add_mtd_blktrans_dev()
471 put_disk(new->disk); in add_mtd_blktrans_dev()
473 list_del(&new->list); in add_mtd_blktrans_dev()
491 /* Stop new requests to arrive */ in del_mtd_blktrans_dev()