Lines Matching refs:bc

91 static void bsg_free_command(struct bsg_command *bc)  in bsg_free_command()  argument
93 struct bsg_device *bd = bc->bd; in bsg_free_command()
96 kmem_cache_free(bsg_cmd_cachep, bc); in bsg_free_command()
107 struct bsg_command *bc = ERR_PTR(-EINVAL); in bsg_alloc_command() local
117 bc = kmem_cache_zalloc(bsg_cmd_cachep, GFP_KERNEL); in bsg_alloc_command()
118 if (unlikely(!bc)) { in bsg_alloc_command()
121 bc = ERR_PTR(-ENOMEM); in bsg_alloc_command()
125 bc->bd = bd; in bsg_alloc_command()
126 INIT_LIST_HEAD(&bc->list); in bsg_alloc_command()
127 dprintk("%s: returning free cmd %p\n", bd->name, bc); in bsg_alloc_command()
128 return bc; in bsg_alloc_command()
131 return bc; in bsg_alloc_command()
304 struct bsg_command *bc = rq->end_io_data; in bsg_rq_end_io() local
305 struct bsg_device *bd = bc->bd; in bsg_rq_end_io()
309 bd->name, rq, bc, bc->bio, uptodate); in bsg_rq_end_io()
311 bc->hdr.duration = jiffies_to_msecs(jiffies - bc->hdr.duration); in bsg_rq_end_io()
314 list_move_tail(&bc->list, &bd->done_list); in bsg_rq_end_io()
326 struct bsg_command *bc, struct request *rq) in bsg_add_command() argument
328 int at_head = (0 == (bc->hdr.flags & BSG_FLAG_Q_AT_TAIL)); in bsg_add_command()
333 bc->rq = rq; in bsg_add_command()
334 bc->bio = rq->bio; in bsg_add_command()
336 bc->bidi_bio = rq->next_rq->bio; in bsg_add_command()
337 bc->hdr.duration = jiffies; in bsg_add_command()
339 list_add_tail(&bc->list, &bd->busy_list); in bsg_add_command()
342 dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc); in bsg_add_command()
344 rq->end_io_data = bc; in bsg_add_command()
350 struct bsg_command *bc = NULL; in bsg_next_done_cmd() local
354 bc = list_first_entry(&bd->done_list, struct bsg_command, list); in bsg_next_done_cmd()
355 list_del(&bc->list); in bsg_next_done_cmd()
360 return bc; in bsg_next_done_cmd()
368 struct bsg_command *bc; in bsg_get_done_cmd() local
372 bc = bsg_next_done_cmd(bd); in bsg_get_done_cmd()
373 if (bc) in bsg_get_done_cmd()
377 bc = ERR_PTR(-EAGAIN); in bsg_get_done_cmd()
383 bc = ERR_PTR(-ERESTARTSYS); in bsg_get_done_cmd()
388 dprintk("%s: returning done %p\n", bd->name, bc); in bsg_get_done_cmd()
390 return bc; in bsg_get_done_cmd()
475 struct bsg_command *bc; in bsg_complete_all_commands() local
497 bc = bsg_get_done_cmd(bd); in bsg_complete_all_commands()
498 if (IS_ERR(bc)) in bsg_complete_all_commands()
501 tret = blk_complete_sgv4_hdr_rq(bc->rq, &bc->hdr, bc->bio, in bsg_complete_all_commands()
502 bc->bidi_bio); in bsg_complete_all_commands()
506 bsg_free_command(bc); in bsg_complete_all_commands()
516 struct bsg_command *bc; in __bsg_read() local
525 bc = bsg_get_done_cmd(bd); in __bsg_read()
526 if (IS_ERR(bc)) { in __bsg_read()
527 ret = PTR_ERR(bc); in __bsg_read()
536 ret = blk_complete_sgv4_hdr_rq(bc->rq, &bc->hdr, bc->bio, in __bsg_read()
537 bc->bidi_bio); in __bsg_read()
539 if (copy_to_user(buf, &bc->hdr, sizeof(bc->hdr))) in __bsg_read()
542 bsg_free_command(bc); in __bsg_read()
599 struct bsg_command *bc; in __bsg_write() local
608 bc = NULL; in __bsg_write()
613 bc = bsg_alloc_command(bd); in __bsg_write()
614 if (IS_ERR(bc)) { in __bsg_write()
615 ret = PTR_ERR(bc); in __bsg_write()
616 bc = NULL; in __bsg_write()
620 if (copy_from_user(&bc->hdr, buf, sizeof(bc->hdr))) { in __bsg_write()
628 rq = bsg_map_hdr(bd, &bc->hdr, has_write_perm, bc->sense); in __bsg_write()
635 bsg_add_command(bd, q, bc, rq); in __bsg_write()
636 bc = NULL; in __bsg_write()
643 if (bc) in __bsg_write()
644 bsg_free_command(bc); in __bsg_write()