Lines Matching refs:tr
45 static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr, in do_blktrans_request() argument
54 block = blk_rq_pos(req) << 9 >> tr->blkshift; in do_blktrans_request()
55 nsect = blk_rq_cur_bytes(req) >> tr->blkshift; in do_blktrans_request()
59 if (tr->flush(dev)) in do_blktrans_request()
63 if (tr->discard(dev, block, nsect)) in do_blktrans_request()
68 for (; nsect > 0; nsect--, block++, buf += tr->blksize) { in do_blktrans_request()
69 if (tr->readsect(dev, block, buf)) { in do_blktrans_request()
80 if (!tr->writesect) in do_blktrans_request()
87 for (; nsect > 0; nsect--, block++, buf += tr->blksize) { in do_blktrans_request()
88 if (tr->writesect(dev, block, buf)) { in do_blktrans_request()
124 struct mtd_blktrans_ops *tr = dev->tr; in mtd_blktrans_work() local
133 if (tr->background && !background_done) { in mtd_blktrans_work()
136 tr->background(dev); in mtd_blktrans_work()
152 res = do_blktrans_request(dev->tr, dev, req); in mtd_blktrans_work()
197 __module_get(dev->tr->owner); in blktrans_open()
202 if (dev->tr->open) { in blktrans_open()
203 ret = dev->tr->open(dev); in blktrans_open()
219 if (dev->tr->release) in blktrans_open()
220 dev->tr->release(dev); in blktrans_open()
222 module_put(dev->tr->owner); in blktrans_open()
237 module_put(dev->tr->owner); in blktrans_release()
240 if (dev->tr->release) in blktrans_release()
241 dev->tr->release(dev); in blktrans_release()
259 ret = dev->tr->getgeo ? dev->tr->getgeo(dev, geo) : -ENOTTY; in blktrans_getgeo()
278 struct mtd_blktrans_ops *tr = new->tr; in add_mtd_blktrans_dev() local
286 list_for_each_entry(d, &tr->devs, list) { 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()
322 if (!tr->writesect) in add_mtd_blktrans_dev()
345 gd->major = tr->major; in add_mtd_blktrans_dev()
346 gd->first_minor = (new->devnum) << tr->part_bits; in add_mtd_blktrans_dev()
347 gd->minors = 1 << tr->part_bits; in add_mtd_blktrans_dev()
350 if (tr->part_bits) { in add_mtd_blktrans_dev()
353 "%s%c", tr->name, 'a' + new->devnum); in add_mtd_blktrans_dev()
356 "%s%c%c", tr->name, 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()
371 if (tr->flush) in add_mtd_blktrans_dev()
374 blk_queue_logical_block_size(new->rq, tr->blksize); in add_mtd_blktrans_dev()
379 if (tr->discard) { in add_mtd_blktrans_dev()
381 new->rq->limits.discard_granularity = tr->blksize; in add_mtd_blktrans_dev()
439 if (old->tr->release) in del_mtd_blktrans_dev()
440 old->tr->release(old); in del_mtd_blktrans_dev()
453 struct mtd_blktrans_ops *tr; in blktrans_notify_remove() local
456 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_remove()
457 list_for_each_entry_safe(dev, next, &tr->devs, list) in blktrans_notify_remove()
459 tr->remove_dev(dev); in blktrans_notify_remove()
464 struct mtd_blktrans_ops *tr; in blktrans_notify_add() local
469 list_for_each_entry(tr, &blktrans_majors, list) in blktrans_notify_add()
470 tr->add_mtd(tr, mtd); in blktrans_notify_add()
478 int register_mtd_blktrans(struct mtd_blktrans_ops *tr) in register_mtd_blktrans() argument
489 ret = register_blkdev(tr->major, tr->name); in register_mtd_blktrans()
492 tr->name, tr->major, ret); in register_mtd_blktrans()
497 tr->major = ret; in register_mtd_blktrans()
499 tr->blkshift = ffs(tr->blksize) - 1; in register_mtd_blktrans()
501 INIT_LIST_HEAD(&tr->devs); in register_mtd_blktrans()
504 list_add(&tr->list, &blktrans_majors); in register_mtd_blktrans()
507 tr->add_mtd(tr, mtd); in register_mtd_blktrans()
512 int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) in deregister_mtd_blktrans() argument
519 list_del(&tr->list); in deregister_mtd_blktrans()
521 list_for_each_entry_safe(dev, next, &tr->devs, list) in deregister_mtd_blktrans()
522 tr->remove_dev(dev); in deregister_mtd_blktrans()
525 unregister_blkdev(tr->major, tr->name); in deregister_mtd_blktrans()
527 BUG_ON(!list_empty(&tr->devs)); in deregister_mtd_blktrans()