From patchwork Wed Jun 26 16:26:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 167845 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1158533ilk; Wed, 26 Jun 2019 09:29:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUQTJ0QqJQqi/PWVk7KkxkbPiRrnhtSNCXpES3VgsC1McB5iGEDxZclaZiNT2zL9tg+ZmM X-Received: by 2002:a17:902:e281:: with SMTP id cf1mr6225263plb.271.1561566540405; Wed, 26 Jun 2019 09:29:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561566540; cv=none; d=google.com; s=arc-20160816; b=PqWAJ4Uri4RLdwtx56apqsM7TE8i6icY1ie6pDyfAJBfXtxTmIRbcCyo+bAmMWu2Id j46beRuYFhNaBtC2zm6lDQX16aL/5kvwNuumhuN60Bho5VuCUiDV0cGyTpERDmz7/wEP k+Z4p81ggx4UUVfiLqj2OwN0azZqQbjjW/CSrZFS4eYa2rMSj8J+lOHHL1rgbiVCdsCf 8aYhtSaYhrWcMaoAVnMOtaxfdtB4GOSMcOPOohoXS2NR6pd3zX3QPsT+OdtxE0IFJYgK 4PK+m5Hfu7t5pBwy0Ein5fHaXa1VEpNCEfnTCxgzOR2ItyIEqyDrvAnqA6L+WReSK6qJ UHaw== 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=c5Qb7+GCUQbMBVYb30khBcTVFmxUrPGSa5utdoQ5VA4=; b=JhPBzqAZugKTzkhhq9kWYY7ilONsDLa11JwppILOgfcYL7DzQlXgL2H5D4APNH0kpz tfNleftcSDyzYPPiV4RVwGFynHiUIw7fHwvhp3QBNynd26pXCrY5py/YCai5Sxw+0ujf chtKYvcpgLzL1YWtlbO7NCIyz2oGj/dzzBPSCn3jclgCh1PJJMRIhD8smUP9/TVnqmuG KSNOSp+zBgjb6Chds5WVMjWu5Xpn6FToHeVjQLScsIQfwI3FcaoQ1yXEBPa+w+XHKTK8 aQs8d7fb8wuMubrf/7S+Lfz5/Nftnk7LOH7emnGfCeVAf5xaQrI2q62/Jmx9cRgCx19S A/TA== 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 i101si2256177pje.4.2019.06.26.09.29.00; Wed, 26 Jun 2019 09:29:00 -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 S1726695AbfFZQ2z (ORCPT + 30 others); Wed, 26 Jun 2019 12:28:55 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:50324 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726601AbfFZQ2j (ORCPT ); Wed, 26 Jun 2019 12:28:39 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3EB0DFA71DF6CE458D6D; Thu, 27 Jun 2019 00:28:36 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Thu, 27 Jun 2019 00:28:26 +0800 From: John Garry To: CC: , , , , , John Garry Subject: [PATCH v3 6/6] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration Date: Thu, 27 Jun 2019 00:26:58 +0800 Message-ID: <1561566418-22714-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1561566418-22714-1-git-send-email-john.garry@huawei.com> References: <1561566418-22714-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 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(-) -- 2.17.1 diff --git a/lib/logic_pio.c b/lib/logic_pio.c index 905027574e5d..52831a85293a 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 \