From patchwork Tue Nov 26 19:52:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13886320 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013067.outbound.protection.outlook.com [52.101.67.67]) (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 20B3D1DE4FF; Tue, 26 Nov 2024 19:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732650806; cv=fail; b=IlPj4hik1ADzdRsl8Wmt6WDWzQFZv5BhQQsYAGG7RD8yqFd1tLS7q6bE1CDx8b0F82Vn0EobuNtsnB8Su6+1KWubQgMxlPHjlQQMWdtKE26kerW3wfKBe+TkmZuR4kfaTX5LzUOdsgZQ4IndXQWWA4nBQW2A7l+miWmTTdXm9xc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732650806; c=relaxed/simple; bh=tOE4mKNKmtBMV8Pd5B17TXxe7OglzDV32QGTf7E8ONY=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=QlM+v6sMtQuxN/TyesUqKyCEwb/nbu5e4mkK32uRPULvcBgY1XLAAWanezU6VuVyXWgyM9MSCTF6GOGRHYCwk3aVn3gnLsbb9DT7ukrBL5V5/LfuemPGH2rgg4dzEh+aQ+Xg9Xnwd6ULw+9UxvQu3XRwaZDo7OPbuHq6ufKxm/s= 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=FHTKmzMM; arc=fail smtp.client-ip=52.101.67.67 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="FHTKmzMM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I4+Ta2dtpxrOEUxdnF5r6F6VilbqMO3WCV35bHuBSQS6fLNSIvX0EPNmfayHHPnIxQwVerPdRw0k2CRKE3liLTz6QrQHIdj5XN3vNmGCvJ/+f5Ysngyp3lHNWXcgW1wh/blEK6iD2EvFeW+CbX9AJ1orI0ld9PZWv5kecTQRoFB2vIeOaaWt2E01wcEV8ygw6VGKxPZR3JobNLB7ZAHAlhgL3KTWwl8XUM51iG4+dBZFTUIHMEyif6ts16hTaPcU/yL5rqaZqGlNNkjngq7ZsWyXlKyJuot4mZV/6ZQA6Y0HHqEbCXwcPiGpPdnFTb3UnzlccOtKNNUOC8GvGbcOuw== 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=5pHt8SQC/5gvZR+hq/9Av3RdAaPl5rvqKVPZbK+v02c=; b=OnLaTNzEMoFu6oh1lJuY5b7SFUn0n1Vzd6kcZ/RDT0x6yACOBbjOrpduwu5zaQT7Mj0al4N6KqhUGyWqWQQbSabTCKV3yy6iU/yz+UgmeSfSo1tKEeKNrFTJOh6zVApR8SNYvxSBzdcsomosspYT9ssJL6IEILx+J9J/kz4cDvgrWugbEooWmm2i6vDdbj4fSFL23X999360jaNDk8Gfwg+mbhPgOmw4JnesRiWlFYUZOKCx7fPUHderLFAu7vr+WzqhC9kkbJF3KVRGQALGhx7US1z6RXr5/wn7YjxTjtva1sGZu2242QU8QAjOtJr/hjWoLS8dY2WfnU0U3EHpuw== 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=5pHt8SQC/5gvZR+hq/9Av3RdAaPl5rvqKVPZbK+v02c=; b=FHTKmzMMCj2sBdfRwLo6nvm5wpPqxSPgIWwCnNQcZoaL2WjyXxcEBvXU9QmBL4SEsdQTV+aPCTxduKDLEveK/8Pvb8a/X87y0EQFcUG3u1G7S+IN5XCxZz42zNWQQ9ETQ4fyHbzh/JZ8h/PHW6HqOei/Meypu3QqXT7zBM//cqzh98XoeRNHbOimmbQm21uvFOnrnM/b36aIc1Tp6Ydjc+zsQcb6pbqpxs0Sypn7we00Q51qYPYRvbmsC9yMSas4aNIRLQ1YFXngn7wX+nPjlN2+fCOW4q6vvzoxC0zhJ2HDkRPWujcH+Bhj35wsy3oJ7hDuHjdi1PbcTH10UUScWg== 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 GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 19:53:11 +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.8182.019; Tue, 26 Nov 2024 19:53:11 +0000 From: Frank Li To: jic23@kernel.org Cc: Frank.Li@nxp.com, haibo.chen@nxp.com, imx@lists.linux.dev, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Date: Tue, 26 Nov 2024 14:52:55 -0500 Message-Id: <20241126195256.2441622-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR13CA0190.namprd13.prod.outlook.com (2603:10b6:a03:2c3::15) 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_|GVXPR04MB9831:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b8bcdac-fd0e-449c-b9b5-08dd0e53f500 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: Pj3gGeWvpD96kWNm/ifq3m5LYFbPv/beL50GQr9r8oVJObzSsAuGydZN9AtUxc+dja3kSHf5g84BfW6bYK+uSCvY3PCyKOVqQxDw6WMxwR9xmFEcRKi7edpYc6nCl7IX8C+87pQpltzI0bkYr/QuxN0MgQ25ZC+CtAyjJUctBSCo/TC66QwwN3dUG4YQBSgRcU5m2Hc/xePgpA/33M8xWOaBp56JG9HmK0+p7jkFaHfjHIzxIx84L4/TCF5LlfVVhiNSzhjw+MhOuriVniR1VTD327uJ/KSuJ4UI4IVDlqN1o966GyBemZ3ErDL3pbpZSxYd9550yQTJCfFqKljeX8RMiRMYTq6WoOogW3KXODEFcG4LBIPOV8YH2M0DTovpcUKIssx1JvU+Mko0dvtFqwWBnKdkHF2AhK87J70OwFcv2fdTZJVeEo44l7X9RZ2mnpyYwHm3+KqeGSTnGy5cFQtSwU15aCIuHaJBkBev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376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6VbXrJ1PLr8Rg+F9bTCiE8sPOtVueovVEmZ76RwvsRFxRhYoQG6VII9E0MVQImCjmtoPK+q99Jmlpnu7Srth13aEvGxvZz6tG+0hwvmUXSTgIfGjMOoireUPT3QqqEagnvHl5xfIrRddAtloa6HjtEdE/U0Mg7Nbxwd8RTIhvboZzQyszHuvZNASdLiSwcPFU2kf1mdDbhx4kWo5mW4BoSWPlfeCxR3lT2p1822hZUp6A8rIAeQPB6oJRphtzuHZNKz4fLTwrEmjeI76HUS2pizePO+T6HOploQPAoH0aJqBARFcONWFvwCNVXrvExJxwXrFSRTo359JCQqfJDxdOb4fxpYZT2DynD9iEwG9cLWi9eRPxDvbP56L5gYr7hU++chdlQyFQENBtT1Vy5STtO8fSXoDQWqG60+EJoWQ7eH135wpXfvojkh8bE0WLa7hZbnu1B5glf57unxqenJxeCa/sj4yfQfIDBuskhysOVbucRucHAx7A9NhNpPDr4eGaazfMxxmIwVpYlpQkgyT42CkmWO2F7rgA0oPDPVirzjOzTEYuM9GHln+uWS80+34Daebv3yrL/8psDURFUh8D2PnJnXRnNl2FVdJIovI0lE+IVhragsYe9Z6uRjsKDyqVv7OrGgPoxqEupoUVgbdCGtf4SoxDZ1RqUTcc6Hie3iCiNoNLPKoL05uVMuvb7lDNt9Vr36cY/x25e5nFaWzb1nNIb+U9pHS/Ttvv126lSXsEckTqsZaIRpG3Ab1/wIDeDXXYd0SuqZuNEOCl1lXGhjWEavO++FfdVGlA0kHRkoaLH6xSsv+OadqK7JzzKjI0Hudj/bzEXvvraZi4jGyMddMXLqJCzyuY38Um/0HolJ7L+0TEPn63ZBMF900mz7r9ikZWsyTXzCYTsygpZFyhcj6dfbxx/qsGzcWC0AxMBKqtNlx+N/tYw4U7cKpQKontO6EYdBOOTfYuN1K4oaRTu3NrXaQPOcr3EzbELWhX7FD4CcOOTXzU3lXMFj90LPGUFmlpT54WG9AbIbVdtX8yZwvIxLm0MKoXDO+f59zGBVcg9AKGOOo35jUql2bvCTVFYhAWcnARUgi/xP6KnRl3syHV5XfLzQRKoL8bCV1GxB9DKGE4H5wfGp0J0g6pCWwOJzpyKuav1YyGAhnAA67CjKGH7+jAkVv+ad9Mrr8GPHAJ2+o1A3JQbp+xijZCUF7zqPCVmOqG7NXNnsiiHe5QKzb/MbBAVZCtYP3DcbufmieoZU/olNM0H0+SwRJklXYTkXq3IFBIFsk0lKmGNl+R0Wz5JlKqqyqe94JtcnwUv6qZdRcASWfhwDKS0NyakUP3KoNMaH7pDZarR29+e4PykdYwRq1EflBfyhpogPvEAgjw73kauE6OTQoPH/22obr+pq0bVQXjPkcCbJtBuLyGs9dywHw3TaeQxjy4Lfx4AFnpN7oZxXHSDHTVz2/3l+M+r9tXPxGXGjqH9c5Wdbc8j7mPQXtvrjnfomuELjMJ867ZePhJCIyfm7qnPm6PMz8b6S2sgRev6alrN4NVcJY7yOboJLa3QUqcm6KVqAUutxyc1X+VFrGecQAr69YS2E2 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b8bcdac-fd0e-449c-b9b5-08dd0e53f500 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 19:53:11.3826 (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: B9mfaFQM0qSl4zzvEQKt8QzJgnl0QnM3gXA/+RBkGSzqY/1+UYvPLPbguNMXOoClFxHtPbVkVCGLq1b9xLA4oA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9831 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 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 Tue Nov 26 19:52:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13886319 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013067.outbound.protection.outlook.com [52.101.67.67]) (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 C91411DACBB; Tue, 26 Nov 2024 19:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732650803; cv=fail; b=LS4EBZ+4ClhIYvLiY+M5VZOcWKzr9rMXMdCJ5xFO1FlY4X42C3qJ/Dav/8aWN9N9d614chDuZNHuAPtv8Le6sXa9iG1B/gesGM6mrcXkJY785v7tn/8shseRUGhv8MvDzS2zvrRDsG92jw2/64LHQeLUarno1HzOrua/492Fcqs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732650803; c=relaxed/simple; bh=lOH6uKgp4qocjXTGqI2DZ7uMpsB1hN0XNn3KR3ot/D8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RWKu/MsCJa0m6Ph/O04ziju2Jcp5To0wZS1vsGpJiHHmDt0h22d5pETn9IE/0tmJnYGdUf6jl6PLIZJOt3SBUFb6TCa55h9NHS4DAvFrx9MF9w33HzTUAF4iDhNQSpR5INF0c4y4ru9weR58UXAaR+0w7c/47+w3fmNShheyFBs= 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=C58bUuF5; arc=fail smtp.client-ip=52.101.67.67 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="C58bUuF5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jbOV45b4VSq+gvTpAVmCSkD98xYX4L++fmELxg2jzgN5SHuZlQvzXt5vfHaj98m2sLQqZ9wferOp4bhGWsEP/bOdAQzxy8lRKgs5m2N82IM8k5J0Xl0+yNOz8dI22i7jxHv3LqG7uZbwsi4UnQ3Q4mSQTsaPI21WjQMimv/pUt+IcWvYn04leO8TXn7WM1OvGQGJzhMPd0Woj0Y/fmec2iLdp8ek0oreGgkyxSdTXhkCs6sOsvgzNRDwREzF7KGjBQ2vQxzJ3DZCEGQzOeVe7nlf8aVbZFcptNg3ljU7I7Rwvufwhho/dWZwynJTgMgnKyuBvNfv0dg7bYmC0gB1Kg== 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=UBQqwxMGjqwTIRtBIMH/Dslh28Cnyih9ZZXgeWnGIgQ=; b=Nk1foO4j6PCys57lj/3sm7IJhGflvuXbuPvunwBD4ID4NHUca8cpex6PYcA9Cirthm7dGslcGHPZwoJjI1jN/3YKZXxdVtDQ9YLxLwQN4v8grL/QS56Y8kUd5i+mVfjf4OlQiQTcCTtmIT8PAo9t5y6FepHPWLcbZqDl+mr1wy5Zi88KMt0JPBHoL9Y1ssQctCUuRcFbMshMXCsmmWsvDIBVPFEK+IyN7oQF7RCCYZD74zBmq337IQY1FX9ul9GD2Id6EjoxTWbcIpzn1a9/nK6EhMfSRZAtVU5t2SCDLkNQ0TbLbhMfO/KTQXS2ql2YhiuPJDdVdMjJEWVKUoGK+Q== 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=UBQqwxMGjqwTIRtBIMH/Dslh28Cnyih9ZZXgeWnGIgQ=; b=C58bUuF53saPUdyDt5+MwQVqlbOxxfN/bQfRqPRXu6q9m8dsRg2+PFWfY8HmybBijd17M78V+AK6RCMZjJ5O3lt9uyrdMcYGi7Q3PdG3bGsZROlo0TR0A3rmXMAFf4TW9MWp7hdC3WiYm5/uV1a9ukIH05rJmkJqGFs+vIxK3/uiL0+fDDllY9hQqNFK6ck1muQgIwULiMC8x47KjDkpa0mpW3N9sP/Vr2m/oMa5xyPYW2IGc/6sdOJL7Upp4aFl6HX9RNzEswhnk080ZUC5nuhLXtz+BAEdsPo0gQ86jHHxlGb+6M/qMdhpEHTBUmFYj47A6UKGALta7Gph+4/eMw== 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 GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 19:53:13 +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.8182.019; Tue, 26 Nov 2024 19:53:13 +0000 From: Frank Li To: jic23@kernel.org Cc: Frank.Li@nxp.com, haibo.chen@nxp.com, imx@lists.linux.dev, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Date: Tue, 26 Nov 2024 14:52:56 -0500 Message-Id: <20241126195256.2441622-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241126195256.2441622-1-Frank.Li@nxp.com> References: <20241126195256.2441622-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0190.namprd13.prod.outlook.com (2603:10b6:a03:2c3::15) 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_|GVXPR04MB9831:EE_ X-MS-Office365-Filtering-Correlation-Id: 8015b945-515a-4ef3-67a3-08dd0e53f665 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA: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E3qQ6vrx7ijD5KYdFgRWlO5sLjhShT9z76IKLaVIRD5o7IprBDSygqOppruNsyZpFhFs5GBBVW2YvOGpBf0IKtr/qHy/YoWiFXAZt+SM7A4pmfJMn6GXwDEYGBcDl7DsaGYVqH7jnaX1dXrOEp8/s8q2XLgJLjBK6lJYnCO6/guL9iqDX00Uaty8L6S5hchRHAhDUKBRraIp7rexNOUkzoMffADRxNr0AY66a7DiYCm4gFIrYDM2ift6avlbqyzLSwQbcVrD7BCS71AgZuIZnatJq/YTBEPHcqShGHRR6Pnu42fG2XueJ2eCj0eUxga8RibQK9a+SK9ADB+3Fjxv2/1Qs7I6vJjlqXqTVroXklXYernpFXwL4qkhJ03JRUL4f/1RWKHyCA5oFejq8gexv/zitg== 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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NiuXjXLmAIpaBHIsiH271hk1Zdf3zhMiPY+ToVafPJWg9eu1QHa3HLq8Chqln6rzgYDH+0JvZ4PZJ6LqT3vZ0tGISbXwUs38inYuB522jh3YYRF16dj9pw7G/EPoJuji1PmYf9UdbyNloZJ8aSTZ6epd9nfUbxZZsjNd2edshzZyZq1aNN9MXjWlTQaagJRlDcRyYd/FetK519StsPsem+5tdnDoVZNOCH19K1+d5ZSsOS7stwEzGm+FwCEP8u4Sp2AoVc05Ou0+j0ncBjh3FaD/VZIEUjMJzg7xYVpWmYwnn9zDWaNfWcAbEnZaPohBVIUHnhJYFYD7jKrjfOKeHopbGO8sjf4lc9IvrzXfum6K5Psupcz6Y4j8Gzjy0JZGap65wdpIpkBmcy/ZhY91xbYN1SM+YmVCCbjh/qxSA3Pv9RATEVSmCsmcUQ8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TFrG3tYF8QGsTAw8ZQVHaiH05hY/YcgED7StfCdSiwW1sSOHrVIiu86nxd+k2kdWOkUVJsM8LMT+yHcKdOW93x X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8015b945-515a-4ef3-67a3-08dd0e53f665 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 19:53:13.7056 (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: fXRCFZ2Ch/UmxKKI5zWA/K2W2vniOFWcOiS0rnjqpjHp9yE/CbjJ1PZ0R2ObFAd1teaO2Xs3uf2WAfC90IWnMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9831 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 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index fb7afa91151f2..ed05c2b3caeca 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); @@ -823,6 +836,7 @@ static void vf610_adc_action_remove(void *d) static int vf610_adc_probe(struct platform_device *pdev) { + const struct vf610_chip_info *chip_info; struct device *dev = &pdev->dev; struct vf610_adc *info; struct iio_dev *indio_dev; @@ -840,6 +854,10 @@ static int vf610_adc_probe(struct platform_device *pdev) if (IS_ERR(info->regs)) return PTR_ERR(info->regs); + chip_info = device_get_match_data(dev); + if (!chip_info) + return -EINVAL; + irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; @@ -881,7 +899,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);