Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1167225ybd; Wed, 26 Jun 2019 12:26:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB6W/3lrxJaGyw5qWMLFmN1i2/XmoYoJeZWHnDQ69XH4YLbuerLWQbBUP/9nW8lahCf7/6 X-Received: by 2002:a17:90a:5884:: with SMTP id j4mr904729pji.142.1561577168284; Wed, 26 Jun 2019 12:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561577168; cv=none; d=google.com; s=arc-20160816; b=KDIDCGEJXzVWfItFR3glNaoCel7Z9QbmP1xY9zmxvRgsRpY/bgQdfyeTLdp9SiXnYH l1qR+YZ4PMHqnSSF8CI6s+h8OiSpwqEAtQ3FCgtndCTqGKnuWBAEUoB5yTw0O4ITsMcx lc5s26C/KUCYQovc/q0NnbpSUjvRdH4LTNHWnoTi7Z1eKw9vUjt8aMkkc0hNfpEu7YiD cUCMDO/+K2bdoFsmBdy9Tyhs4B9wnG11hoZUdza1/nxwckd2Yf6hH0BS5r5pCqG/e2zC f7aUBGFyesP6LiQZaZDGGxgVcTb25yus0FpYG6/vUunAp503SkrrUkLbABsdMHsWJPeQ skHQ== 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:subject:cc:to:from:date :dkim-signature; bh=WAqNfgfpcveVVhmgVdO/tyPcpNM8QYAbxUk92I12pMo=; b=uj6XwT6Rx/+FJyvUI2N6hVkMcLnKLkfYDlfXRPb9GuP3nyLzDv4I1smvWMgEIByB0v 7eRIRA15YgRHp6DOFjBS60cneohu3rfKjsSXMQWJqHqSLABeq0qxNWuFgpSIix49PA13 Ob8NFkGs8WfNSp0EKRtqc9H3PUauoEZ9rWkMiYhB+YxvoTjJQdy24FMdyFgPKJxveYgV FPiLXst361sYsB5el7AaNjYHr0CkLc+R4Cn5qGKcjjRGPu4DclqOK6b+26laSZyyzIYU PLbH8xpFOjahO5vQMhKAjJYnei3Ht4VpsdRac2QPaUrTpFG+WhP6WmwLOYfsX/TF77Ko 54HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KrW9kanM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si3882927plc.253.2019.06.26.12.25.51; Wed, 26 Jun 2019 12:26:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KrW9kanM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfFZTZa (ORCPT + 99 others); Wed, 26 Jun 2019 15:25:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:52766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbfFZTZa (ORCPT ); Wed, 26 Jun 2019 15:25:30 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 332CA20663; Wed, 26 Jun 2019 19:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561577129; bh=17SmlQOB16n8ABcZcXfvr/VljlqwX+htptnV1U7ULd4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KrW9kanM4nUc3adGaHL8IjyuCHfd35a1/SvKU/FDWO2dgY1ySWO/K0eCy0gvR/3tE z1uHhBTD9PA3efM76gssVjC6xaCkQTLVsJA6l3vnBWkdL96thU5wu+xD3rzrjagS9Q w05wyYTTtcOrqHjX1TvTqEjQWPB9dbLDtUwQjsAQ= Date: Wed, 26 Jun 2019 20:25:25 +0100 From: Jonathan Cameron To: Mircea Caprioru Cc: , , , , , , , Subject: Re: [PATCH V4 3/5] iio: adc: ad7124: Shift to dynamic allocation for channel configuration Message-ID: <20190626202525.6eec81fe@archlinux> In-Reply-To: <20190625081128.22190-3-mircea.caprioru@analog.com> References: <20190625081128.22190-1-mircea.caprioru@analog.com> <20190625081128.22190-3-mircea.caprioru@analog.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Jun 2019 11:11:26 +0300 Mircea Caprioru wrote: > This patch changes the channel configuration member of the device > structure from a fixed size array to a dynamic allocated one with a size > equal to the number of channels specified in the device tree. This will > ensure a more flexibility for compatible devices. > > Ex. ad7124-4 - can have 4 differential or 8 pseudo-differential channels > ad7124-8 - can have 8 differential or 16 pseudo-differential channels > > Also the device can suspport any other combination of differential and > pseudo-differential channels base on the physical number of inputs > available. > > Signed-off-by: Mircea Caprioru Applied. Thanks, Jonathan > --- > > Changelog v2: > - nothing changed here > > Changelog v3: > - nothing changed here > > Changelog v4: > - nothing changed here > > drivers/iio/adc/ad7124.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c > index ab52c5e9ecb1..edc6f1cc90b2 100644 > --- a/drivers/iio/adc/ad7124.c > +++ b/drivers/iio/adc/ad7124.c > @@ -121,7 +121,7 @@ struct ad7124_channel_config { > struct ad7124_state { > const struct ad7124_chip_info *chip_info; > struct ad_sigma_delta sd; > - struct ad7124_channel_config channel_config[4]; > + struct ad7124_channel_config *channel_config; > struct regulator *vref[4]; > struct clk *mclk; > unsigned int adc_control; > @@ -439,6 +439,7 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, > struct ad7124_state *st = iio_priv(indio_dev); > struct device_node *child; > struct iio_chan_spec *chan; > + struct ad7124_channel_config *chan_config; > unsigned int ain[2], channel = 0, tmp; > int ret; > > @@ -453,8 +454,14 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, > if (!chan) > return -ENOMEM; > > + chan_config = devm_kcalloc(indio_dev->dev.parent, st->num_channels, > + sizeof(*chan_config), GFP_KERNEL); > + if (!chan_config) > + return -ENOMEM; > + > indio_dev->channels = chan; > indio_dev->num_channels = st->num_channels; > + st->channel_config = chan_config; > > for_each_available_child_of_node(np, child) { > ret = of_property_read_u32(child, "reg", &channel);