Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3511752rdb; Wed, 13 Sep 2023 14:32:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbdrgKZ8AXmpOHu3sn8PRG5DOaX0/2tvUFo/UnXuu3d+bBrUdFgtjOWS/SGgYcl7IkJFAv X-Received: by 2002:a17:90a:ad96:b0:268:a5f6:2a97 with SMTP id s22-20020a17090aad9600b00268a5f62a97mr3610840pjq.1.1694640743535; Wed, 13 Sep 2023 14:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694640743; cv=none; d=google.com; s=arc-20160816; b=J6OfirOxMrukvXKp2R9rzODyuiWLcotjNDkiA42uHY9QD2UalIePqsy6zN3nHXfAuH 6IvZFIZB/wJ83FlpngayS5hNyOVZLVKXy/XJ0W4gqHSIBuB4mB9KVipffUGTlGRB5puo hLW5zzLIY4VQ+kn5MaIu1nYbR7v/pp28JGWfQ3a1kezriWmUWpB7TlXN97GByAu7kehs hPRKYDufn2ajxYbFDuHPIyWhtX61tWFeBcNe1iMk98RPHqKhoPRDBcnrt6drwEXW8ZHk 1vUwtvWEeukMJd/3aUAeTFrN6q6X4AJUZcrJe4iIWyVIfhOF1H4iVFFctgudIL6eleF2 N1OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sWjco15Q2VJQGSon7n2yV7/mJ7GKfR55HFhMl/CtwOc=; fh=V2IY9JiXP/LhUMpX66+Nr0N3VSfqLapXj8NIppeg0Gk=; b=EGG1sgoPXHzC9iVrK19cOx7Kk7kk6NZpZmpIL3QC0Yg2WDv8jN7UBkansmt/TRNQju OVQyskrY0vux0KnaLKetd9SmMqz7f9xTOO973/OPPbaFj2t92wi0SsmtvNDjHelupoOF lfimxHn5/VPylszoazmXts2C82zsuAlDKwQT8M0w8WGg6qOQj/c1een8Xts8zt4GJelb A9HaToen1/+VNyji7EhBquVKEpqMpL3tT7r79w/mvBED0CYKZrlZFt6277EqyqVTb5mz 9E1H0MtLvXkuLelnTPM5o3bNWuAu2OHOOqkxEG5s+/dUxUf4dtVTdtMJ1Wwuc6w3bLJ6 10aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=b8eDPYI2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id z16-20020a656650000000b00573fd89e62asi10618848pgv.483.2023.09.13.14.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20221208-6x11dpa4 header.b=b8eDPYI2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mev.co.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 633AF81583A6; Wed, 13 Sep 2023 09:44:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbjIMQnu (ORCPT + 99 others); Wed, 13 Sep 2023 12:43:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbjIMQnT (ORCPT ); Wed, 13 Sep 2023 12:43:19 -0400 Received: from smtp65.iad3a.emailsrvr.com (smtp65.iad3a.emailsrvr.com [173.203.187.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 491654237 for ; Wed, 13 Sep 2023 09:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1694623243; bh=rI2CRIUlkLsVtlmYyygnJdB9GvpVENPYuTmpPjCqLlw=; h=From:To:Subject:Date:From; b=b8eDPYI2WpEwB2YDYcoR0b9vMrSHuE3jdGLorvo1gMhgbePD5zrUD+KgEM0Pwoyd2 WHsA+n2LoLl+5q161/y3GYBgO7fc4h5P8X3WSoLonZqP+GfaTp0PKtqucP1KOnorkM MuZ5QtrJaQ28x+uTziNDANkR28u/KQuGnP3JBBGY= X-Auth-ID: abbotti@mev.co.uk Received: by smtp25.relay.iad3a.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 9DCE42521C; Wed, 13 Sep 2023 12:40:42 -0400 (EDT) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Arnd Bergmann , Niklas Schnelle Subject: [PATCH v2 12/13] comedi: amplc_dio200_common: Conditionally remove I/O port support Date: Wed, 13 Sep 2023 17:40:12 +0100 Message-Id: <20230913164013.107520-13-abbotti@mev.co.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913164013.107520-1-abbotti@mev.co.uk> References: <20230913164013.107520-1-abbotti@mev.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Classification-ID: bb5231ff-a70f-4c9d-8b55-93f03f91465d-13-1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:44:22 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email In a future patch, the port I/O functions (`inb()`, `outb()`, and friends will only be declared in the `HAS_IOPORT` configuration option is enabled. The amplc_dio200_common module is used by the amplc_dio200 module (for ISA cards) and the amplc_dio200_pci module (for PCI and PCI Express cards). It supports both port I/O and memory-mapped I/O. Port I/O and memory-mapped I/O is confined to the `dio200___read8()`, `dio200___read32()`, `dio200___write8()` and `dio200___write32()` functions. Conditionally compile two versions of those functions. If the `CONFIG_HAS_IOPORT` macro is defined, call either the port I/O or memory mapped I/O functions depending on the `mmio` member of the `struct comedi_device`. If the `CONFIG_HAS_IOPORT` macro is undefined only call the memory-mapped I/O functions. Add a run-time check to `amplc_dio200_common_attach()` to return an error if the device wants to use port I/O when the `CONFIG_HAS_IOPORT` macro is undefined. The changes allow the module to be built even if the port I/O functions have not been declared. Cc: Arnd Bergmann Cc: Niklas Schnelle Signed-off-by: Ian Abbott --- v2: Correct `CONFIG_HAS_PORTIO` to `CONFIG_HAS_IOPORT` in commit description. --- drivers/comedi/drivers/amplc_dio200_common.c | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/comedi/drivers/amplc_dio200_common.c b/drivers/comedi/drivers/amplc_dio200_common.c index e6d63e89e7bf..b1a9b4c4a185 100644 --- a/drivers/comedi/drivers/amplc_dio200_common.c +++ b/drivers/comedi/drivers/amplc_dio200_common.c @@ -86,6 +86,8 @@ struct dio200_subdev_intr { unsigned int active:1; }; +#ifdef CONFIG_HAS_IOPORT + static unsigned char dio200___read8(struct comedi_device *dev, unsigned int offset) { @@ -120,6 +122,34 @@ static void dio200___write32(struct comedi_device *dev, outl(val, dev->iobase + offset); } +#else /* CONFIG_HAS_IOPORT */ + +static unsigned char dio200___read8(struct comedi_device *dev, + unsigned int offset) +{ + return readb(dev->mmio + offset); +} + +static void dio200___write8(struct comedi_device *dev, + unsigned int offset, unsigned char val) +{ + writeb(val, dev->mmio + offset); +} + +static unsigned int dio200___read32(struct comedi_device *dev, + unsigned int offset) +{ + return readl(dev->mmio + offset); +} + +static void dio200___write32(struct comedi_device *dev, + unsigned int offset, unsigned int val) +{ + writel(val, dev->mmio + offset); +} + +#endif /* CONFIG_HAS_IOPORT */ + static unsigned char dio200_read8(struct comedi_device *dev, unsigned int offset) { @@ -803,6 +833,12 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, unsigned int n; int ret; + if (!IS_ENABLED(CONFIG_HAS_IOPORT) && !dev->mmio) { + dev_err(dev->class_dev, + "error! need I/O port support\n"); + return -ENXIO; + } + ret = comedi_alloc_subdevices(dev, board->n_subdevs); if (ret) return ret; -- 2.40.1