Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp250057ybh; Sun, 12 Jul 2020 05:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXBogwTL2ZUUXHHdO1uy7RhBXirUijHHrC5v915kXLrb/nN5dTQAOMb7wAIlBS1cOceasj X-Received: by 2002:a50:c88d:: with SMTP id d13mr87352156edh.104.1594555926610; Sun, 12 Jul 2020 05:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594555926; cv=none; d=google.com; s=arc-20160816; b=b05PweKy02m7b/mE3rG93ZdH0UllNG3urzjI17BjMv7osld4GNN0F28bH8y0f2zqtd lTVfEiP4e/KeiaOqOn8F0m3fZg8/0ttvUJ8MQKd2yNK69/D1pYXUqQ4tHHMvl2elNXBC Fep9liwsGAVJ62lRwKEBD0pNdgxl8j+WSp4Zt7AdwS17M8WhVTpSLnHWduVd/ewR2OuH ZgwCAjerHZcImiw/P6fVEfusc0cxZCZ1/5DZX+IVqosAaQju2kMUUyk/HApAQ4Hwim/a O4AQPaeNBTfmG0aQf0uQEEgZc+grBuW3fKIuIiv4Z99CKrDZQp3DFdKw0PPbWsfCnKHC HhuA== 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=r4ypOGIx3Xyiol3Ej2iPSiS5nf7K+ng1xObISXdOtGU=; b=gdpgbAMdTGEfYBHot9wIP8/1Owy7ZWNzm8ckKBmC9jomqsnHUYSCylKf9nDPONX0sR JADQhWRTmGTwnXlf9O0xmPb29ZULzUu/MmeSxojqIzeGo++QBc3VQsEF4tEQShEiB2kl pnl0JAJKfT8sfb/ZC9XpMt4y20TfztjFDwAfGougok/DJlMNRee6ucn+xs7kqLaAxRyh da5hllhOOoUZQg1p/4mJtouFaVCuL+mZZMCBl96Uc4gYckZfhfUlTRX+MiHdciVRGLmS Xyy7gANm+88zjyG6QuNVEE9NYZSxBi8BM3Y2f3QP/SqM9vyzcoOzpainEGTYJnW8ZaLF +UUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ysmf6asx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx13si6924540edb.280.2020.07.12.05.11.43; Sun, 12 Jul 2020 05:12:06 -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=@kernel.org header.s=default header.b=Ysmf6asx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728786AbgGLMLg (ORCPT + 99 others); Sun, 12 Jul 2020 08:11:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:51640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728339AbgGLMLf (ORCPT ); Sun, 12 Jul 2020 08:11:35 -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 E787A2068F; Sun, 12 Jul 2020 12:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594555894; bh=5A7Kn5Qga4ZyMXUawR4RuAtCYEkJSQR1Ou26ajhvME4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ysmf6asxrQC+NuYgC8d1O+c4QEpxF3bmSjO+Twz4z6JI7z9x+YqcImui0RPpnmEqL xHQZPk342QzUL7zl2GjQlDjgYKcDm2H81BYFL170TrACZWURv2engWovTm4pDidg30 ugfIV80Tv+dhvaE3UWZAcxdstI5ySi0f6TAxPWuw= Date: Sun, 12 Jul 2020 13:11:30 +0100 From: Jonathan Cameron To: Artur Rojek Cc: Dmitry Torokhov , Rob Herring , Mark Rutland , Paul Cercueil , Andy Shevchenko , Heiko Stuebner , Ezequiel Garcia , devicetree@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 4/6] iio/adc: ingenic: Retrieve channels list from soc data struct Message-ID: <20200712131130.350fd3c7@archlinux> In-Reply-To: <20200712130713.64cd2bac@archlinux> References: <20200709152200.10039-1-contact@artur-rojek.eu> <20200709152200.10039-5-contact@artur-rojek.eu> <20200712130713.64cd2bac@archlinux> X-Mailer: Claws Mail 3.17.5 (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 Sun, 12 Jul 2020 13:07:13 +0100 Jonathan Cameron wrote: > On Thu, 9 Jul 2020 17:21:58 +0200 > Artur Rojek wrote: > > > From: Paul Cercueil > > > > Instead of having one array of struct iio_chan_spec for all SoCs, and > > have some SoCs remove the last item of the array as they can't use it, > > have each SoC define its array of supported channels. > > > > Signed-off-by: Paul Cercueil > > Tested-by: Artur Rojek > Applied to the togreg branch of iio.git and pushed out as testing for > autobuilders to play with it. Actually removed from tree again. Artur, as you sent this patch on to me, you need to sign-off on it so we maintain the DCO related records of how this got to the kernel. You can just reply here to give it. Thanks, Jonathan > > Thanks, > > Jonathan > > > --- > > > > Changes: > > > > v8: new patch > > > > drivers/iio/adc/ingenic-adc.c | 99 +++++++++++++++++++++++------------ > > 1 file changed, 65 insertions(+), 34 deletions(-) > > > > diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c > > index 89019fb59d48..0233a9055c86 100644 > > --- a/drivers/iio/adc/ingenic-adc.c > > +++ b/drivers/iio/adc/ingenic-adc.c > > @@ -55,6 +55,8 @@ struct ingenic_adc_soc_data { > > size_t battery_scale_avail_size; > > unsigned int battery_vref_mode: 1; > > unsigned int has_aux2: 1; > > + const struct iio_chan_spec *channels; > > + unsigned int num_channels; > > int (*init_clk_div)(struct device *dev, struct ingenic_adc *adc); > > }; > > > > @@ -262,6 +264,61 @@ static int jz4770_adc_init_clk_div(struct device *dev, struct ingenic_adc *adc) > > return 0; > > } > > > > +static const struct iio_chan_spec jz4740_channels[] = { > > + { > > + .extend_name = "aux", > > + .type = IIO_VOLTAGE, > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .indexed = 1, > > + .channel = INGENIC_ADC_AUX, > > + .scan_index = -1, > > + }, > > + { > > + .extend_name = "battery", > > + .type = IIO_VOLTAGE, > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .indexed = 1, > > + .channel = INGENIC_ADC_BATTERY, > > + .scan_index = -1, > > + }, > > +}; > > + > > +static const struct iio_chan_spec jz4770_channels[] = { > > + { > > + .extend_name = "aux", > > + .type = IIO_VOLTAGE, > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .indexed = 1, > > + .channel = INGENIC_ADC_AUX, > > + .scan_index = -1, > > + }, > > + { > > + .extend_name = "battery", > > + .type = IIO_VOLTAGE, > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .indexed = 1, > > + .channel = INGENIC_ADC_BATTERY, > > + .scan_index = -1, > > + }, > > + { > > + .extend_name = "aux2", > > + .type = IIO_VOLTAGE, > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > + BIT(IIO_CHAN_INFO_SCALE), > > + .indexed = 1, > > + .channel = INGENIC_ADC_AUX2, > > + .scan_index = -1, > > + }, > > +}; > > + > > static const struct ingenic_adc_soc_data jz4725b_adc_soc_data = { > > .battery_high_vref = JZ4725B_ADC_BATTERY_HIGH_VREF, > > .battery_high_vref_bits = JZ4725B_ADC_BATTERY_HIGH_VREF_BITS, > > @@ -271,6 +328,8 @@ static const struct ingenic_adc_soc_data jz4725b_adc_soc_data = { > > .battery_scale_avail_size = ARRAY_SIZE(jz4725b_adc_battery_scale_avail), > > .battery_vref_mode = true, > > .has_aux2 = false, > > + .channels = jz4740_channels, > > + .num_channels = ARRAY_SIZE(jz4740_channels), > > .init_clk_div = jz4725b_adc_init_clk_div, > > }; > > > > @@ -283,6 +342,8 @@ static const struct ingenic_adc_soc_data jz4740_adc_soc_data = { > > .battery_scale_avail_size = ARRAY_SIZE(jz4740_adc_battery_scale_avail), > > .battery_vref_mode = true, > > .has_aux2 = false, > > + .channels = jz4740_channels, > > + .num_channels = ARRAY_SIZE(jz4740_channels), > > .init_clk_div = NULL, /* no ADCLK register on JZ4740 */ > > }; > > > > @@ -295,6 +356,8 @@ static const struct ingenic_adc_soc_data jz4770_adc_soc_data = { > > .battery_scale_avail_size = ARRAY_SIZE(jz4770_adc_battery_scale_avail), > > .battery_vref_mode = false, > > .has_aux2 = true, > > + .channels = jz4770_channels, > > + .num_channels = ARRAY_SIZE(jz4770_channels), > > .init_clk_div = jz4770_adc_init_clk_div, > > }; > > > > @@ -427,35 +490,6 @@ static const struct iio_info ingenic_adc_info = { > > .of_xlate = ingenic_adc_of_xlate, > > }; > > > > -static const struct iio_chan_spec ingenic_channels[] = { > > - { > > - .extend_name = "aux", > > - .type = IIO_VOLTAGE, > > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > - BIT(IIO_CHAN_INFO_SCALE), > > - .indexed = 1, > > - .channel = INGENIC_ADC_AUX, > > - }, > > - { > > - .extend_name = "battery", > > - .type = IIO_VOLTAGE, > > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > - BIT(IIO_CHAN_INFO_SCALE), > > - .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW) | > > - BIT(IIO_CHAN_INFO_SCALE), > > - .indexed = 1, > > - .channel = INGENIC_ADC_BATTERY, > > - }, > > - { /* Must always be last in the array. */ > > - .extend_name = "aux2", > > - .type = IIO_VOLTAGE, > > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > > - BIT(IIO_CHAN_INFO_SCALE), > > - .indexed = 1, > > - .channel = INGENIC_ADC_AUX2, > > - }, > > -}; > > - > > static int ingenic_adc_probe(struct platform_device *pdev) > > { > > struct device *dev = &pdev->dev; > > @@ -517,11 +551,8 @@ static int ingenic_adc_probe(struct platform_device *pdev) > > iio_dev->dev.parent = dev; > > iio_dev->name = "jz-adc"; > > iio_dev->modes = INDIO_DIRECT_MODE; > > - iio_dev->channels = ingenic_channels; > > - iio_dev->num_channels = ARRAY_SIZE(ingenic_channels); > > - /* Remove AUX2 from the list of supported channels. */ > > - if (!adc->soc_data->has_aux2) > > - iio_dev->num_channels -= 1; > > + iio_dev->channels = soc_data->channels; > > + iio_dev->num_channels = soc_data->num_channels; > > iio_dev->info = &ingenic_adc_info; > > > > ret = devm_iio_device_register(dev, iio_dev); >