Lines Matching refs:tr
65 static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr, in do_blktrans_request() argument
72 block = blk_rq_pos(req) << 9 >> tr->blkshift; in do_blktrans_request()
73 nsect = blk_rq_cur_bytes(req) >> tr->blkshift; in do_blktrans_request()
76 if (tr->flush(dev)) in do_blktrans_request()
87 if (tr->discard(dev, block, nsect)) in do_blktrans_request()
92 for (; nsect > 0; nsect--, block++, buf += tr->blksize) { in do_blktrans_request()
93 if (tr->readsect(dev, block, buf)) { in do_blktrans_request()
102 if (!tr->writesect) in do_blktrans_request()
107 for (; nsect > 0; nsect--, block++, buf += tr->blksize) { in do_blktrans_request()
108 if (tr->writesect(dev, block, buf)) { in do_blktrans_request()
144 struct mtd_blktrans_ops *tr = dev->tr; in mtd_blktrans_work() local
153 if (tr->background && !background_done) { in mtd_blktrans_work()
156 tr->background(dev); in mtd_blktrans_work()
172 res = do_blktrans_request(dev->tr, dev, req); in mtd_blktrans_work()
219 __module_get(dev->tr->owner); in blktrans_open()
224 if (dev->tr->open) { in blktrans_open()
225 ret = dev->tr->open(dev); in blktrans_open()
243 if (dev->tr->release) in blktrans_open()
244 dev->tr->release(dev); in blktrans_open()
246 module_put(dev->tr->owner); in blktrans_open()
268 module_put(dev->tr->owner); in blktrans_release()
271 if (dev->tr->release) in blktrans_release()
272 dev->tr->release(dev); in blktrans_release()
294 ret = dev->tr->getgeo ? dev->tr->getgeo(dev, geo) : -ENOTTY; in blktrans_getgeo()
317 ret = dev->tr->flush ? dev->tr->flush(dev) : 0; in blktrans_ioctl()
342 struct mtd_blktrans_ops *tr = new->tr; in add_mtd_blktrans_dev() local
351 list_for_each_entry(d, &tr->devs, list) { in add_mtd_blktrans_dev()
379 if (new->devnum > (MINORMASK >> tr->part_bits) || in add_mtd_blktrans_dev()
380 (tr->part_bits && new->devnum >= 27 * 26)) { in add_mtd_blktrans_dev()
385 list_add_tail(&new->list, &tr->devs); in add_mtd_blktrans_dev()
391 if (!tr->writesect) in add_mtd_blktrans_dev()
396 gd = alloc_disk(1 << tr->part_bits); in add_mtd_blktrans_dev()
403 gd->major = tr->major; in add_mtd_blktrans_dev()
404 gd->first_minor = (new->devnum) << tr->part_bits; in add_mtd_blktrans_dev()
407 if (tr->part_bits) in add_mtd_blktrans_dev()
410 "%s%c", tr->name, 'a' + new->devnum); in add_mtd_blktrans_dev()
413 "%s%c%c", tr->name, in add_mtd_blktrans_dev()
418 "%s%d", tr->name, new->devnum); in add_mtd_blktrans_dev()
420 set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); in add_mtd_blktrans_dev()
438 if (tr->flush) in add_mtd_blktrans_dev()
442 blk_queue_logical_block_size(new->rq, tr->blksize); in add_mtd_blktrans_dev()
447 if (tr->discard) { in add_mtd_blktrans_dev()
450 new->rq->limits.discard_granularity = tr->blksize; in add_mtd_blktrans_dev()
503 if (old->tr->release) in del_mtd_blktrans_dev()
504 old->tr->release(old); in del_mtd_blktrans_dev()
517 struct mtd_blktrans_ops *tr; in blktrans_notify_remove() local
520 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_remove()
521 list_for_each_entry_safe(dev, next, &tr->devs, list) in blktrans_notify_remove()
523 tr->remove_dev(dev); in blktrans_notify_remove()
528 struct mtd_blktrans_ops *tr; in blktrans_notify_add() local
533 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_add()
534 tr->add_mtd(tr, mtd); in blktrans_notify_add()
542 int register_mtd_blktrans(struct mtd_blktrans_ops *tr) in register_mtd_blktrans() argument
556 ret = register_blkdev(tr->major, tr->name); in register_mtd_blktrans()
559 tr->name, tr->major, ret); in register_mtd_blktrans()
565 tr->major = ret; in register_mtd_blktrans()
567 tr->blkshift = ffs(tr->blksize) - 1; in register_mtd_blktrans()
569 INIT_LIST_HEAD(&tr->devs); in register_mtd_blktrans()
570 list_add(&tr->list, &blktrans_majors); in register_mtd_blktrans()
574 tr->add_mtd(tr, mtd); in register_mtd_blktrans()
580 int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) in deregister_mtd_blktrans() argument
587 list_del(&tr->list); in deregister_mtd_blktrans()
589 list_for_each_entry_safe(dev, next, &tr->devs, list) in deregister_mtd_blktrans()
590 tr->remove_dev(dev); in deregister_mtd_blktrans()
592 unregister_blkdev(tr->major, tr->name); in deregister_mtd_blktrans()
595 BUG_ON(!list_empty(&tr->devs)); in deregister_mtd_blktrans()