From patchwork Tue Jul 19 21:11:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9238369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECB48600CB for ; Tue, 19 Jul 2016 21:12:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA1DE2624D for ; Tue, 19 Jul 2016 21:12:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE89927569; Tue, 19 Jul 2016 21:12:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D686B2624D for ; Tue, 19 Jul 2016 21:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbcGSVL7 (ORCPT ); Tue, 19 Jul 2016 17:11:59 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34823 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751036AbcGSVL7 (ORCPT ); Tue, 19 Jul 2016 17:11:59 -0400 Received: by mail-pf0-f193.google.com with SMTP id h186so2029920pfg.2; Tue, 19 Jul 2016 14:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date:in-reply-to:references; bh=eq+dItc0lj2NempBF9qqcfaelyKZ6gx1JaxtMHMlCG8=; b=IX9dtx3dWN/B1pmq5BGT/kcr5rnpq06ciGMi36G+aA71jh4e4XpdVgK3Lw+kNFqXJM JpzLFv6mAbGj19JybThWfwHBGqW5gK0Fc4rU7C2+AbWwgcBNhX5FDMlJBUpy+1E/EDHa EiY4ivyANC/U80BJnFwU1GO/YE/FWSj1riNleDDQyyv91/z1vT6iOUIRLEnHUKSfAaFa FnsQPBoydiMillTKfIuGcB/f6kB0/m8hhHBJ3tGbYAmLIGAV2vv1nINwvwgC+w3Augyh Y35PlPA962kgLAE1ZQSx3wUSO5KQ1mD4dfY/XacjgBwJS6QbnI6JU2BJfMmnriFGESjs A8dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date:in-reply-to :references; bh=eq+dItc0lj2NempBF9qqcfaelyKZ6gx1JaxtMHMlCG8=; b=UvOLTLooQzghrxY2RxqHtDDFJZWdpdgVG4bmmN8ON6PLGAfKNpvvH1WHfk52SH4bth ksAp5lAXWgPs+bQym6kDFlMJ+lJ0VvF37Sctrfzl69AqBnwMaSb7yfK6i43sRqgMcdPz G7xAhS1fha3vFKJzc7njkVskw8etr8Q/898tWEnX/7cc5VU68NZ/NaBCdVUA8noTL0j5 IFqWm9qtbZh5WLu74sCZmBLmohlRQLerO69Qph1Zo0l6wHlmIq6Ghq3GWr35TppS/gSE CYlzqpSj1CQfVMo7VvhWAeH3Jr5TY7HkZzclWh9j/JqWLuyKkx4eh2XKrVW5OB015MJr XxkA== X-Gm-Message-State: ALyK8tKsMNd7d+eV9wD4ODf1cJZBhXZuReZLalRwAyIi9uyzWrnv598TTrlWmzZmY1J0IQ== X-Received: by 10.98.158.78 with SMTP id s75mr58583857pfd.137.1468962718266; Tue, 19 Jul 2016 14:11:58 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id 81sm7019586pfm.90.2016.07.19.14.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 14:11:57 -0700 (PDT) Message-ID: <578e979d.d40c620a.f5800.0924@mx.google.com> X-Google-Original-Message-ID: <20160719211150.1700-1-me> From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org, sergei.shtylyov@cogentembedded.com Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, Tom Yan Subject: [PATCH v4] libata-scsi: minor cleanup in ata_mselect_*() Date: Wed, 20 Jul 2016 05:11:50 +0800 X-Mailer: git-send-email 2.9.0 In-Reply-To: <578e9008.4500420a.2d828.d131@mx.google.com> References: <578e9008.4500420a.2d828.d131@mx.google.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Yan 1. Removed a repeated bit masking in ata_mselect_control() 2. Moved `wce`/`d_sense` assignment below the page validity checks 3. Added/Removed empty lines where appropriate Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index b00521b..06afe63 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3604,7 +3604,6 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc, * The first two bytes of def_cache_mpage are a header, so offsets * in mpage are off by 2 compared to buf. Same for len. */ - if (len != CACHE_MPAGE_LEN - 2) { if (len < CACHE_MPAGE_LEN - 2) *fp = len; @@ -3613,8 +3612,6 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc, return -EINVAL; } - wce = buf[0] & (1 << 2); - /* * Check that read-only bits are not modified. */ @@ -3628,6 +3625,8 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc, } } + wce = buf[0] & (1 << 2); + tf->flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; tf->protocol = ATA_PROT_NODATA; tf->nsect = 0; @@ -3660,7 +3659,6 @@ static int ata_mselect_control(struct ata_queued_cmd *qc, * The first two bytes of def_control_mpage are a header, so offsets * in mpage are off by 2 compared to buf. Same for len. */ - if (len != CONTROL_MPAGE_LEN - 2) { if (len < CONTROL_MPAGE_LEN - 2) *fp = len; @@ -3669,8 +3667,6 @@ static int ata_mselect_control(struct ata_queued_cmd *qc, return -EINVAL; } - d_sense = buf[0] & (1 << 2); - /* * Check that read-only bits are not modified. */ @@ -3683,7 +3679,10 @@ static int ata_mselect_control(struct ata_queued_cmd *qc, return -EINVAL; } } - if (d_sense & (1 << 2)) + + d_sense = buf[0] & (1 << 2); + + if (d_sense) dev->flags |= ATA_DFLAG_D_SENSE; else dev->flags &= ~ATA_DFLAG_D_SENSE;