Lines Matching refs:new
276 int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) in add_mtd_blktrans_dev() argument
278 struct mtd_blktrans_ops *tr = new->tr; in add_mtd_blktrans_dev()
287 if (new->devnum == -1) { in add_mtd_blktrans_dev()
291 new->devnum = last_devnum+1; in add_mtd_blktrans_dev()
292 list_add_tail(&new->list, &d->list); in add_mtd_blktrans_dev()
295 } else if (d->devnum == new->devnum) { in add_mtd_blktrans_dev()
298 } else if (d->devnum > new->devnum) { in add_mtd_blktrans_dev()
300 list_add_tail(&new->list, &d->list); in add_mtd_blktrans_dev()
307 if (new->devnum == -1) in add_mtd_blktrans_dev()
308 new->devnum = last_devnum+1; in add_mtd_blktrans_dev()
313 if (new->devnum > (MINORMASK >> tr->part_bits) || in add_mtd_blktrans_dev()
314 (tr->part_bits && new->devnum >= 27 * 26)) in add_mtd_blktrans_dev()
317 list_add_tail(&new->list, &tr->devs); in add_mtd_blktrans_dev()
320 mutex_init(&new->lock); in add_mtd_blktrans_dev()
321 kref_init(&new->ref); in add_mtd_blktrans_dev()
323 new->readonly = 1; in add_mtd_blktrans_dev()
326 new->tag_set = kzalloc(sizeof(*new->tag_set), GFP_KERNEL); in add_mtd_blktrans_dev()
327 if (!new->tag_set) in add_mtd_blktrans_dev()
330 ret = blk_mq_alloc_sq_tag_set(new->tag_set, &mtd_mq_ops, 2, in add_mtd_blktrans_dev()
336 gd = blk_mq_alloc_disk(new->tag_set, new); in add_mtd_blktrans_dev()
342 new->disk = gd; in add_mtd_blktrans_dev()
343 new->rq = new->disk->queue; in add_mtd_blktrans_dev()
344 gd->private_data = new; in add_mtd_blktrans_dev()
346 gd->first_minor = (new->devnum) << tr->part_bits; in add_mtd_blktrans_dev()
351 if (new->devnum < 26) in add_mtd_blktrans_dev()
353 "%s%c", tr->name, 'a' + new->devnum); in add_mtd_blktrans_dev()
357 'a' - 1 + new->devnum / 26, in add_mtd_blktrans_dev()
358 'a' + new->devnum % 26); in add_mtd_blktrans_dev()
361 "%s%d", tr->name, new->devnum); in add_mtd_blktrans_dev()
365 set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); in add_mtd_blktrans_dev()
368 spin_lock_init(&new->queue_lock); in add_mtd_blktrans_dev()
369 INIT_LIST_HEAD(&new->rq_list); in add_mtd_blktrans_dev()
372 blk_queue_write_cache(new->rq, true, false); in add_mtd_blktrans_dev()
374 blk_queue_logical_block_size(new->rq, tr->blksize); in add_mtd_blktrans_dev()
376 blk_queue_flag_set(QUEUE_FLAG_NONROT, new->rq); in add_mtd_blktrans_dev()
377 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, new->rq); in add_mtd_blktrans_dev()
380 blk_queue_max_discard_sectors(new->rq, UINT_MAX); in add_mtd_blktrans_dev()
381 new->rq->limits.discard_granularity = tr->blksize; in add_mtd_blktrans_dev()
384 gd->queue = new->rq; in add_mtd_blktrans_dev()
386 if (new->readonly) in add_mtd_blktrans_dev()
389 ret = device_add_disk(&new->mtd->dev, gd, NULL); in add_mtd_blktrans_dev()
393 if (new->disk_attributes) { in add_mtd_blktrans_dev()
395 new->disk_attributes); in add_mtd_blktrans_dev()
401 put_disk(new->disk); in add_mtd_blktrans_dev()
403 blk_mq_free_tag_set(new->tag_set); in add_mtd_blktrans_dev()
405 kfree(new->tag_set); in add_mtd_blktrans_dev()
407 list_del(&new->list); in add_mtd_blktrans_dev()