Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1772351ybi; Thu, 20 Jun 2019 03:34:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGf5Ql3ojqZPYT7BB/fHwKRJp36oJtxRchX/RVnW8IAITjYokdS+smgoEtkYl8cp67Nmkp X-Received: by 2002:a17:902:a5c5:: with SMTP id t5mr126430232plq.288.1561026857783; Thu, 20 Jun 2019 03:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026857; cv=none; d=google.com; s=arc-20160816; b=nMDPYJQSDVTZ6w554gDd2HVxqXMcAKe0+msQBawDDIUzy9vZIOeWa8fYHhNa4WoLv+ kc3yN0wy+AF6kECYMWM8liTGY60rkMfcygGDm/yYrHKbo9Tja+6iBRS3I0hF27TfgQ4b H1orFUv8vL5+keqHdWpNmvnEOP9u4Pu+urUaE+n2gK2M+2GwKHyejO69tcfbeEgvohAp eDGSge3zPZIRu/8A4xfv7yrtSPyWLt9rbeCPfMYxSqJ0nktVr+SEVXCGHZ5rIFJXlnh3 +tUFVF/MYJNimJy6DNdcWLCHCo+iQH1KWk1PjlPnBn+vVtaTHKSgCKlNRJaH1zY63We8 Twdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=FKjysQ5JpqHo9RBQhtCAp8hsC/rFtm3k7cf+r9rYrng=; b=fApkgL0j8xJQuPxY04zRG3tBIaM4Pz9hqmv9opD+rhqLHYiB90bTFS5O5s0uvmyAlb B54BQE8nkOe1ypwREooN9528v1iazUp+j2XyOJPPY1dOgb/8Vp7Ye2W2DOKft3+h6J1i tJ28qLw0EZvRX3dwUyGOf69e9OWN8QsRJvDgaTrCWkES2Ntf/uBACwsjCVmRdGixf1nc msDC5aVcpMW/ucqphelFSAM8YLwUIvpJ+CnTU55Wo6MiQJbRQUdzb2Btx3809bJBuigU cYARCFHx/2VMSGx21czC5M+5aH30WHImBe+MN+KsNOTLn0h0OQfD9D4lH20zUqoYGQX1 iSow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si19286715pfb.264.2019.06.20.03.34.01; Thu, 20 Jun 2019 03:34:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731488AbfFTKdh (ORCPT + 99 others); Thu, 20 Jun 2019 06:33:37 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:18645 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726318AbfFTKdf (ORCPT ); Thu, 20 Jun 2019 06:33:35 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E76CD590D75BBE78D99E; Thu, 20 Jun 2019 18:33:32 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Thu, 20 Jun 2019 18:33:26 +0800 From: John Garry To: CC: , , , , , , John Garry Subject: [PATCH 5/5] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration Date: Thu, 20 Jun 2019 18:31:56 +0800 Message-ID: <1561026716-140537-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1561026716-140537-1-git-send-email-john.garry@huawei.com> References: <1561026716-140537-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the only LOGIC_PIO_INDIRECT host (hisi-lpc) now sets the ops prior to registration, enforce this check at registration instead of in the IO port accessors to simplify and marginally optimise the code. A slight misalignment is also tidied. Suggested-by: Bjorn Helgaas Signed-off-by: John Garry --- lib/logic_pio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/logic_pio.c b/lib/logic_pio.c index 45eb57af2574..126593ed9049 100644 --- a/lib/logic_pio.c +++ b/lib/logic_pio.c @@ -39,7 +39,8 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) resource_size_t iio_sz = MMIO_UPPER_LIMIT; int ret = 0; - if (!new_range || !new_range->fwnode || !new_range->size) + if (!new_range || !new_range->fwnode || !new_range->size || + (new_range->flags == LOGIC_PIO_INDIRECT && !new_range->ops)) return -EINVAL; start = new_range->hw_start; @@ -237,7 +238,7 @@ type logic_in##bw(unsigned long addr) \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ struct logic_pio_hwaddr *entry = find_io_range(addr); \ \ - if (entry && entry->ops) \ + if (entry) \ ret = entry->ops->in(entry->hostdata, \ addr, sizeof(type)); \ else \ @@ -253,7 +254,7 @@ void logic_out##bw(type value, unsigned long addr) \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ struct logic_pio_hwaddr *entry = find_io_range(addr); \ \ - if (entry && entry->ops) \ + if (entry) \ entry->ops->out(entry->hostdata, \ addr, value, sizeof(type)); \ else \ @@ -261,7 +262,7 @@ void logic_out##bw(type value, unsigned long addr) \ } \ } \ \ -void logic_ins##bw(unsigned long addr, void *buffer, \ +void logic_ins##bw(unsigned long addr, void *buffer, \ unsigned int count) \ { \ if (addr < MMIO_UPPER_LIMIT) { \ @@ -269,7 +270,7 @@ void logic_ins##bw(unsigned long addr, void *buffer, \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ struct logic_pio_hwaddr *entry = find_io_range(addr); \ \ - if (entry && entry->ops) \ + if (entry) \ entry->ops->ins(entry->hostdata, \ addr, buffer, sizeof(type), count); \ else \ @@ -286,7 +287,7 @@ void logic_outs##bw(unsigned long addr, const void *buffer, \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ struct logic_pio_hwaddr *entry = find_io_range(addr); \ \ - if (entry && entry->ops) \ + if (entry) \ entry->ops->outs(entry->hostdata, \ addr, buffer, sizeof(type), count); \ else \ -- 2.17.1