From patchwork Sun Dec 2 11:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slawomir Stepien X-Patchwork-Id: 10708027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 944B6109C for ; Sun, 2 Dec 2018 11:58:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8732629F06 for ; Sun, 2 Dec 2018 11:58:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B39A2A004; Sun, 2 Dec 2018 11:58:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0647629F06 for ; Sun, 2 Dec 2018 11:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725814AbeLBL6C (ORCPT ); Sun, 2 Dec 2018 06:58:02 -0500 Received: from smtpo.poczta.interia.pl ([217.74.65.155]:37210 "EHLO smtpo.poczta.interia.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbeLBL6C (ORCPT ); Sun, 2 Dec 2018 06:58:02 -0500 X-Interia-R: Interia X-Interia-R-IP: 188.121.17.172 X-Interia-R-Helo: Received: from localhost (ipv4-188-121-17-172.net.internetunion.pl [188.121.17.172]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by www.poczta.fm (INTERIA.PL) with ESMTPSA; Sun, 2 Dec 2018 12:57:57 +0100 (CET) From: Slawomir Stepien To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 1/3] staging: iio: adc: ad7280a: split ad7280_channel_init() to more functions Date: Sun, 2 Dec 2018 12:58:28 +0100 Message-Id: <20181202115830.20363-2-sst@poczta.fm> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181202115830.20363-1-sst@poczta.fm> References: <20181202115830.20363-1-sst@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl; s=biztos; t=1543751878; bh=LhAGj6TbkwmiLB28JOPwSaJg2h9MuARnwyTBn+R/sWQ=; h=X-Interia-R:X-Interia-R-IP:X-Interia-R-Helo:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Interia-Antivirus; b=gA0mUSQ7/hu6Z79M4n9aSZwEgmmkcpzrRoh865HDnngihF918w1U4xomQxkiR0MJP nEQ919hfsaN57TTdGgRBq6esUKLocx7qhHs9qv0i4gvt+kOdTAnuLNLOQPjyk0fKXX aIUaRSeYMW0KIYbU5Y7QuY4jsuJXyZR6i6WOOd0w= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ad7280_channel_init function has been split into more specific functions to increase the code readability. Signed-off-by: Slawomir Stepien --- drivers/staging/iio/adc/ad7280a.c | 119 +++++++++++++++++++----------- 1 file changed, 77 insertions(+), 42 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 7a0ba26f9fd9..a6b1bdd9f372 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -496,6 +496,75 @@ static const struct attribute_group ad7280_attrs_group = { .attrs = ad7280_attributes, }; +static void ad7280_voltage_channel_init(struct ad7280_state *st, int cnt, + int dev, int ch) +{ + struct iio_chan_spec *chan = &st->channels[cnt]; + + chan->type = IIO_VOLTAGE; + chan->differential = 1; + chan->channel = (dev * 6) + ch; + chan->channel2 = chan->channel + 1; +} + +static void ad7280_temp_channel_init(struct ad7280_state *st, int cnt, int dev, + int ch) +{ + struct iio_chan_spec *chan = &st->channels[cnt]; + + chan->type = IIO_TEMP; + chan->channel = (dev * 6) + ch - 6; +} + +static void ad7280_common_fields_init(struct ad7280_state *st, int cnt, int dev, + int ch) +{ + struct iio_chan_spec *chan = &st->channels[cnt]; + + chan->indexed = 1; + chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); + chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); + chan->address = ad7280a_devaddr(dev) << 8 | ch; + chan->scan_index = cnt; + chan->scan_type.sign = 'u'; + chan->scan_type.realbits = 12; + chan->scan_type.storagebits = 32; + chan->scan_type.shift = 0; +} + +static void ad7280_all_voltage_channel_init(struct ad7280_state *st, int cnt, + int dev) +{ + struct iio_chan_spec *chan = &st->channels[cnt]; + + chan->type = IIO_VOLTAGE; + chan->differential = 1; + chan->channel = 0; + chan->channel2 = dev * 6; + chan->address = AD7280A_ALL_CELLS; + chan->indexed = 1; + chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); + chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); + chan->scan_index = cnt; + chan->scan_type.sign = 'u'; + chan->scan_type.realbits = 32; + chan->scan_type.storagebits = 32; + chan->scan_type.shift = 0; +} + +static void ad7280_timestamp_channel_init(struct ad7280_state *st, int cnt) +{ + struct iio_chan_spec *chan = &st->channels[cnt]; + + chan->type = IIO_TIMESTAMP; + chan->channel = -1; + chan->scan_index = cnt; + chan->scan_type.sign = 's'; + chan->scan_type.realbits = 64; + chan->scan_type.storagebits = 64; + chan->scan_type.shift = 0; +} + static int ad7280_channel_init(struct ad7280_state *st) { int dev, ch, cnt; @@ -508,51 +577,17 @@ static int ad7280_channel_init(struct ad7280_state *st) for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; ch++, cnt++) { - if (ch < AD7280A_AUX_ADC_1) { - st->channels[cnt].type = IIO_VOLTAGE; - st->channels[cnt].differential = 1; - st->channels[cnt].channel = (dev * 6) + ch; - st->channels[cnt].channel2 = - st->channels[cnt].channel + 1; - } else { - st->channels[cnt].type = IIO_TEMP; - st->channels[cnt].channel = (dev * 6) + ch - 6; - } - st->channels[cnt].indexed = 1; - st->channels[cnt].info_mask_separate = - BIT(IIO_CHAN_INFO_RAW); - st->channels[cnt].info_mask_shared_by_type = - BIT(IIO_CHAN_INFO_SCALE); - st->channels[cnt].address = - ad7280a_devaddr(dev) << 8 | ch; - st->channels[cnt].scan_index = cnt; - st->channels[cnt].scan_type.sign = 'u'; - st->channels[cnt].scan_type.realbits = 12; - st->channels[cnt].scan_type.storagebits = 32; - st->channels[cnt].scan_type.shift = 0; + if (ch < AD7280A_AUX_ADC_1) + ad7280_voltage_channel_init(st, cnt, dev, ch); + else + ad7280_temp_channel_init(st, cnt, dev, ch); + + ad7280_common_fields_init(st, cnt, dev, ch); } - st->channels[cnt].type = IIO_VOLTAGE; - st->channels[cnt].differential = 1; - st->channels[cnt].channel = 0; - st->channels[cnt].channel2 = dev * 6; - st->channels[cnt].address = AD7280A_ALL_CELLS; - st->channels[cnt].indexed = 1; - st->channels[cnt].info_mask_separate = BIT(IIO_CHAN_INFO_RAW); - st->channels[cnt].info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); - st->channels[cnt].scan_index = cnt; - st->channels[cnt].scan_type.sign = 'u'; - st->channels[cnt].scan_type.realbits = 32; - st->channels[cnt].scan_type.storagebits = 32; - st->channels[cnt].scan_type.shift = 0; + ad7280_all_voltage_channel_init(st, cnt, dev); cnt++; - st->channels[cnt].type = IIO_TIMESTAMP; - st->channels[cnt].channel = -1; - st->channels[cnt].scan_index = cnt; - st->channels[cnt].scan_type.sign = 's'; - st->channels[cnt].scan_type.realbits = 64; - st->channels[cnt].scan_type.storagebits = 64; - st->channels[cnt].scan_type.shift = 0; + ad7280_timestamp_channel_init(st, cnt); return cnt + 1; } From patchwork Sun Dec 2 11:58:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slawomir Stepien X-Patchwork-Id: 10708029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A731109C for ; Sun, 2 Dec 2018 11:58:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D4F329F06 for ; Sun, 2 Dec 2018 11:58:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3172A2A004; Sun, 2 Dec 2018 11:58:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95F0E29F06 for ; Sun, 2 Dec 2018 11:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725819AbeLBL6E (ORCPT ); Sun, 2 Dec 2018 06:58:04 -0500 Received: from smtpo.poczta.interia.pl ([217.74.65.155]:60099 "EHLO smtpo.poczta.interia.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbeLBL6E (ORCPT ); Sun, 2 Dec 2018 06:58:04 -0500 X-Interia-R: Interia X-Interia-R-IP: 188.121.17.172 X-Interia-R-Helo: Received: from localhost (ipv4-188-121-17-172.net.internetunion.pl [188.121.17.172]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by www.poczta.fm (INTERIA.PL) with ESMTPSA; Sun, 2 Dec 2018 12:57:58 +0100 (CET) From: Slawomir Stepien To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 2/3] staging: iio: adc: ad7280a: split ad7280_attr_init() to more functions Date: Sun, 2 Dec 2018 12:58:29 +0100 Message-Id: <20181202115830.20363-3-sst@poczta.fm> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181202115830.20363-1-sst@poczta.fm> References: <20181202115830.20363-1-sst@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl; s=biztos; t=1543751879; bh=yCueciNFpEuYCq7SWVxbArq57j8ed3j8acHbqH1LNJ8=; h=X-Interia-R:X-Interia-R-IP:X-Interia-R-Helo:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Interia-Antivirus; b=JhBAqgsScjiNGUs03OCGbRVvu/04WOHEg7VWq3xKZzTo99Emx3xtYVIYkwz6Ur+FV lZKOE6VG/zOo/TQ0mu+9ABUIZrxjlmbgmWyQrSAzQ37rG9oepH6dMvmIb6X+SmNgUY yXV/59+3mseL/Eva4rV8LyAFOUOZA+CjrF98J1+g= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ad7280_attr_init function has been split into more specific functions to increase the code readability. Signed-off-by: Slawomir Stepien --- drivers/staging/iio/adc/ad7280a.c | 79 +++++++++++++++++++------------ 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index a6b1bdd9f372..6faa85bf6f7e 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -592,11 +592,49 @@ static int ad7280_channel_init(struct ad7280_state *st) return cnt + 1; } +static int ad7280_balance_switch_attr_init(struct ad7280_state *st, int cnt, + int dev, int ch) +{ + struct iio_dev_attr *attr = &st->iio_attr[cnt]; + + attr->address = ad7280a_devaddr(dev) << 8 | ch; + attr->dev_attr.attr.mode = 0644; + attr->dev_attr.show = ad7280_show_balance_sw; + attr->dev_attr.store = ad7280_store_balance_sw; + attr->dev_attr.attr.name = devm_kasprintf(&st->spi->dev, GFP_KERNEL, + "in%d-in%d_balance_switch_en", + ch, ch + 1); + if (!attr->dev_attr.attr.name) + return -ENOMEM; + + ad7280_attributes[cnt] = &attr->dev_attr.attr; + + return 0; +} + +static int ad7280_balance_timer_attr_init(struct ad7280_state *st, int cnt, + int dev, int ch) +{ + struct iio_dev_attr *attr = &st->iio_attr[cnt]; + + attr->address = ad7280a_devaddr(dev) << 8 | (AD7280A_CB1_TIMER + ch); + attr->dev_attr.attr.mode = 0644; + attr->dev_attr.show = ad7280_show_balance_timer; + attr->dev_attr.store = ad7280_store_balance_timer; + attr->dev_attr.attr.name = devm_kasprintf(&st->spi->dev, GFP_KERNEL, + "in%d-in%d_balance_timer", + ch, ch + 1); + if (!attr->dev_attr.attr.name) + return -ENOMEM; + + ad7280_attributes[cnt] = &attr->dev_attr.attr; + + return 0; +} + static int ad7280_attr_init(struct ad7280_state *st) { - int dev, ch, cnt; - unsigned int index; - struct iio_dev_attr *iio_attr; + int dev, ch, cnt, ret; st->iio_attr = devm_kcalloc(&st->spi->dev, 2, sizeof(*st->iio_attr) * (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, @@ -607,35 +645,14 @@ static int ad7280_attr_init(struct ad7280_state *st) for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_CELL_VOLTAGE_6; ch++, cnt++) { - iio_attr = &st->iio_attr[cnt]; - index = dev * AD7280A_CELLS_PER_DEV + ch; - iio_attr->address = ad7280a_devaddr(dev) << 8 | ch; - iio_attr->dev_attr.attr.mode = 0644; - iio_attr->dev_attr.show = ad7280_show_balance_sw; - iio_attr->dev_attr.store = ad7280_store_balance_sw; - iio_attr->dev_attr.attr.name = - devm_kasprintf(&st->spi->dev, GFP_KERNEL, - "in%d-in%d_balance_switch_en", - index, index + 1); - if (!iio_attr->dev_attr.attr.name) - return -ENOMEM; - - ad7280_attributes[cnt] = &iio_attr->dev_attr.attr; + ret = ad7280_balance_switch_attr_init(st, cnt, dev, ch); + if (ret < 0) + return ret; + cnt++; - iio_attr = &st->iio_attr[cnt]; - iio_attr->address = ad7280a_devaddr(dev) << 8 | - (AD7280A_CB1_TIMER + ch); - iio_attr->dev_attr.attr.mode = 0644; - iio_attr->dev_attr.show = ad7280_show_balance_timer; - iio_attr->dev_attr.store = ad7280_store_balance_timer; - iio_attr->dev_attr.attr.name = - devm_kasprintf(&st->spi->dev, GFP_KERNEL, - "in%d-in%d_balance_timer", - index, index + 1); - if (!iio_attr->dev_attr.attr.name) - return -ENOMEM; - - ad7280_attributes[cnt] = &iio_attr->dev_attr.attr; + ret = ad7280_balance_timer_attr_init(st, cnt, dev, ch); + if (ret < 0) + return ret; } ad7280_attributes[cnt] = NULL; From patchwork Sun Dec 2 11:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slawomir Stepien X-Patchwork-Id: 10708031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16C2A1579 for ; Sun, 2 Dec 2018 11:58:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 098BA29F06 for ; Sun, 2 Dec 2018 11:58:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1C512A004; Sun, 2 Dec 2018 11:58:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C38129F06 for ; Sun, 2 Dec 2018 11:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725812AbeLBL6F (ORCPT ); Sun, 2 Dec 2018 06:58:05 -0500 Received: from smtpo.poczta.interia.pl ([217.74.65.155]:50849 "EHLO smtpo.poczta.interia.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbeLBL6F (ORCPT ); Sun, 2 Dec 2018 06:58:05 -0500 X-Interia-R: Interia X-Interia-R-IP: 188.121.17.172 X-Interia-R-Helo: Received: from localhost (ipv4-188-121-17-172.net.internetunion.pl [188.121.17.172]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by www.poczta.fm (INTERIA.PL) with ESMTPSA; Sun, 2 Dec 2018 12:57:59 +0100 (CET) From: Slawomir Stepien To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 3/3] staging: iio: adc: ad7280a: add braces to complex for loops Date: Sun, 2 Dec 2018 12:58:30 +0100 Message-Id: <20181202115830.20363-4-sst@poczta.fm> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181202115830.20363-1-sst@poczta.fm> References: <20181202115830.20363-1-sst@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl; s=biztos; t=1543751881; bh=7rmLiO93f+95AnYpYYxjBuFgIEEN1U9AmK3x6MoM450=; h=X-Interia-R:X-Interia-R-IP:X-Interia-R-Helo:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Interia-Antivirus; b=TU2/0mXKwDu+ojEeBO3pATs1gzM8jDlNtk3h+A0jIBCVeR18XcGw1IEjX2AKk0Y1l gUF/zgkoo8HInXiOsoi46bNSdkcr6LwAHV02qJJpBWtLtTISjKVTUHJ3QIPmWzd+IO TWxFcxb4jTLekII9gFPGFMXR4mByeg+vqPq8avbg= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These for loops have just only one instruction as its body. However this body is complex, so add braces to them. Signed-off-by: Slawomir Stepien --- drivers/staging/iio/adc/ad7280a.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 6faa85bf6f7e..6ec5a0d2a438 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -574,7 +574,7 @@ static int ad7280_channel_init(struct ad7280_state *st) if (!st->channels) return -ENOMEM; - for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) + for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) { for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_AUX_ADC_6; ch++, cnt++) { if (ch < AD7280A_AUX_ADC_1) @@ -584,6 +584,7 @@ static int ad7280_channel_init(struct ad7280_state *st) ad7280_common_fields_init(st, cnt, dev, ch); } + } ad7280_all_voltage_channel_init(st, cnt, dev); cnt++; @@ -642,7 +643,7 @@ static int ad7280_attr_init(struct ad7280_state *st) if (!st->iio_attr) return -ENOMEM; - for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) + for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) { for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_CELL_VOLTAGE_6; ch++, cnt++) { ret = ad7280_balance_switch_attr_init(st, cnt, dev, ch); @@ -654,6 +655,7 @@ static int ad7280_attr_init(struct ad7280_state *st) if (ret < 0) return ret; } + } ad7280_attributes[cnt] = NULL;