Lines Matching refs:hdr
349 struct sg_io_hdr *hdr, fmode_t mode) in scsi_fill_sghdr_rq() argument
353 if (hdr->cmd_len < 6) in scsi_fill_sghdr_rq()
355 if (copy_from_user(scmd->cmnd, hdr->cmdp, hdr->cmd_len)) in scsi_fill_sghdr_rq()
359 scmd->cmd_len = hdr->cmd_len; in scsi_fill_sghdr_rq()
361 rq->timeout = msecs_to_jiffies(hdr->timeout); in scsi_fill_sghdr_rq()
372 static int scsi_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, in scsi_complete_sghdr_rq() argument
381 hdr->status = scmd->result & 0xff; in scsi_complete_sghdr_rq()
382 hdr->masked_status = status_byte(scmd->result); in scsi_complete_sghdr_rq()
383 hdr->msg_status = COMMAND_COMPLETE; in scsi_complete_sghdr_rq()
384 hdr->host_status = host_byte(scmd->result); in scsi_complete_sghdr_rq()
385 hdr->driver_status = 0; in scsi_complete_sghdr_rq()
386 if (scsi_status_is_check_condition(hdr->status)) in scsi_complete_sghdr_rq()
387 hdr->driver_status = DRIVER_SENSE; in scsi_complete_sghdr_rq()
388 hdr->info = 0; in scsi_complete_sghdr_rq()
389 if (hdr->masked_status || hdr->host_status || hdr->driver_status) in scsi_complete_sghdr_rq()
390 hdr->info |= SG_INFO_CHECK; in scsi_complete_sghdr_rq()
391 hdr->resid = scmd->resid_len; in scsi_complete_sghdr_rq()
392 hdr->sb_len_wr = 0; in scsi_complete_sghdr_rq()
394 if (scmd->sense_len && hdr->sbp) { in scsi_complete_sghdr_rq()
395 int len = min((unsigned int) hdr->mx_sb_len, scmd->sense_len); in scsi_complete_sghdr_rq()
397 if (!copy_to_user(hdr->sbp, scmd->sense_buffer, len)) in scsi_complete_sghdr_rq()
398 hdr->sb_len_wr = len; in scsi_complete_sghdr_rq()
410 static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) in sg_io() argument
420 if (hdr->interface_id != 'S') in sg_io()
423 if (hdr->dxfer_len > (queue_max_hw_sectors(sdev->request_queue) << 9)) in sg_io()
426 if (hdr->dxfer_len) in sg_io()
427 switch (hdr->dxfer_direction) { in sg_io()
437 if (hdr->flags & SG_FLAG_Q_AT_HEAD) in sg_io()
446 if (hdr->cmd_len > sizeof(scmd->cmnd)) { in sg_io()
451 ret = scsi_fill_sghdr_rq(sdev, rq, hdr, mode); in sg_io()
455 ret = blk_rq_map_user_io(rq, NULL, hdr->dxferp, hdr->dxfer_len, in sg_io()
456 GFP_KERNEL, hdr->iovec_count && hdr->dxfer_len, in sg_io()
457 hdr->iovec_count, 0, rq_data_dir(rq)); in sg_io()
468 hdr->duration = jiffies_to_msecs(jiffies - start_time); in sg_io()
470 ret = scsi_complete_sghdr_rq(rq, hdr, bio); in sg_io()
617 int put_sg_io_hdr(const struct sg_io_hdr *hdr, void __user *argp) in put_sg_io_hdr() argument
622 .interface_id = hdr->interface_id, in put_sg_io_hdr()
623 .dxfer_direction = hdr->dxfer_direction, in put_sg_io_hdr()
624 .cmd_len = hdr->cmd_len, in put_sg_io_hdr()
625 .mx_sb_len = hdr->mx_sb_len, in put_sg_io_hdr()
626 .iovec_count = hdr->iovec_count, in put_sg_io_hdr()
627 .dxfer_len = hdr->dxfer_len, in put_sg_io_hdr()
628 .dxferp = (uintptr_t)hdr->dxferp, in put_sg_io_hdr()
629 .cmdp = (uintptr_t)hdr->cmdp, in put_sg_io_hdr()
630 .sbp = (uintptr_t)hdr->sbp, in put_sg_io_hdr()
631 .timeout = hdr->timeout, in put_sg_io_hdr()
632 .flags = hdr->flags, in put_sg_io_hdr()
633 .pack_id = hdr->pack_id, in put_sg_io_hdr()
634 .usr_ptr = (uintptr_t)hdr->usr_ptr, in put_sg_io_hdr()
635 .status = hdr->status, in put_sg_io_hdr()
636 .masked_status = hdr->masked_status, in put_sg_io_hdr()
637 .msg_status = hdr->msg_status, in put_sg_io_hdr()
638 .sb_len_wr = hdr->sb_len_wr, in put_sg_io_hdr()
639 .host_status = hdr->host_status, in put_sg_io_hdr()
640 .driver_status = hdr->driver_status, in put_sg_io_hdr()
641 .resid = hdr->resid, in put_sg_io_hdr()
642 .duration = hdr->duration, in put_sg_io_hdr()
643 .info = hdr->info, in put_sg_io_hdr()
653 if (copy_to_user(argp, hdr, sizeof(*hdr))) in put_sg_io_hdr()
660 int get_sg_io_hdr(struct sg_io_hdr *hdr, const void __user *argp) in get_sg_io_hdr() argument
669 *hdr = (struct sg_io_hdr) { in get_sg_io_hdr()
698 if (copy_from_user(hdr, argp, sizeof(*hdr))) in get_sg_io_hdr()
783 struct sg_io_hdr hdr; in scsi_cdrom_send_packet() local
791 memset(&hdr, 0, sizeof(hdr)); in scsi_cdrom_send_packet()
792 hdr.interface_id = 'S'; in scsi_cdrom_send_packet()
793 hdr.cmd_len = sizeof(cgc.cmd); in scsi_cdrom_send_packet()
794 hdr.dxfer_len = cgc.buflen; in scsi_cdrom_send_packet()
797 hdr.dxfer_direction = SG_DXFER_UNKNOWN; in scsi_cdrom_send_packet()
800 hdr.dxfer_direction = SG_DXFER_TO_DEV; in scsi_cdrom_send_packet()
803 hdr.dxfer_direction = SG_DXFER_FROM_DEV; in scsi_cdrom_send_packet()
806 hdr.dxfer_direction = SG_DXFER_NONE; in scsi_cdrom_send_packet()
812 hdr.dxferp = cgc.buffer; in scsi_cdrom_send_packet()
813 hdr.sbp = cgc.sense; in scsi_cdrom_send_packet()
814 if (hdr.sbp) in scsi_cdrom_send_packet()
815 hdr.mx_sb_len = sizeof(struct request_sense); in scsi_cdrom_send_packet()
816 hdr.timeout = jiffies_to_msecs(cgc.timeout); in scsi_cdrom_send_packet()
817 hdr.cmdp = ((struct cdrom_generic_command __user *) arg)->cmd; in scsi_cdrom_send_packet()
818 hdr.cmd_len = sizeof(cgc.cmd); in scsi_cdrom_send_packet()
820 err = sg_io(sdev, &hdr, mode); in scsi_cdrom_send_packet()
824 if (hdr.status) in scsi_cdrom_send_packet()
828 cgc.buflen = hdr.resid; in scsi_cdrom_send_packet()
838 struct sg_io_hdr hdr; in scsi_ioctl_sg_io() local
841 error = get_sg_io_hdr(&hdr, argp); in scsi_ioctl_sg_io()
844 error = sg_io(sdev, &hdr, mode); in scsi_ioctl_sg_io()
847 if (put_sg_io_hdr(&hdr, argp)) in scsi_ioctl_sg_io()