Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932876AbbFERim (ORCPT ); Fri, 5 Jun 2015 13:38:42 -0400 Received: from smtp81.iad3a.emailsrvr.com ([173.203.187.81]:47322 "EHLO smtp81.iad3a.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932851AbbFERay (ORCPT ); Fri, 5 Jun 2015 13:30:54 -0400 X-Sender-Id: abbotti@mev.co.uk From: Ian Abbott To: Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , Subject: [PATCH 05/32] staging: comedi: das08: improve test for programmable gain Date: Fri, 5 Jun 2015 18:30:08 +0100 Message-Id: <1433525435-12986-6-git-send-email-abbotti@mev.co.uk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433525435-12986-1-git-send-email-abbotti@mev.co.uk> References: <1433525435-12986-1-git-send-email-abbotti@mev.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1811 Lines: 41 `das08_ai_rinsn()` handles Comedi `INSN_READ` instructions for the AI subdevice. This programs the gain for the analog input channel if the board has support for that, and acquires data from the channel. If programmable gain is supported, the gain code is read from the array pointed to by `devpriv->pg_gainlist` indexed by the range index. The function assumes that programmable gain is supported if the AI subdevice's range table supports more than one range. Replace that with a more direct test for `devpriv->pg_gainlist` being non-NULL, as it is only initialized to a non-NULL pointer for boards that support programmable gain. This will also allow range tables to be included for convenience for those boards that support multiple ranges by DIP switches. Those boards are currently initialized to use a single "unknown" range. Signed-off-by: Ian Abbott --- drivers/staging/comedi/drivers/das08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index b1cd6ea..2521352 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -225,7 +225,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); spin_unlock(&dev->spinlock); - if (s->range_table->length > 1) { + if (devpriv->pg_gainlist) { /* set gain/range */ range = CR_RANGE(insn->chanspec); outb(devpriv->pg_gainlist[range], -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/