From patchwork Thu Jul 21 18:41: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: 9242325 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 650DC60756 for ; Thu, 21 Jul 2016 18:43:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57C761FF10 for ; Thu, 21 Jul 2016 18:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C01427D64; Thu, 21 Jul 2016 18:43:49 +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 F0A451FF10 for ; Thu, 21 Jul 2016 18:43:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752463AbcGUSma (ORCPT ); Thu, 21 Jul 2016 14:42:30 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36662 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752410AbcGUSm3 (ORCPT ); Thu, 21 Jul 2016 14:42:29 -0400 Received: by mail-pf0-f196.google.com with SMTP id y134so5870072pfg.3; Thu, 21 Jul 2016 11:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=4d3yJcZcAqdeK8uyMFAMw9laCjxcd9dq3ytrnkowHPA=; b=rCwg+fqfcUeglrnFWtqrp+dZJJZGHwbvx2b4o6IXxb6kP1epThgCvBrThcJebK13hO m7WuBtu77rmtpfkGMBAmbfTKhcLokGjScyDM436aGaZKI/c+es2m4/SOn5T0jNz2lFh6 RvjHX+GudvtTaLwQ7aANXvjPJCs/HzFdKhjiQpcwGeurB3hQX32wH7zVpX6bUHkf178v Zzvk0ZefC8KJ9drzkbSHItyv1aHMxA3ig3xKgV+CWDxLKYe6CFDhM4P2Y+4DXUcoiLAW 8mq1mEBC3PW9mw2Nl2Iefwq4l4ghx6GWWzfAGO4dqmWH72TTADNXmMVtBgRsk6fKubVs iM/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4d3yJcZcAqdeK8uyMFAMw9laCjxcd9dq3ytrnkowHPA=; b=JMbbxgoDH/xm5ggR6R6Z2SUZ4NB6BSZyHTnq2gHgvbwsqumv2lNZANmYYZQtbFE9Nk Fc3O6wxJZo51rXT9bPNa2dhrWfM3xoYMeWntViBF7IINNwCLRSP7FRkovvK8JaxhzCGq fqRHd8+VbdTzoPHT0ZBg59mlVLSJW8IgDiptzXE8vft0W1Gi4aGmyzv9cKUyHS2GGgDP 9qqJctl4vNlmiB/K0WHjbBuWWX8/cln3OWDVrWWPb8TQVWKMe3RZo82BF8exIWX2StsO 0D2LKv3dM7wr/rq9euCeD94pRaLtJFtqCOj6QAbGNOY5YYBmS3e8T1yiMRsrS06hQ8gP uPLw== X-Gm-Message-State: ALyK8tKgJqXDv1nxQ4//uX/nxu25xpxeltXOv/9LyHqks7vxSCTkgg5p4FoNdwKCccatnA== X-Received: by 10.98.102.79 with SMTP id a76mr67732106pfc.75.1469126548636; Thu, 21 Jul 2016 11:42:28 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id j7sm14002691paa.30.2016.07.21.11.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 11:42:28 -0700 (PDT) From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org, hare@suse.de, sergei.shtylyov@cogentembedded.com, arnd@arndb.de Cc: sfr@canb.auug.org.au, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, Tom Yan Subject: [PATCH resend 1/5] libata-scsi: minor cleanup in ata_mselect_*() Date: Fri, 22 Jul 2016 02:41:50 +0800 Message-Id: X-Mailer: git-send-email 2.9.0 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 2bdb5da..eb5e8ff 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3618,7 +3618,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; @@ -3627,8 +3626,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. */ @@ -3642,6 +3639,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; @@ -3674,7 +3673,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; @@ -3683,8 +3681,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. */ @@ -3697,7 +3693,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;