From patchwork Fri Dec 6 22:56:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13897911 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011038.outbound.protection.outlook.com [52.101.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85CA1212FB4; Fri, 6 Dec 2024 22:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733525820; cv=fail; b=NH81TBSioQxg/hHxdQUE+EFIu7SXO8T+XdfUn65Y8Iml9/XaQ42MHxwN1mIqxCyqPN6qdb0XUUBPfLjrD14hu4YeHzzEZ4/MSyp80oCF2jQoqM9IXd4ZxdjuBk7YcfpfLeulSfGJyR1wH+arRk+2jmmSfVlQOTsPOfivMUuf01o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733525820; c=relaxed/simple; bh=gdaZmGZKt/HEMZsvvWdVjisT/bSHP+AXZvmK/21Rxks=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bXriva996yMfRIO8X8DvDTUPg0OUHEdjsWhVQ/EmQCvEKk+KQohYGeAbvv7mZoJjZJOHyahabcDf2wpYdzlCZE863vvrQh35ymTfmpIEcdKkl413KZnjEEtRZBKyssuMcKPXG6iQDAFsIWa7AgJcvdQvLzZ/yyZEQ+u4N7X1HjI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=iDgihNNu; arc=fail smtp.client-ip=52.101.65.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="iDgihNNu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T82eu2FWssXcdrYxQ12w+tz8QPRnS/N4m3lNF4ygwsjgD8wJGNp2XvKL2O45X4LkcSf6CW0uElVcn8t1x/+v9Aq4wTepg3dcny5Bn8oddQ0arbYtayI/z50Q34F0DE0TEUWnEzzDM8gxywch3W8ncr6ceWpQ3hW7uAtWSLPA9DNp9z6vpzj6y77GjGH7MgIQll93YmRrWZYQTA1nzvbaiJMeVfTA5+IjYxPyXtcMphzJsBsdZcff6EOadJ752Ic5Ix1RIdqZP0e48izBO8eTBOH87mRv/9vTf28s0K+uH5O/HbTTyulr7Fx6W9VTECcFi3g2CCIv42XEtHXNMBO0hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fz0VnUtPq+U1rvgBgMjKNagLttDXW0PMW8mcqI0ufrQ=; b=wNsp9p6TDFee/NJbPb56+E8akUy+t8AH10Oitbhwmuhg2xpcCgRhPo1t7vCgjSVN19k6bbYGiD1qXuXulNKOL0j6jN3erl9qFNdpemac66lnRf8Q63e9lEU9PI7Rhl+myGjwnm9Ra3we2kSLjde8qX9aLXgZOF6M6E8EHESdfhPF4E6udc7OCcSytNmrz8XAzgnQUnpnkO3aihqeW8VhOK+0DecEolkPQlE0g9ySgYm9rDa3it++ZtBQs4o0UYnoUWikY71iGleIOcuBmZ85v9pNXEA4Q4rfh3Tdm5swSiwv7bqpnaDYJj+f8YNNkI8e/+OGhPqYHZ3uaJ1QmOnmwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fz0VnUtPq+U1rvgBgMjKNagLttDXW0PMW8mcqI0ufrQ=; b=iDgihNNuKu1EyLR0ClHoDlzl6bk6MiuahRLf8tu4WRIUvjoxKXHdZgT3K1TTg6t2WPc5pytEQ5wTQNDDAp5YwBbfT+V6Wm3+6Pp5tCeDPUV6L8Inx25Es+6kE9lqpREvBGM5M3tFP7tookx8zyvp76utEYZYe19RiqwqdHt9DqjqEdeaLPRjcoONnL2s+uhPBxCb7Cw6O0T04JZ3hh5HrH8TJhmeDFPD0Gxf+7kRnj6PGcjeCFvUob9WSc1lMUHs2k2IwvFDudkRyBlxeWbmR+m+DAGN5s28Pu5GMhFp5vAMw4dSxfgx2pW9oDEfwncQlTeoS93813Pqj5ct3h+3Gg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by VI0PR04MB10709.eurprd04.prod.outlook.com (2603:10a6:800:262::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 22:56:54 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Fri, 6 Dec 2024 22:56:54 +0000 From: Frank Li To: Haibo Chen , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org (open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER), imx@lists.linux.dev (open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Date: Fri, 6 Dec 2024 17:56:23 -0500 Message-Id: <20241206225624.3744880-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206225624.3744880-1-Frank.Li@nxp.com> References: <20241206225624.3744880-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ2PR07CA0007.namprd07.prod.outlook.com (2603:10b6:a03:505::12) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI0PR04MB10709:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a159193-c2cf-4c26-3eec-08dd16494790 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: BHPRf4DMBZjVLoO5+/0at9zwdbmy9/CaWMkEyH5FxUCtf96nVHv5uuFNWq+74SJT65lUou7tmF1CS56VnemswesihAg8rMCjuYQj5psaQEZ/RSBHvM/LKRa743WzyU0eP01C0OtvQC7kkKqArzwufe2AlndwxfVS2fBcADAxvFS8qi2ZR3baIA/rjtSJ0ceGvDZm773WfccF93g1A8/wTQv2SOfeSGaYRFu/aFuSlBClNFV2/sJFQc2Zjd6Qj1lNwL2x+kmr1Z4fZ22KqK1m5wI6u3jSkADsRjRfbQX1F9M/S6I+M06xziLxPaiJL3bk5M6HJ5MNbwXZHJT77hD8WWNx4pav5fWO2VvRML5SmTsNvBt1E+eV9u1w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:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PoZ0b9JS9DWXIkHZXaXYMzzGWvmCWbhEVi44kFWPh6Q3IZmhHLrqPROG7TgLCi1Dog1kvP5G8JQy5mflYMCWhvJgG91TsLijhfxPIgUSSRiQXk80BbmTXyvTS98CdsfF6I393CGfJrV5SUz+i82cMwq9Ef72B/VWMbTIxe06Fs1x2pvvNa5ahr19/KbFMNrbjsyTPljOc5ygscjNmOZh/K8x1qilrrTI480SrEYejGK2shMDPqQHLqfJ2mxi4KQj5HtQt6VSOLug2NRNy29zo4jKj/E7k+46fzdBKUQOJKzqBaUpWjnB0FWjDdbvLGGiNp5cPfbs4JwL9Da0CkkivxzCF8qm/EEy8WrBibsgK8TK0CAspjU84XJX85ZPh0QYJuvJBqfej/ZAFtjH16VTUI3H/omiWCKxel3cGl/JmYuibOOP43ajlElUkocXZ3qq8DzjtKYSwn8rgHemWbURMmmSwxC4zfSMH5O85eLhHTKbQjxKf/VDVp+gQP0xAqxKKcuq4pPhmNlwZNuQuBVfu6KbAZfthLwiIJsziqlpJLfhwEVUYY9P4iREqTgYEa39hAjwXMQjSQFFu2JTPOp3YJPiLZkv0EXpYK0ORIT/POuMbQc1JfTHBbTXdl/ycRK2QW/qr3XZ21me5Y8ukZsYYCWZaAmiMo1rn1TNTyfD7zjKIOHh7QglRS9n7M85DE6SEJvkpwgwjsAIvUrkJUnPvzPI+OGuEM9I5wcf+lw0CBZ/c99VclcBph+V6qcQXxdLs0x1PHK/+DKNQ8XZNbz/ovDJSk0eQaYsFuyVQ8HjC9jB0OVZazbkYrcPp3f8BR5PiYiMeTFl5ZIK5x1ZKxkzXdIVP7C6X54leocTKr5xFmMrRoc3SF1Gqfc0XWL0ULsFy550PXRH2R3S7mSUF1J3b1l9upYVRG3NJCQQ8M3WMtB+5O5VH84UmzlCSXER2R9HUXALaJBd7Qis1Ne3rzFXC9mz4ZJldu/RFde7Uv20/Qmqqvlm7mVwdI8CwpafqvVnogmgI0f6FbK7eq+DDMsBY4/A+YLhkz7zcmhBTl6H80PBv41ksl+QJbE8JE+bkC+MbsC+OnOJcV3qI33pfuvlAXD1kMF3uPu/fwVHlGkzpZHFegt0eOqdWXURPdn60BmgpAwKA/fCnuz04zoXqqd+xVEBCGxKLdTR5DmuhsBFZDOckO0qBCcVh9y4ZUdLswHAlBkWEGJg9bZNzqYVq5pTF+2DMR3y1MwRojUWIIx1Q3m5Y201HYVXltlTgvkniKocXhkeMCwYb3M4Tr5/ccNPm4xtESB1PfX9rLEfJCLFbWdezKdHeqJ4vKtpqeTJjc4CA2C7jORa1Pjr1xwBI/0BT+o6qxkVE3A2Ih4rcveJLnkrNOOhFpNDn4q0wqyTSR/s7TO7U4Owpr6yoBvymMjSWmvr2WAIfvBP+ItcOwhf1n92OdfcUVKXVM18R284KdFkDvQOuI7uCcc0qeHHbevxzBSeaEMGO79ypYOoZacEKb8GOGHwQYRz4p/yS+GUHLpQFMxcSTtp5zEtVcCcQUHunNddSf5jUAJTvj6TU2X4UCLPO3weEYl+hbkWL31/laYe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a159193-c2cf-4c26-3eec-08dd16494790 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 22:56:54.6899 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: il+JOE66tIhIv/ZptaoQFOB+zVnuaXYzOcRybyqdsASbBX9T/2d8mi2++kvOClKXI5ZG0t4AXa7q4y81jcoBZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10709 Use devm_* and dev_err_probe() simplify probe function and remove vf610_adc_remove(). Reviewed-by: Haibo Chen Signed-off-by: Frank Li --- Change from v5 to v6 - none Change from v4 to v5 - Remove vref check in remove action callback Change from v3 to v4 - keep vref_uv as u32 - keep original regulator part and only add devm_add_action_or_reset(&pdev->dev, vf610_adc_remove, info) Change from v2 to v3 - change vref_uv to int from u32 to fix below warning | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202411070633.NIrO7Ert-lkp@intel.com/ smatch warnings: drivers/iio/adc/vf610_adc.c:857 vf610_adc_probe() warn: unsigned 'info->vref_uv' is never less than zero. vim +857 drivers/iio/adc/vf610_adc.c Change from v1 to v2 - add Haibo's review tag --- drivers/iio/adc/vf610_adc.c | 78 ++++++++++++------------------------- 1 file changed, 25 insertions(+), 53 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 4d83c12975c53..fb7afa91151f2 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -814,6 +814,13 @@ static const struct of_device_id vf610_adc_match[] = { }; MODULE_DEVICE_TABLE(of, vf610_adc_match); +static void vf610_adc_action_remove(void *d) +{ + struct vf610_adc *info = d; + + regulator_disable(info->vref); +} + static int vf610_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -823,10 +830,8 @@ static int vf610_adc_probe(struct platform_device *pdev) int ret; indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc)); - if (!indio_dev) { - dev_err(&pdev->dev, "Failed allocating iio device\n"); - return -ENOMEM; - } + if (!indio_dev) + return dev_err_probe(&pdev->dev, -ENOMEM, "Failed allocating iio device\n"); info = iio_priv(indio_dev); info->dev = &pdev->dev; @@ -842,17 +847,12 @@ static int vf610_adc_probe(struct platform_device *pdev) ret = devm_request_irq(info->dev, irq, vf610_adc_isr, 0, dev_name(&pdev->dev), indio_dev); - if (ret < 0) { - dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", irq); - return ret; - } + if (ret < 0) + return dev_err_probe(&pdev->dev, ret, "failed requesting irq, irq = %d\n", irq); - info->clk = devm_clk_get(&pdev->dev, "adc"); - if (IS_ERR(info->clk)) { - dev_err(&pdev->dev, "failed getting clock, err = %ld\n", - PTR_ERR(info->clk)); - return PTR_ERR(info->clk); - } + info->clk = devm_clk_get_enabled(&pdev->dev, "adc"); + if (IS_ERR(info->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(info->clk), "failed getting clock\n"); info->vref = devm_regulator_get(&pdev->dev, "vref"); if (IS_ERR(info->vref)) @@ -862,6 +862,10 @@ static int vf610_adc_probe(struct platform_device *pdev) if (ret) return ret; + ret = devm_add_action_or_reset(&pdev->dev, vf610_adc_action_remove, info); + if (ret) + return ret; + info->vref_uv = regulator_get_voltage(info->vref); device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3); @@ -879,52 +883,21 @@ static int vf610_adc_probe(struct platform_device *pdev) indio_dev->channels = vf610_adc_iio_channels; indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels); - ret = clk_prepare_enable(info->clk); - if (ret) { - dev_err(&pdev->dev, - "Could not prepare or enable the clock.\n"); - goto error_adc_clk_enable; - } - vf610_adc_cfg_init(info); vf610_adc_hw_init(info); - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, - NULL, &iio_triggered_buffer_setup_ops); - if (ret < 0) { - dev_err(&pdev->dev, "Couldn't initialise the buffer\n"); - goto error_iio_device_register; - } + ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev, &iio_pollfunc_store_time, + NULL, &iio_triggered_buffer_setup_ops); + if (ret < 0) + return dev_err_probe(&pdev->dev, ret, "Couldn't initialise the buffer\n"); mutex_init(&info->lock); - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(&pdev->dev, "Couldn't register the device.\n"); - goto error_adc_buffer_init; - } + ret = devm_iio_device_register(&pdev->dev, indio_dev); + if (ret) + return dev_err_probe(&pdev->dev, ret, "Couldn't register the device.\n"); return 0; - -error_adc_buffer_init: - iio_triggered_buffer_cleanup(indio_dev); -error_iio_device_register: - clk_disable_unprepare(info->clk); -error_adc_clk_enable: - regulator_disable(info->vref); - - return ret; -} - -static void vf610_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - struct vf610_adc *info = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(info->vref); - clk_disable_unprepare(info->clk); } static int vf610_adc_suspend(struct device *dev) @@ -972,7 +945,6 @@ static DEFINE_SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, vf610_adc_suspend, static struct platform_driver vf610_adc_driver = { .probe = vf610_adc_probe, - .remove = vf610_adc_remove, .driver = { .name = DRIVER_NAME, .of_match_table = vf610_adc_match, From patchwork Fri Dec 6 22:56:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13897912 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011038.outbound.protection.outlook.com [52.101.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2257213E7F; Fri, 6 Dec 2024 22:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733525822; cv=fail; b=QaEJDSz52Wtdjss+80xi/FYSwh8LGYK6Ys1UZpK5FpmFJqpTBa4D4koBsqCj56YhFx0ML1FYBhiC2rqP1gtg6355eDJSV3fWGjlL4hNAsuzFC7eS7jJdZFeqgDgWktHk78i/q8i7tjuaMhgcbRcdwzHAYS/pwE/dkRw8DKVAcE4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733525822; c=relaxed/simple; bh=uXbp0XllZwIzvbFqkk5iMzXc+aKoGQmSbAy7pv4AWs4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=N9Q5xQxZhsQEbhZkAxScgsKq0DdM5i8kByc6U8cFG/YY1JUJnBCTsIqA2IKWthZrYpM2PZhsbeD4CJUdvk07JCzTQmOtC5U25DWUFYQzfZyEkGJd2ZKVBZGjoVRo3dNrVIAR9n/6WuSb4VkBbhYwakXLFH+nNCY23Sd/ohqLIlM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LOllkyBF; arc=fail smtp.client-ip=52.101.65.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LOllkyBF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xj1jloDodM+mLHYH3zVq7p2ohzZQkW02mhS798BQHVKaX2dYRwUBsNmrUCm5TJhyaKozjtJq6Bf9Mg2bhDKSv+RbDVm1JiGcHpIxJaTKCTirW2mdmrkxxfgrb8NF3U7AhRr+unOmjv0MufJ1UaIQ+E8Pq2WQfhls7EKzMntLxX/cPeeXRwheZVownSiGh6lziorzBovgAEAXieKPjtFHdJA8CeZekSrWluwkmRXs2mR3JPP1ob2pGSlun4HUePsdLwSntRDefNe4F42d7pCQgG6DZtagjDXYnVZuCIBjR6udYXaU7Wy/cA1jMTA/lwGDr+e1Q521i1ZQ/y8yDoB7sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4uFaRLh6BdwDuJ8Mwv8gLyiNqir4PRNnz1HrBunXk94=; b=rkshQJP4TP3KSio35KraOOsif9HHxyuAktNTqV9KoVIC9YRg5xDJf3k3OWGNCAgjS8/MgCvFRp/JHYCqCUx2COW1wzKnZXoZ0AsQAimDgpH+7W8xeL8Hf67t4RB3eKfvHCBiKPXYsh9jsTKZahhmssB96SVj/FLo9aPl/yPLS/45K+0tmMMV+kjZTN4WeXctaY51slNzg2XFfPkg2ugirm9eKfGmmcdGv3HP04f/cDwMsJW7vbMPGwV+HOKcxTVECv3izOEQ4fEJlnTnDxj7CKX5QlNtuFyepbrpqkcLucSnyls6DA+S6/nlg2wJCgr1UUB8lOdmH09P7h64ELkaWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4uFaRLh6BdwDuJ8Mwv8gLyiNqir4PRNnz1HrBunXk94=; b=LOllkyBFgLuKP/T8OVwnDkf2KVvJglZIxQKwLwv19Cvc1Bjl/kSxwXR4kDViZ6CdiwX/b73UOt1l6UmJ5ORe6bRtIoTcBwzRxpmd92BjPpmyK+5ymI3yBu6ONPymapVIhZCxdTz5giZy+/Jp9zvRzbqz+278DY1d6lbh8TZmM78g39aW0khUcg8iSs4gqMx/85cE+d9B/Zi2B6o5z5vhWVm6+BLNcT/xx7fJbjwn2NwKvZFQpFFN1fzRmMyWGJs10oiiN+/es05GgdgFDCWk6vRT61sVIOVk1RizrV8k6rRWIkYB2FG53p5L9gQmDPukyxBWHTM/DDGZKJZFiI8jJA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by VI0PR04MB10709.eurprd04.prod.outlook.com (2603:10a6:800:262::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 22:56:57 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Fri, 6 Dec 2024 22:56:57 +0000 From: Frank Li To: Haibo Chen , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org (open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER), imx@lists.linux.dev (open list:NXP i.MX 7D/6SX/6UL/93 AND VF610 ADC DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v6 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Date: Fri, 6 Dec 2024 17:56:24 -0500 Message-Id: <20241206225624.3744880-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241206225624.3744880-1-Frank.Li@nxp.com> References: <20241206225624.3744880-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ2PR07CA0007.namprd07.prod.outlook.com (2603:10b6:a03:505::12) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI0PR04MB10709:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e4750bb-5696-414f-8be4-08dd164948e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: JNeIkx1T1106ycWubX+2QTneCZM3uWnSCAxQ3Gf5oQSY3yDsRMCPEGLPVYi6SLmHPwvfyOnx68/2drm/hfiRvj8oZzgUMl44hndCKpbCn+0OwJlaVSLZTZ28eKBZV1YHbLjQJvDdk8SeCK86keqUiDOWwlbcl469NZIyn00oow+sKAk35dzsYUJJHRuQjY00j29GdqHeJK7jMfu9RdEzbPcFe61yLk9by8MmzWnhqA6c//LD1jqygu7pDPGM/n8fTztFsZKlnwYE06b+2v6hoU5cJO7IlgQqVfXUIuQKkW0qI/SsYpALLuhzWich1uOW0cVUJFNUx1sj9ACBG2WL9/g7Rl+p6DarB3XuRuawExOP8/CX/FlzRmYBpC1XFw6WL550hyH6Mz0jRrqUDtvUrFXrjZEKDwHvZxnZV2cMLmGlEkW0eMbkRUyslRsALsNPQo22J80UZOTQXvDBer8WutOvB+xFXy4WnECSJjTgy9XOB51ynOFfp4hCJNZiAuSBWQtFxa90XnzbKleQNOdDVLMH514B/WJPYGOf3fu0iJ+BQHLXZGxC0RVO18aqAP9U89Q0gJCclTwPYfP8JisduJi1Nuu6zqH02xEm87o4upwsv0ol2Ok6fmX70Nvzas2BouITAt3TXpQ8mpiM2a6oeEp74L0ajLsp5lu88iMRujwkJoPnPDokYt0FooiOFS6Z9B1FY/E61nSyGvDFjta9O2CkQNFRvhB2ntPRIVMYZvIXmvt7ve1HT2QewMDXMJdrF+LZrFBkmULLUQqaPplHIBh/8P3HmKBpooVosVvvsy3+v5b3uiPHITg/J3JtSUbkE4G/zz/7EpNrcqAY5RPCNNPhrz1GfdoYoDGhJHi1tcUhucwvclqP1EczKTFGhz452ukl/QWhshQcCc8CFYXlkLJ/1iUO53BWXc9kl+XSIP4YtS2xBbbizAK9rh+Xdkiupm/RgnRM1vscx8VlEYLxmm9YtwrMp0jKi4t3LCJIx/gMCrAqOk/06eCt/kYttPbVoIhAAK292linxc0Z+1dRF/i/EfpGvEHzhkPoLTD7jamiEzyNnemwcrpym87dtjlUiSlBefN+23pWEyucI3LUFd/aOF6O896khLjYKGg5F8EffM2ZRwvmp3CRY48y6KeGvOlbyaLGh/zvppFzCsjWmBMuA8DaEWRDcJ2jgfIf8Go1ryHN6PfQwiwpC+3oxdiG8/ww8477TPnxjPODherw4D3W3+72uWKivLpAMusoTo7F+2gL8TNLAV6fapoN3DajyFRBV9Hos+PCT2uphJcw7UjGwcEOQpMitSEqY4WxyWq5qxOe2mghDjcK21Nd33qPDMZeVoBetalUtRASvLE1ZcP8IAtXzGBQxmVpZLhipftfdlaLEaJ2EEGkm17mpHXbdtSrTbKz64bzqQLhX6T9Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uJCAc1ekxY+ml8/gZwAnAmxA59zoI4/WRGXwRDtyAi7lS2k+obC5VgH12OV1DcFAY+euGK46N/unPCXh0DRT+wHqdP3GGHYoqvinzNzBD6h8ALC49Kz2j40wvLP/mQ83olrd1QrnV5UBxz8c2DRjJ0w/e2Sbf5V/mP1lV1Caf7GMzyfxfGrMmQURRL2s1xaB/cYPvwLJD56JPGDuPWgDQlumFrP2B7HmG0gTitCyGrIsp1Z2R4HpFzmmK+aZsbQlFRqiO+YuxShhAGPY3RHH9emjIadjgJFn46+IMfPsAtX2yR7w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1kTz0NhgwIhWtr2IDKlu0N2qaNs2ydUQXIl3FjebIHL1VZ7Y5PP8iK7Ppwn+w1YpjS3dLKBQYbDuaYF9iY7kPEHrHaOmxW24u6ii6nDnhCZURc/x4OuRwsUBs5bkrzqd/wCFXK8qp0l6MVcIZmOqFKIZu+wJXSnwfAJAw6RW4u9gqBHma2hdE0mW1rOWjZhYY591TwdfIfVRdMBkIfS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e4750bb-5696-414f-8be4-08dd164948e4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 22:56:56.9187 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VG90F8PP5pcnY0lsqDhKeBQdVEaHXXuyQvbCeuxGSNCqGT0EuwrUwqSCSSaPThIicf3hG7j7MvaPaQioktfoug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10709 i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for compatible string 'fsl,imx6sx-adc'. Reviewed-by: Haibo Chen Signed-off-by: Frank Li --- compatible string 'fsl,imx6sx-adc' already document in Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml Change from v5 to v6 - remove return value check of device_get_match_data() and move it to declare place. Change from v4 to v5 - none Change from v3 to v4 - Add struct vf610_chip_info to avoid cast int to void* Change from v2 to v3 - none Change from v1 to v2 - Add Haibo Chen - change cast to uintptr_t to fix below warning | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202411052345.gyJaM3h4-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/iio/adc/vf610_adc.c:20: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:21: In file included from include/linux/mm.h:2213: include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~>> drivers/iio/adc/vf610_adc.c:874:28: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const void *' [-Wvoid-pointer-to-int-cast] 874 | indio_dev->num_channels = (u32)device_get_match_data(dev); | --- drivers/iio/adc/vf610_adc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index fb7afa91151f2..850453be7a8a4 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -177,6 +177,10 @@ struct vf610_adc { } scan; }; +struct vf610_chip_info { + u8 num_channels; +}; + static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 }; static const u32 vf610_lst_adder[] = { 3, 5, 7, 9, 13, 17, 21, 25 }; @@ -808,8 +812,17 @@ static const struct iio_info vf610_adc_iio_info = { .attrs = &vf610_attribute_group, }; +static const struct vf610_chip_info vf610_chip_info = { + .num_channels = ARRAY_SIZE(vf610_adc_iio_channels), +}; + +static const struct vf610_chip_info imx6sx_chip_info = { + .num_channels = 4, +}; + static const struct of_device_id vf610_adc_match[] = { - { .compatible = "fsl,vf610-adc", }, + { .compatible = "fsl,imx6sx-adc", .data = &imx6sx_chip_info}, + { .compatible = "fsl,vf610-adc", .data = &vf610_chip_info}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, vf610_adc_match); @@ -824,6 +837,7 @@ static void vf610_adc_action_remove(void *d) static int vf610_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct vf610_chip_info *chip_info = device_get_match_data(dev); struct vf610_adc *info; struct iio_dev *indio_dev; int irq; @@ -881,7 +895,7 @@ static int vf610_adc_probe(struct platform_device *pdev) indio_dev->info = &vf610_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = vf610_adc_iio_channels; - indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels); + indio_dev->num_channels = chip_info->num_channels; vf610_adc_cfg_init(info); vf610_adc_hw_init(info);