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
354 list_for_each_entry(d, &tr->devs, list) { 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()
394 if (!tr->writesect) in add_mtd_blktrans_dev()
399 gd = alloc_disk(1 << tr->part_bits); in add_mtd_blktrans_dev()
406 gd->major = tr->major; in add_mtd_blktrans_dev()
407 gd->first_minor = (new->devnum) << tr->part_bits; in add_mtd_blktrans_dev()
410 if (tr->part_bits) in add_mtd_blktrans_dev()
413 "%s%c", tr->name, 'a' + new->devnum); in add_mtd_blktrans_dev()
416 "%s%c%c", tr->name, 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()
441 if (tr->flush) in add_mtd_blktrans_dev()
445 blk_queue_logical_block_size(new->rq, tr->blksize); in add_mtd_blktrans_dev()
450 if (tr->discard) { in add_mtd_blktrans_dev()
509 if (old->tr->release) in del_mtd_blktrans_dev()
510 old->tr->release(old); in del_mtd_blktrans_dev()
523 struct mtd_blktrans_ops *tr; in blktrans_notify_remove() local
526 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_remove()
527 list_for_each_entry_safe(dev, next, &tr->devs, list) in blktrans_notify_remove()
529 tr->remove_dev(dev); in blktrans_notify_remove()
534 struct mtd_blktrans_ops *tr; in blktrans_notify_add() local
539 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_add()
540 tr->add_mtd(tr, mtd); in blktrans_notify_add()
548 int register_mtd_blktrans(struct mtd_blktrans_ops *tr) in register_mtd_blktrans() argument
562 ret = register_blkdev(tr->major, tr->name); in register_mtd_blktrans()
565 tr->name, tr->major, ret); in register_mtd_blktrans()
571 tr->major = ret; in register_mtd_blktrans()
573 tr->blkshift = ffs(tr->blksize) - 1; in register_mtd_blktrans()
575 INIT_LIST_HEAD(&tr->devs); in register_mtd_blktrans()
576 list_add(&tr->list, &blktrans_majors); in register_mtd_blktrans()
580 tr->add_mtd(tr, mtd); in register_mtd_blktrans()
586 int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) in deregister_mtd_blktrans() argument
593 list_del(&tr->list); in deregister_mtd_blktrans()
595 list_for_each_entry_safe(dev, next, &tr->devs, list) in deregister_mtd_blktrans()
596 tr->remove_dev(dev); in deregister_mtd_blktrans()
598 unregister_blkdev(tr->major, tr->name); in deregister_mtd_blktrans()
601 BUG_ON(!list_empty(&tr->devs)); in deregister_mtd_blktrans()