Lines Matching refs:tr
76 static int do_blktrans_request(struct mtd_blktrans_ops *tr, in do_blktrans_request() argument
83 block = blk_rq_pos(req) << 9 >> tr->blkshift; in do_blktrans_request()
84 nsect = blk_rq_cur_bytes(req) >> tr->blkshift; in do_blktrans_request()
91 return tr->flush(dev); in do_blktrans_request()
98 return tr->discard(dev, block, nsect); in do_blktrans_request()
101 for (; nsect > 0; nsect--, block++, buf += tr->blksize) in do_blktrans_request()
102 if (tr->readsect(dev, block, buf)) in do_blktrans_request()
107 if (!tr->writesect) in do_blktrans_request()
111 for (; nsect > 0; nsect--, block++, buf += tr->blksize) in do_blktrans_request()
112 if (tr->writesect(dev, block, buf)) in do_blktrans_request()
128 struct mtd_blktrans_ops *tr = dev->tr; in mtd_blktrans_work() local
140 if (tr->background && !background_done) { in mtd_blktrans_work()
143 tr->background(dev); in mtd_blktrans_work()
159 res = do_blktrans_request(dev->tr, dev, req); in mtd_blktrans_work()
202 __module_get(dev->tr->owner); in blktrans_open()
207 if (dev->tr->open) { in blktrans_open()
208 ret = dev->tr->open(dev); in blktrans_open()
226 if (dev->tr->release) in blktrans_open()
227 dev->tr->release(dev); in blktrans_open()
229 module_put(dev->tr->owner); in blktrans_open()
251 module_put(dev->tr->owner); in blktrans_release()
254 if (dev->tr->release) in blktrans_release()
255 dev->tr->release(dev); in blktrans_release()
277 ret = dev->tr->getgeo ? dev->tr->getgeo(dev, geo) : -ENOTTY; in blktrans_getgeo()
300 ret = dev->tr->flush ? dev->tr->flush(dev) : 0; in blktrans_ioctl()
321 struct mtd_blktrans_ops *tr = new->tr; in add_mtd_blktrans_dev() local
333 list_for_each_entry(d, &tr->devs, list) { in add_mtd_blktrans_dev()
361 if (new->devnum > (MINORMASK >> tr->part_bits) || in add_mtd_blktrans_dev()
362 (tr->part_bits && new->devnum >= 27 * 26)) { in add_mtd_blktrans_dev()
367 list_add_tail(&new->list, &tr->devs); in add_mtd_blktrans_dev()
373 if (!tr->writesect) in add_mtd_blktrans_dev()
378 gd = alloc_disk(1 << tr->part_bits); in add_mtd_blktrans_dev()
385 gd->major = tr->major; in add_mtd_blktrans_dev()
386 gd->first_minor = (new->devnum) << tr->part_bits; in add_mtd_blktrans_dev()
389 if (tr->part_bits) in add_mtd_blktrans_dev()
392 "%s%c", tr->name, 'a' + new->devnum); in add_mtd_blktrans_dev()
395 "%s%c%c", tr->name, in add_mtd_blktrans_dev()
400 "%s%d", tr->name, new->devnum); in add_mtd_blktrans_dev()
402 set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); in add_mtd_blktrans_dev()
411 if (tr->flush) in add_mtd_blktrans_dev()
415 blk_queue_logical_block_size(new->rq, tr->blksize); in add_mtd_blktrans_dev()
420 if (tr->discard) { in add_mtd_blktrans_dev()
429 tr->name, new->mtd->index); in add_mtd_blktrans_dev()
484 if (old->tr->release) in del_mtd_blktrans_dev()
485 old->tr->release(old); in del_mtd_blktrans_dev()
498 struct mtd_blktrans_ops *tr; in blktrans_notify_remove() local
501 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_remove()
502 list_for_each_entry_safe(dev, next, &tr->devs, list) in blktrans_notify_remove()
504 tr->remove_dev(dev); in blktrans_notify_remove()
509 struct mtd_blktrans_ops *tr; in blktrans_notify_add() local
514 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_add()
515 tr->add_mtd(tr, mtd); in blktrans_notify_add()
523 int register_mtd_blktrans(struct mtd_blktrans_ops *tr) in register_mtd_blktrans() argument
537 ret = register_blkdev(tr->major, tr->name); in register_mtd_blktrans()
540 tr->name, tr->major, ret); in register_mtd_blktrans()
546 tr->major = ret; in register_mtd_blktrans()
548 tr->blkshift = ffs(tr->blksize) - 1; in register_mtd_blktrans()
550 INIT_LIST_HEAD(&tr->devs); in register_mtd_blktrans()
551 list_add(&tr->list, &blktrans_majors); in register_mtd_blktrans()
555 tr->add_mtd(tr, mtd); in register_mtd_blktrans()
561 int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) in deregister_mtd_blktrans() argument
568 list_del(&tr->list); in deregister_mtd_blktrans()
570 list_for_each_entry_safe(dev, next, &tr->devs, list) in deregister_mtd_blktrans()
571 tr->remove_dev(dev); in deregister_mtd_blktrans()
573 unregister_blkdev(tr->major, tr->name); in deregister_mtd_blktrans()
576 BUG_ON(!list_empty(&tr->devs)); in deregister_mtd_blktrans()