From patchwork Tue Jul 12 13:28:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9225315 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 A691A604DB for ; Tue, 12 Jul 2016 13:28:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9784D27BFC for ; Tue, 12 Jul 2016 13:28:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C5E827DCD; Tue, 12 Jul 2016 13:28:46 +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 3476A27CF9 for ; Tue, 12 Jul 2016 13:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750998AbcGLN2l (ORCPT ); Tue, 12 Jul 2016 09:28:41 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34709 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750936AbcGLN2k (ORCPT ); Tue, 12 Jul 2016 09:28:40 -0400 Received: by mail-pf0-f195.google.com with SMTP id g202so1088699pfb.1; Tue, 12 Jul 2016 06:28:40 -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=tHp0znfCn+1A84jw0rHvyDYNUHXGfhlnRgBv0sU5Sk8=; b=LmOT7wnYLjWvFY4DrxCiSORz4lhLbt3yBu4hrnXiYXuLRfBTmndrkIwI2edRApH+A8 TcUncZ/URwU1jTwlMN3zc4m+v9DAMpo+WqsUYePs6aAt9rhRb0EYR0cLDM9ts+TP9+Pe Gbuy/FlKer5FfmKrciOJYtNreDIQU9K0TqU3xWGglLvdg68FrrQnrRJsl6YHbhqx/N9x CVWYFFeDvklv3knYxXSlYRf/q5XL8SrzQ0fa87gCWKzRonLXti6876r+PxbtLM4PnntA RpgC+CLQIKY+q8R01AY06zUJ8I0LFlJgZneI3vIllOJVbeDb6hWy03Cjo5v7QH6UW8R9 A1vw== 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=tHp0znfCn+1A84jw0rHvyDYNUHXGfhlnRgBv0sU5Sk8=; b=fYYWK/vQZYugmvfNOXHH0MRmh+sd49fE+feNzcGYm85hDP9BodgZZVi9K8HwTlBhaL UE1QtWyUQbc6iJgJAi8zydhr7Lg7cxwRAbp6NQGfGxOelnmxZs1O3SM90YWLxKxS+q0T bHzaZYar8CbyCC7a0g95U/L2KmMO7eNPMi5FDmEPtOyHt2AiKqBfJf6FulZwr5h0F+Zp dQOAk9QsrXQ6o/RIdbuj5do6VXbfQ4bYzZhFaSNqvycyrWJwBLuag8cF8dxkrsX02LG+ blE/+BNOuV3ntX9WwTUZP6IUsRUqrGgXzBYcX6lN8tWQKRgCQh4O+4/I1zdc7SsBNrvi l9YQ== X-Gm-Message-State: ALyK8tK770Yk2jr5yFII8ygGioRkFwhYkbeGhB6xg+xjkPGc+WLl30ZfjIAvtSlF9k+Vbw== X-Received: by 10.98.16.75 with SMTP id y72mr15236707pfi.50.1468330119760; Tue, 12 Jul 2016 06:28:39 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id q67sm5196410pfb.31.2016.07.12.06.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 06:28:39 -0700 (PDT) Message-ID: <5784f087.465c620a.e5292.ffffbf31@mx.google.com> X-Google-Original-Message-ID: <20160712132823.1765-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 v2 2/2] libata-scsi: better style in ata_msense_caching() Date: Tue, 12 Jul 2016 21:28:23 +0800 X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160712132823.1765-1-me> References: <20160712132823.1765-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..6f7c626 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2424,10 +2424,13 @@ 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); }