Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp632461ybi; Fri, 21 Jun 2019 05:40:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSAeLBSO0vraTzDBV451AHY/KbsLWf+f88DXpzp2l30v8rprAhYhKDlmhEKrU/3J/va3Vd X-Received: by 2002:a17:90a:778c:: with SMTP id v12mr6052556pjk.141.1561120857492; Fri, 21 Jun 2019 05:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561120857; cv=none; d=google.com; s=arc-20160816; b=RYei9iA8ojv30fscmX7pNW1X9hFZRZjTam44KD6Dqivs139OkaKQk0HnYVOy+1uQ+L FmmUi1Gzd326Kozk1H/yZCj3+buMrtY1Da+jmch3XZKI4NAKaHlofGXoOGQ4AO6fAwCU +sLJoa7h/pWwF8JPT6XohwxW8gbzZhXqQOvAvMvTuGxO1jPZDLxSsv5GkpaUChJsEeyx SyJhAOlLeLaNDepFymXzkEbfcUhgs/SpxPSt3u7M0dTU7d+Zvm1YteJOd9JRRsNJvklH Lo/3XA8UrKyNSd/CTHUd21C4276lCjEOKXjTiRtvkUT8XoLAX6+gqC7O5AHfquHWSgW6 eqcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=m9ujq0FjNOpnARa0wtTiJpN2igZAh/C9uap/d0xAMGw=; b=QP3XaVOwReUlvL2LzjkxeO33gVgyxLXTFOHExtmqDouW5bNP7RtLJcEbb4kuN7+lOs SVkvIOLT1IeEe4TknfwJrWe1Ln6//Thkn1DJyMkDVzAhyoxf2IEz9uICMSIr9gNn8OcX iZR3R5vE3uXKK/ykfVATMko+7mZ5NbM2bntXLJo6tGhu9eOZAEJsB9a5oHdb1qRlgwEr N7cA5frf9xbvn5jR3h9zc1IfUpfry0B2mKVpHsfFwnEACTG8jzEvgQ9iHOYZpKa2rvAP +Ub/72uHhiTfWeEyXiR9kAPv21fURSCF6dLCsb7UTLzvm+FW6XsQ0MrJanLczYKMNkTZ DgHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@analog.onmicrosoft.com header.s=selector1-analog-onmicrosoft-com header.b=jW8tPV+L; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si2621653pfn.188.2019.06.21.05.40.41; Fri, 21 Jun 2019 05:40:57 -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=@analog.onmicrosoft.com header.s=selector1-analog-onmicrosoft-com header.b=jW8tPV+L; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbfFUMkg (ORCPT + 99 others); Fri, 21 Jun 2019 08:40:36 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:57652 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFUMkg (ORCPT ); Fri, 21 Jun 2019 08:40:36 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5LCBHZC018678; Fri, 21 Jun 2019 08:14:21 -0400 Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2053.outbound.protection.outlook.com [104.47.42.53]) by mx0b-00128a01.pphosted.com with ESMTP id 2t8vahrgnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2019 08:14:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m9ujq0FjNOpnARa0wtTiJpN2igZAh/C9uap/d0xAMGw=; b=jW8tPV+L8C9e/0UCm/bBo/joKkCv67W6M9/r8NtApBw9oMlv/sSIgqi1JJrfWWpypK1DAEyOSyPQHFCF0e2KHlhBfoiiTt8Yp1LmC+ZCeNQsveoNmsJTQUB/zqDDI+c2YClRcJ2pt7dhhECRyb6cXX89d0xje2GOgtS4wU91cMc= Received: from BN6PR03CA0116.namprd03.prod.outlook.com (2603:10b6:404:10::30) by BL2PR03MB547.namprd03.prod.outlook.com (2a01:111:e400:c23::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.13; Fri, 21 Jun 2019 12:14:19 +0000 Received: from BL2NAM02FT012.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::207) by BN6PR03CA0116.outlook.office365.com (2603:10b6:404:10::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.13 via Frontend Transport; Fri, 21 Jun 2019 12:14:19 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT012.mail.protection.outlook.com (10.152.77.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1987.11 via Frontend Transport; Fri, 21 Jun 2019 12:14:18 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x5LCEIJ8023562 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 21 Jun 2019 05:14:18 -0700 Received: from mircea-Latitude-E6540.ad.analog.com (10.48.65.115) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Fri, 21 Jun 2019 08:14:18 -0400 From: Mircea Caprioru To: CC: , , , , , , , , Mircea Caprioru Subject: [PATCH V2 3/4] iio: adc: ad7124: Shift to dynamic allocation for channel configuration Date: Fri, 21 Jun 2019 15:13:43 +0300 Message-ID: <20190621121344.24917-3-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190621121344.24917-1-mircea.caprioru@analog.com> References: <20190621121344.24917-1-mircea.caprioru@analog.com> MIME-Version: 1.0 Content-Type: text/plain X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(376002)(346002)(39860400002)(136003)(2980300002)(54534003)(199004)(189003)(336012)(77096007)(2351001)(86362001)(186003)(246002)(106002)(70206006)(70586007)(47776003)(5660300002)(316002)(16586007)(1076003)(26005)(7636002)(305945005)(2906002)(4326008)(7696005)(76176011)(8676002)(356004)(50466002)(6666004)(6916009)(107886003)(51416003)(8936002)(14444005)(476003)(126002)(486006)(426003)(54906003)(2616005)(446003)(478600001)(50226002)(11346002)(36756003)(48376002)(44832011)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2PR03MB547;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0f4dad3-23e6-4724-a30c-08d6f641fc88 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(4709080)(1401327)(2017052603328);SRVR:BL2PR03MB547; X-MS-TrafficTypeDiagnostic: BL2PR03MB547: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-Forefront-PRVS: 0075CB064E X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: xYqLZJp+zOOkdyQAsHgI31cpt+VQ6zFzUNSPNsgbH/IMkVrea5V0tqYxMh9hzdtCk3VZ/61OTv1Vn6piB2h+Mr49aOuicyxUNbPGZBwhLUIvbkydGP1yDpzZoQff8gZq2A4U2u6dCyoOu+BixmtOad/IQ2QFjaBQSmEYC41eaZwjrt83B5bdezKl8rMT9hHyeaGP3DZNfQ+Cgrm6/vg+XI83abZgfScAUQI+r/at1gju/wyu8SLUPDK/3X0t8IxP8VUpx6RkOyvGevxgfcmoyawrPMTWGy8IJnk3NJBO4t6gRzczxn8WK3AmVc70JI664hXN0B150Jvqo9dnj5XWVduEiKji7G+dc3+nivvt1IHtzviWswjcHznx65H90xKK+Xt0ZOy6jtoWI4kKLf+2b8BGLv+uDKZIpS9lVJzmiCk= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2019 12:14:18.8423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0f4dad3-23e6-4724-a30c-08d6f641fc88 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB547 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-21_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210104 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changelog v2: - 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); -- 2.17.1