Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2038964ybh; Fri, 17 Jul 2020 07:54:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNIO9pJE1lfME/C7VzKC0S4yt4SQ+JwMpzG4sB0Mr6vwEUfAew6NdfN3jxRjBLACdwGKWJ X-Received: by 2002:a17:906:7115:: with SMTP id x21mr8717494ejj.86.1594997658920; Fri, 17 Jul 2020 07:54:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594997658; cv=none; d=google.com; s=arc-20160816; b=cyYStHCuhYHCUoWA3dDcYet4bR9wGxh6vE2HYaVHIMjENGxPqme3ZMryDTzMNPYkJQ 1GXZKhcd7EV/5Mdft58skPkq/kIzmB8evxeyEOcvMXtZrwsxbXX9jBHS2IWMOo+qjb5C mCuVAc4hSeihNFUEl9QUepuVOIavtByp2TEED8wqs33raP69jVF9Gob1osShZ8V06pks TqRaYGlGDMRJD0IyExZdI/7gcNLlLI2s3Wztay/IyAX52y0Ob+xmYDI77oxlJyFbN8bz wqIpgnsj4rh9+43rS8rl9vExz0E4mE8M8IqYNKHJtfnPrJkPvV+hfslpqgOOzwJXK9Kn L+Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mCqG3hgxbHOaRcUOCivQuc7rpDH64MPsHRmu+f1oKRM=; b=KJjtEHtFtCWfrn6aSRyvawz/3aDd/FUOvlox10IQ9Otihsbl9YE0qxNiuS03EA1MVM c3vlV3gTrFgjHSzLtB4SCTgWkwvAKJ75zYRKkzio4Xw7oyufH5CFHqDZsNSATjWlAfdo 3r0jJE2yetLpnB/fzzrx85Zu0cAoPZ7lu4lelKlUNqvMG58U+UrGwHF574o58gzF0w4K P/ihHd5rvrNMBMT+CpuAB4EnhgUdCsfQZ9vkENOoA79Aw3jxlZjkD7bnDkKCecNcYGo1 rP7ZkoigPEXn4j1wXMjw+xXpF26rjtBeORNGa9NNl2WNpVnR9X0NKV5AmBOwrR/WzDDS MFNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20190130-41we5z8j header.b=GrD2fjtv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bj4si5580918ejb.540.2020.07.17.07.53.55; Fri, 17 Jul 2020 07:54:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mev.co.uk header.s=20190130-41we5z8j header.b=GrD2fjtv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgGQOxW (ORCPT + 99 others); Fri, 17 Jul 2020 10:53:22 -0400 Received: from smtp98.iad3b.emailsrvr.com ([146.20.161.98]:33923 "EHLO smtp98.iad3b.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbgGQOxU (ORCPT ); Fri, 17 Jul 2020 10:53:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20190130-41we5z8j; t=1594997599; bh=G1XNZoKUosIczaVLZ/Uz0cf5fBJExUEJ6FXGdrTvYOY=; h=From:To:Subject:Date:From; b=GrD2fjtvE7CwjH8nqB4dp92/3SxBd+Z2nMh9FLtVppFvg/5r5qVfuw9zZ4xaURyzR 2DfnmpVPvtkaI0a3uoiOlPixjTc0khvxXk/qOvxpV6oBg5FZSB5IrTjJFBRVvKUN4g uNyIqkKogHBw1P0USpjjrPpUu3daTHbiChO8rC9c= X-Auth-ID: abbotti@mev.co.uk Received: by smtp5.relay.iad3b.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 35B22400CC; Fri, 17 Jul 2020 10:53:18 -0400 (EDT) From: Ian Abbott To: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/4] staging: comedi: ni_6527: fix INSN_CONFIG_DIGITAL_TRIG support Date: Fri, 17 Jul 2020 15:52:54 +0100 Message-Id: <20200717145257.112660-2-abbotti@mev.co.uk> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200717145257.112660-1-abbotti@mev.co.uk> References: <20200717145257.112660-1-abbotti@mev.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Classification-ID: 3cd28aa4-5d40-4a0c-a681-8cbccbead0a1-2-1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `ni6527_intr_insn_config()` processes `INSN_CONFIG` comedi instructions for the "interrupt" subdevice. When `data[0]` is `INSN_CONFIG_DIGITAL_TRIG` it is configuring the digital trigger. When `data[2]` is `COMEDI_DIGITAL_TRIG_ENABLE_EDGES` it is configuring rising and falling edge detection for the digital trigger, using a base channel number (or shift amount) in `data[3]`, a rising edge bitmask in `data[4]` and falling edge bitmask in `data[5]`. If the base channel number (shift amount) is greater than or equal to the number of channels (24) of the digital input subdevice, there are no changes to the rising and falling edges, so the mask of channels to be changed can be set to 0, otherwise the mask of channels to be changed, and the rising and falling edge bitmasks are shifted by the base channel number before calling `ni6527_set_edge_detection()` to change the appropriate registers. Unfortunately, the code is comparing the base channel (shift amount) to the interrupt subdevice's number of channels (1) instead of the digital input subdevice's number of channels (24). Fix it by comparing to 32 because all shift amounts for an `unsigned int` must be less than that and everything from bit 24 upwards is ignored by `ni6527_set_edge_detection()` anyway. Fixes: 110f9e687c1a8 ("staging: comedi: ni_6527: support INSN_CONFIG_DIGITAL_TRIG") Cc: # 3.17+ Signed-off-by: Ian Abbott --- drivers/staging/comedi/drivers/ni_6527.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 4d1eccb5041d..4518c2680b7c 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -332,7 +332,7 @@ static int ni6527_intr_insn_config(struct comedi_device *dev, case COMEDI_DIGITAL_TRIG_ENABLE_EDGES: /* check shift amount */ shift = data[3]; - if (shift >= s->n_chan) { + if (shift >= 32) { mask = 0; rising = 0; falling = 0; -- 2.27.0