From patchwork Tue Jul 12 13:37:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9225335 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 A9719604DB for ; Tue, 12 Jul 2016 13:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AB651FF21 for ; Tue, 12 Jul 2016 13:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F5B427BFC; Tue, 12 Jul 2016 13:37:23 +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 374591FF21 for ; Tue, 12 Jul 2016 13:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbcGLNhV (ORCPT ); Tue, 12 Jul 2016 09:37:21 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:36747 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbcGLNhV (ORCPT ); Tue, 12 Jul 2016 09:37:21 -0400 Received: by mail-pa0-f66.google.com with SMTP id ib6so1051178pad.3; Tue, 12 Jul 2016 06:37:20 -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=fwj6Q/iZ06AAQGmPLfsI4bP3WmZ2LNcguxX41ucus9A=; b=iD7AiWTGITBhSf+XJGdHbs1HTYwx3xX/9eI9foqIjksuQSOxacjb3iP2vXzRDJiUfB rYw2InH77w0GwkOPfSq4zt7fpNMPG9LKjULWloLJTjwUMSJNdNOEQLsQgEKwPSrClVyT Ha83AedFMOZujA3q7x7hAUUCUEUdkEooWDkYMlNRVfr0dRKqIYzajnwKURA8pz0CqCkL xDWuYXRHBfHyd5QODgYPzTJ/T0y5u5G0UhvbQWPhQycpJM4Lw3X1MJa8wbJpLeHi5qwK YO8Y30QXg8fCliw0DHhuNn3lpTd4wivXcx7JwmWjEfjuulEDfxzRcwup6ixJHBa2Ow5A FUIA== 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=fwj6Q/iZ06AAQGmPLfsI4bP3WmZ2LNcguxX41ucus9A=; b=TdCIwTyM44b1TLzjuw63QxKZU3WTlv8HDfjaleLnqzUOyC0IK83JmeFfKAK/rUTrGb McUKNCl/wrA5sganMXj39XcM+s+OAAPUNpDbl5D9qfpVSEfScKQ6pOSoMQ3r5bjRnAgI ckgvDCliIGulC5ffBwFdLR80K9w9veOQ7PgdPqUu4k7540slPDgZOKgNO4AylEbeCkiy iuRxMvqwnk6PuWCf9QE4MrMvi3pcuMS3cCfh385vatZHb4BwSM5HRKJCEf3lvApheBOe 2WNLvdVu5UfGnJGm+NysZagh75dQjIIohHMEkpXufY1j3oRxHIJ1uxQhYDloVtmsKblW PQXg== X-Gm-Message-State: ALyK8tI6lgINVcDlCz4jKbtVmLOOYtyWlu1fleA+ExCJgMIspc3NFoGkm9op0W/q+SUvww== X-Received: by 10.66.154.232 with SMTP id vr8mr4060970pab.104.1468330636761; Tue, 12 Jul 2016 06:37:16 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id p187sm2301170pfg.67.2016.07.12.06.37.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 06:37:16 -0700 (PDT) Message-ID: <5784f28c.c4d0620a.69372.3df2@mx.google.com> X-Google-Original-Message-ID: <20160712133703.2076-2-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 v3 2/2] libata-scsi: better style in ata_msense_caching() Date: Tue, 12 Jul 2016 21:37:03 +0800 X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160712133703.2076-1-me> References: <20160712133703.2076-1-me> 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 Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index bfec66f..48ea887 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable) static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable) { modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable); - if (changeable || ata_id_wcache_enabled(id)) - buf[2] |= (1 << 2); /* write cache enable */ - if (!changeable && !ata_id_rahead_enabled(id)) - buf[12] |= (1 << 5); /* disable read ahead */ + if (changeable) { + buf[2] |= 1 << 2; /* ata_mselect_caching() */ + } else { + buf[2] |= ata_id_wcache_enabled(id) << 2; /* write cache enable */ + buf[12] |= !ata_id_rahead_enabled(id) << 5; /* disable read ahead */ + } return sizeof(def_cache_mpage); }