From nobody Tue Feb 10 05:44:06 2026 Received: from smtp80.ord1d.emailsrvr.com (smtp80.ord1d.emailsrvr.com [184.106.54.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23C1E3559F2 for ; Fri, 30 Jan 2026 17:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=184.106.54.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769792714; cv=none; b=KANIjnW70UxZTDvw6GdN8D/Jnq0q5co6rQ4nFU25O/cOUSWsotKEeMIUXXZ/wez+mbY1J46YX/ZnRnDHeO+cxpaRZOvbyjUSOFAojMUWXU6rY0uugIc/Q0h2bQR8M1cLj3yGMrySiJwdmTChSw2ZsW7l7xxoEgHrjCHSHSlbxzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769792714; c=relaxed/simple; bh=YCPNPvm5mu8EbkoUOWeCYG1AEMvHwq2uygoIth/m21g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sh/RGW4Ka+mZKR7AEYKzAEyO67lB6tnLEmDRucE9e4JZoURFCt0Sy9BS2Bpdffjcy7DqexuyY/+0Xyxgh+vlBSzR3+VL2iLnus806WJn98mKBZYTB42c0jq3hTpaZLk9bQ3gv69lmeHfypkYlnXz6+CnDCeE6vXIbmvM5uVqamA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mev.co.uk; spf=pass smtp.mailfrom=mev.co.uk; dkim=pass (1024-bit key) header.d=mev.co.uk header.i=@mev.co.uk header.b=P4p0HiJT; arc=none smtp.client-ip=184.106.54.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mev.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mev.co.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mev.co.uk header.i=@mev.co.uk header.b="P4p0HiJT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1769792712; bh=YCPNPvm5mu8EbkoUOWeCYG1AEMvHwq2uygoIth/m21g=; h=From:To:Subject:Date:From; b=P4p0HiJTNLo2OqD49nRlJA4oFblhgULIqGsOR26YczQLanMArbVxEzKIXWpgHfvOn Fj4u+XqzRHflplxZ48sfnsc6lV/EJsxGOAI/RZW7yAAeK7yfx1tg4PlIcXMVL4iJ9T 6EL3WjVztd8mPnD8xM+yilR6NviR+f2WDTIS9KIw= X-Auth-ID: abbotti@mev.co.uk Received: by smtp19.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id E7048602FB; Fri, 30 Jan 2026 12:05:11 -0500 (EST) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten Subject: [PATCH 38/46] comedi: pcl818: Add sanity checks for I/O base address Date: Fri, 30 Jan 2026 16:48:03 +0000 Message-ID: <20260130170416.49994-39-abbotti@mev.co.uk> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260130170416.49994-1-abbotti@mev.co.uk> References: <20260130170416.49994-1-abbotti@mev.co.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Classification-ID: 429d5722-7f90-4557-8586-08913fa85e9e-39-1 Content-Type: text/plain; charset="utf-8" The "pcl818" driver uses an admin-supplied configuration option (`it->options[0]`) to configure the I/O port base address of a board in the PCL-818 series. It currently allows any base address to be configured but the hardware devices only support base addresses (configured by on-board DIP switches) from 0 to 0x3F0 on 16-byte boundaries. If the board has a FIFO and jumper JP6 is in the "Enabled" (default) position, then the base address needs to be on a 32-byte boundary and the length of the I/O port region will be 32 (to allow access to the FIFO registers) instead of 16. The state of jumper JP6 is unknown, so if the board has a FIFO device and is being configured on an odd 16-byte boundary, assume that jumper JP6 is in the "Disabled" position (to disallow access to the FIFO registers). Add a sanity check to ensure the device is not configured at an unsupported base address. If the board has a FIFO and is configured on an odd 16-byte boundary, log a reminder that JP6 needs to be in the "Disabled" position for correct operation. If the board has a FIFO and is configured on an even 16-byte boundary and the configuration option has been set to use the FIFO (`it->options[2] =3D=3D -1`), log a reminder that JP6 needs to be in the "Enabled" position. Signed-off-by: Ian Abbott --- drivers/comedi/drivers/pcl818.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/comedi/drivers/pcl818.c b/drivers/comedi/drivers/pcl81= 8.c index 06fe06396f23..aa775a024fc7 100644 --- a/drivers/comedi/drivers/pcl818.c +++ b/drivers/comedi/drivers/pcl818.c @@ -981,6 +981,10 @@ static int pcl818_attach(struct comedi_device *dev, st= ruct comedi_devconfig *it) const struct pcl818_board *board =3D dev->board_ptr; struct pcl818_private *devpriv; struct comedi_subdevice *s; + unsigned int io_base =3D it->options[0]; + bool fifo_is_supported =3D board->has_fifo && !(io_base & 0x10); + bool fifo_is_wanted =3D board->has_fifo && it->options[2] =3D=3D -1; + unsigned int io_len =3D fifo_is_supported ? 0x20 : 0x10; unsigned int osc_base; int ret; =20 @@ -988,11 +992,28 @@ static int pcl818_attach(struct comedi_device *dev, s= truct comedi_devconfig *it) if (!devpriv) return -ENOMEM; =20 - ret =3D comedi_request_region(dev, it->options[0], - board->has_fifo ? 0x20 : 0x10); + ret =3D comedi_check_request_region(dev, io_base, io_len, + 0, 0x3ff, io_len); if (ret) return ret; =20 + if (board->has_fifo) { + /* let user know about any required JP6 setting */ + if (fifo_is_supported) { + if (fifo_is_wanted) { + dev_info(dev->class_dev, + "Assuming JP6 is in \"Enabled\" (default) position to use the FIFO.\= n"); + } + } else { + dev_info(dev->class_dev, + "JP6 needs to be in \"Disabled\" position for correct operation at th= is base address\n"); + if (fifo_is_wanted) { + dev_warn(dev->class_dev, + "FIFO cannot be used at this base address\n"); + } + } + } + /* we can use IRQ 2-7 for async command support */ if (it->options[1] >=3D 2 && it->options[1] <=3D 7) { ret =3D request_irq(it->options[1], pcl818_interrupt, 0, @@ -1002,7 +1023,7 @@ static int pcl818_attach(struct comedi_device *dev, s= truct comedi_devconfig *it) } =20 /* should we use the FIFO? */ - if (dev->irq && board->has_fifo && it->options[2] =3D=3D -1) + if (dev->irq && fifo_is_supported && fifo_is_wanted) devpriv->usefifo =3D 1; =20 /* we need an IRQ to do DMA on channel 3 or 1 */ --=20 2.51.0