From patchwork Fri Jul 31 13:02:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 6911121 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A73CC05AC for ; Fri, 31 Jul 2015 13:02:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3218220582 for ; Fri, 31 Jul 2015 13:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C23320613 for ; Fri, 31 Jul 2015 13:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbbGaNCW (ORCPT ); Fri, 31 Jul 2015 09:02:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:54267 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbbGaNCV (ORCPT ); Fri, 31 Jul 2015 09:02:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E1E14ADA7; Fri, 31 Jul 2015 13:02:17 +0000 (UTC) From: Hannes Reinecke To: Tejun Heo Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, James Bottomley , Hannes Reinecke Subject: [PATCH 2/6] libata-scsi: use ata_scsi_set_sense when generating ATA sense Date: Fri, 31 Jul 2015 15:02:04 +0200 Message-Id: <1438347728-106434-3-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1438347728-106434-1-git-send-email-hare@suse.de> References: <1438347728-106434-1-git-send-email-hare@suse.de> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When generating ATA sense we should be using 'ata_scsi_set_sense' and avoid the hand-crafted functions. Signed-off-by: Hannes Reinecke --- drivers/ata/libata-scsi.c | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 641a61a..7fc1bb4 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1064,45 +1064,26 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) */ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) { - struct ata_device *dev = qc->dev; struct scsi_cmnd *cmd = qc->scsicmd; struct ata_taskfile *tf = &qc->result_tf; - unsigned char *sb = cmd->sense_buffer; - unsigned char *desc = sb + 8; int verbose = qc->ap->ops->error_handler == NULL; - u64 block; - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - - /* sense data is current and format is descriptor */ - sb[0] = 0x72; + set_driver_byte(cmd, DRIVER_SENSE); /* Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. */ if (qc->err_mask || tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { - ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, - &sb[1], &sb[2], &sb[3], verbose); - sb[1] &= 0x0f; - } + u8 sense_key, asc, ascq; - block = ata_tf_read_block(&qc->result_tf, dev); - - /* information sense data descriptor */ - sb[7] = 12; - desc[0] = 0x00; - desc[1] = 10; + ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, + &sense_key, &asc, &ascq, verbose); - desc[2] |= 0x80; /* valid */ - desc[6] = block >> 40; - desc[7] = block >> 32; - desc[8] = block >> 24; - desc[9] = block >> 16; - desc[10] = block >> 8; - desc[11] = block; + ata_scsi_set_sense(cmd, sense_key, asc, ascq); + ata_scsi_set_sense_information(cmd, &qc->result_tf); + } else + ata_scsi_set_sense(cmd, ABORTED_COMMAND, 0, 0); } static void ata_scsi_sdev_config(struct scsi_device *sdev) @@ -1797,12 +1778,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) } else if (!need_sense) { cmd->result = SAM_STAT_GOOD; } else { - /* TODO: decide which descriptor format to use - * for 48b LBA devices and call that here - * instead of the fixed desc, which is only - * good for smaller LBA (and maybe CHS?) - * devices. - */ ata_gen_ata_sense(qc); } }