From patchwork Fri Oct 4 23:30:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deng-Cheng Zhu X-Patchwork-Id: 2990521 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BBF93BF924 for ; Fri, 4 Oct 2013 23:31:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB63A20251 for ; Fri, 4 Oct 2013 23:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20CE42012E for ; Fri, 4 Oct 2013 23:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751181Ab3JDXba (ORCPT ); Fri, 4 Oct 2013 19:31:30 -0400 Received: from multi.imgtec.com ([194.200.65.239]:11394 "EHLO multi.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126Ab3JDXb3 (ORCPT ); Fri, 4 Oct 2013 19:31:29 -0400 From: Deng-Cheng Zhu To: , CC: , , Deng-Cheng Zhu Subject: [PATCH v2 3/4] PCI/quirks: Extract the size detection logic of PIIX4 ACPI io and mem Date: Fri, 4 Oct 2013 16:30:52 -0700 Message-ID: <1380929453-15428-4-git-send-email-dengcheng.zhu@imgtec.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1380929453-15428-1-git-send-email-dengcheng.zhu@imgtec.com> References: <1380929453-15428-1-git-send-email-dengcheng.zhu@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.136.61] X-SEF-Processed: 7_3_0_01192__2013_10_05_00_31_25 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Deng-Cheng Zhu Put the same algorithm in piix4_acpi_[io|mem]_quirk into a dedicated function for size detection. Signed-off-by: Deng-Cheng Zhu Reviewed-by: James Hogan --- drivers/pci/quirks.c | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index a2b66c3..06762a8 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -380,6 +380,20 @@ static void quirk_ali7101_acpi(struct pci_dev *dev) } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, quirk_ali7101_acpi); +static inline u32 piix4_acpi_quirk_size(u32 max, u32 mask) +{ + u32 size = max; + + for (;;) { + unsigned bit = size >> 1; + if ((bit & mask) == bit) + break; + size = bit; + } + + return size; +} + static void piix4_acpi_io_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable) { @@ -391,13 +405,7 @@ static void piix4_acpi_io_quirk(struct pci_dev *dev, const char *name, return; mask = (devres >> 16) & 15; base = devres & 0xffff; - size = 16; - for (;;) { - unsigned bit = size >> 1; - if ((bit & mask) == bit) - break; - size = bit; - } + size = piix4_acpi_quirk_size(16, mask); /* * For now we only print it out. Eventually we'll want to * reserve it (at least if it's in the 0x1000+ range), but @@ -418,13 +426,7 @@ static void piix4_acpi_mem_quirk(struct pci_dev *dev, const char *name, return; base = devres & 0xffff8000; mask = (devres & 0x7f) << 15; - size = 128 << 15; - for (;;) { - unsigned bit = size >> 1; - if ((bit & mask) == bit) - break; - size = bit; - } + size = piix4_acpi_quirk_size(128 << 15, mask); /* * For now we only print it out. Eventually we'll want to * reserve it, but let's get enough confirmation reports first.