From patchwork Thu Nov 7 19:18:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13866977 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011019.outbound.protection.outlook.com [52.101.65.19]) (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 ACB10125D6; Thu, 7 Nov 2024 19:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731007147; cv=fail; b=OvtEbfsOX1D8kOlYaXceyYRhO0gGVZjtSS80xVrE8zKVfN6isH7o11n7ORCzvKxxtOSbQUtkPQp1gKwhx0E0hfcFweyVjA9ckY5p/bAhu44/2jeFyIqcjglh6KhSmaCF934VKIKEkyJee84l0eW2gbSRsuCwk1zi/DX7XmDaJo0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731007147; c=relaxed/simple; bh=WzwTTmhZpwi2/Zk49REqU4gHY3063pgo/Y/nMTNgnG8=; h=From:To:Subject:Date:Message-Id:Content-Type:MIME-Version; b=a/g1nHIBohK+VW4/KYTBXfSaKFIOuvsrA/OziDA5nHLQhr5wYFr3/f2igOV+EGWKh6+Bh3HRopq2B1b/34V542aDmrFm3/VL8Jj8Px+cmWu62P2snEhJyQpiQ9by538xFzddtCOZha9FFNHeDf8BwmMukTDuMP3eDrsuD8CGzls= 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=NX1zAH8Q; arc=fail smtp.client-ip=52.101.65.19 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="NX1zAH8Q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sJpiDzZDTlNZy4+EBHFWlozUgpgMC6x2ULSk0VvpkjRKgV0O5h0ZnoYj2qnH5Y+uP5HMfhhNjs5XqTkBPF0OVkD749CEF4QyNZgfJKHqe+LOWoiXBV7AU8Cx8Z72Lt6d8O+cXnzed/Sc9u5rtQvmrOZcmux6chBB34h0J87XaAj4EaXcLcBPDpIm+SE8e/7LLJz2WsEJkOYJGecBB8GPAFCrE0BZ2E6G97NHVakOn/vBnd+sLvkQ48+kHBsyEoo9Uckw+6T0QjztNDoygFk59kmeiLaVnPj2TsZJS/fs/EjJIMimalUWqNI4KjYSepxmUWnHc8Yfi+vVzyeQov7zUA== 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=1fSAYRH83AS81M2WlpU5dBTKmFwXkIfbJe1h1KHu6uk=; b=VhfHTf/uzVq5nXojiJ9NJX6BcSlH7V4/ps96/i7O3eLtpq+uw8eD2dRDYcjk2qEiqo/EOfqWkz6JRN4dlJln1i7B9SYGeWkVzAfLV5sC/19288/sfKpRiTSQCqns44BVInYk/bVbKY6Fp6vUSVXLVXeEd6Cl7c5GLwAR8MZ+re6iDNrOjddkvX1qxJsFlKJvNKL0QoJxdPUbYSrL147HLHmkbTLfdACVLUe4Xg1TlSgCK5RYAdJPkMSNXRP7KoyDJPbx14edamfKiNfZ20S994PLD3jYZTyEug+5gnOYNzO+iA4tHi/cs3eynW8FZJdpJw5IQAU6/gj4/o05aDmRIA== 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=1fSAYRH83AS81M2WlpU5dBTKmFwXkIfbJe1h1KHu6uk=; b=NX1zAH8Q8MosDg52MaNOvE0r/68ybqO6kS1HjpzKfqI3q3VzrrfGmGqMJazjPDY1qrESB5BEug7DwOMBdU5AsCOGOocl/6T1DVR08bd9pCbmSiZN2HwFjl5oCRQfBOrcEs4YNhRzl8Sfyr726X07vb7UTsxs2cMBgqBHZ35CP7eI2WKAbbOVRESy4AN/0JPDtulKKUxSHdq2/2o7HF7SxZsyZ5eHL6He7UZES4FJielmnzDzpvEGBV+MWtT/Bp8c/LBkYZ051Su37kfI7dRrYx3PC4a1NzVbQ+Eli3goIgfuu77EizdC5/pqKIJqfw0ThgDY2T5EtjrDxc5DOl9sSw== 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 AS8PR04MB8344.eurprd04.prod.outlook.com (2603:10a6:20b:3b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 19:18:56 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 19:18:56 +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 v3 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Date: Thu, 7 Nov 2024 14:18:40 -0500 Message-Id: <20241107191842.3002319-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR13CA0019.namprd13.prod.outlook.com (2603:10b6:a03:2c0::24) 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_|AS8PR04MB8344:EE_ X-MS-Office365-Filtering-Correlation-Id: 63e4d5d7-68ba-45f4-2d47-08dcff610672 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: gVzvyWZriEqAuQ4x42O9/+k8VTN7wrCWpgGQXp0Gw7r79bE9oZ7o9MXijE9Jv/h9LGsxZCC0Is5eq22ZmmhosZdiji49dDmnHECsJEeDeSNVJ7W8O3uTri9w4qtxP8A36T5U9mzF6tFVbQ0kxZyrAgbAq+mbfqZOZmnmMSuQeqSPWFObbnsfCZEb9opCgACbb0+vnswF/RXlbUqrXB6HWk+bUX2WsHbkgLJhB6JT0BYOEODRGjAU6hO1ngUK4WnwKr9pNvj67SqtteZRD5Nw+eO6hKM1JJiNJtc8ZIxvHCKgFGnh0+vxBtHTLYOGD63fzXjRV6VpzK+YF4czYZubxHK2z+zcv4qFhOI06eE/ocIQ44wqBDjobPPaQ20Tw9PgfHP8JfkXoqpuzHwL7PHt319O8a4A0z2FTtb2+o1tYNgNrSCeLZG9pn1Y12t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m39zHU8M00YYO8Gfr/uTPbx0TOc+yzeQNE3JmkXsCliPQDFWzq3TMSa2QXM7oxOrdYrMpK44Z8rZWo27SHlQ1QPUDaRBwtLSfOsu15M0g8fJckxIaqYGH/KGgPqy2JDfMBu+Z6UIKLnnzzlbo9xoF/ui85Y/pqSfhjtnzes8vKb/JskGMrK9nuvEt159g4OTYr0rL6bpBrlYIadYC8SJ0v7oBYKhPvrxhpUWehPcazW7xZX2ZPBp4gCGnUFJvoZbUrZftsK210bCWkoUnQkTVNbM2lOHbm/7WyHkNDvXsBRuHQSN9DsWrJFUnW0OMIj/I7e3Waq98Z9ZuVqtjLPndaqqiROBBhNeQE/rhlXTnz9Ydf2zBqn5/hJX8UhFfcLPYGE9H3czSluKeKYdUYmVkp9N96aN5oH2ED+TS3Hom+T45UsIr1+kuZH+529T7yJzkgxfJ+pQwY5Pj+gg3uNvq4btse84IIgp/kvhDS6zf1mWBxwiD3R/UA2miWHkqiS1mg9b9rSPoGqBWw9aIPnKTzoEmxNlagLclYNPLoP6xbV4mCvzrGCPbPSY4yDk+bW6AUvjzMreWbYna7teuT+PmQvNMvNPr/41iuAWmjMaGXTdYIFOh7vO+4d9wxbRpLB0z5yVMz4a X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63e4d5d7-68ba-45f4-2d47-08dcff610672 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 19:18:56.7128 (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: Ox3dDZCqCw8KtaNc7TOJLdKFxQ1Ye5vJXJel91Ln4jwjGUCVEyDsZrhF/mJxvqIHCc1/CNZmCxVjGfvQeWTTWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8344 Use devm_* and dev_err_probe() simplify probe function and remove vf610_adc_remove(). Change type of 'vref_uv' to int because regulator_get_voltage() return type is int. Reviewed-by: Haibo Chen Signed-off-by: Frank Li --- 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 | 79 ++++++++++--------------------------- 1 file changed, 20 insertions(+), 59 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 4d83c12975c53..a6a0ada8a102f 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -160,7 +160,7 @@ struct vf610_adc { /* lock to protect against multiple access to the device */ struct mutex lock; - u32 vref_uv; + int vref_uv; u32 value; struct regulator *vref; @@ -823,10 +823,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,27 +840,22 @@ 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) + 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, err = %ld\n", + PTR_ERR(info->clk)); info->vref = devm_regulator_get(&pdev->dev, "vref"); if (IS_ERR(info->vref)) return PTR_ERR(info->vref); - ret = regulator_enable(info->vref); - if (ret) - return ret; - - info->vref_uv = regulator_get_voltage(info->vref); + info->vref_uv = devm_regulator_get_enable_read_voltage(&pdev->dev, "vref"); + if (info->vref_uv < 0) + return info->vref_uv; device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3); @@ -879,52 +872,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 +934,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 Thu Nov 7 19:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13866978 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011019.outbound.protection.outlook.com [52.101.65.19]) (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 5B3CD194C92; Thu, 7 Nov 2024 19:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731007149; cv=fail; b=IR56F7FaEsaUUqCC2wJZ8oY3yOMWXlLBMAgPkC4MxhnTlBHStaTsuN47Qa6yaOXbyoBzugTX/VwsLvm95X8t+XoIskg6k9gNPfa9XPmoje7F+q93pHG1vngAYbWv9qDEyhFlOIAZPmj1Oz41i6l4wX1jIVQExoRCVeilfAYTiUA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731007149; c=relaxed/simple; bh=dTYBp5yNo90AIFbbUBF2OWCu4o1mYpD7xLPWFMAw8kk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Nq2pQ9Xw/Fm4jMooJh8T89j7qpxrQ2xB7ddU+UOIJELvsFhLvu+GxoQcPQQp1Z/g2xW3IVUiwRknIHSUQW4awAMFGxDSm6/sc9fDpVFjAZ8wXUzqTY+P2BVePkc8hHyMdeQ84iYeZsSEjesX+ezpAb/YSgNy4ixagokYe1yP0iE= 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=AtVWRKv5; arc=fail smtp.client-ip=52.101.65.19 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="AtVWRKv5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D4v+QpbhSstc+ZV3Np2/mPSWVx5GZc9BbCUSSvqN5+p5YmMSYBDNFiF7UpvBpZgXx+/hSAsd5LCSwPT0SQaf4lc/vSkhMqbFljFTquiL+BIK0NT2L4XQKRvr8ChBmdMmoI/OCh/GLhUuNvtQSO8NJ82XkHYt4yLOkE2pEBzbPjYGy9IBEDqFOdW8FH16nGann0QQQvUJ/zK2NwGvuKq/TZAhXQL0NHTp+JEyxJLgf/4JES1F2t7kOqP+o9ARiENOujO6kmwvNxu69JupjYghRuJ1OWeL/BEHGvlm+WCGvdPnpB2zo0fWddiHGy9ePy3Cvsfy0RdEUvsF74yCT4zGRw== 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=81gwbHlwd9a4GbiegJJ2Fg++MYkxPOY4fp/jDl9T7lY=; b=Dfe3ImJ5HmwYfgX0AYt/u2Iw/syoGDkvhh7M5JHlctpciGGTAjRlhjLXcMlStPz7qalNMk9qLe7jktNciGICkmGUASWP187fuuoluP1qwfIPgkiu2xkwPLcDh3/hoLlCFLqvmRtx2PK07TscqlVYF72dy9KtnumrHGdMhS7lH8RUUf5xwMz7Lox7y/Edzl0cSRYYh3ZczN/oY54dQveHCUf/aDB8vVD8si6l0lAQKJ/j62DqAuCWrlS+7hdK89a85yb3bz5RxkRpRy6O2tXz+qTonVHcd+ags2GvjfENfKQeipiuSbA3TzoeKRudbxOS4IV00OSB7fbuzEBC0kne4w== 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=81gwbHlwd9a4GbiegJJ2Fg++MYkxPOY4fp/jDl9T7lY=; b=AtVWRKv5ZSz1Dzi1zHtb1sw2Bo+2BG+HQBwVD+BmJIroN8jy1yUK55oU053tSEUei5QJYrdINfPx3jeJkIK22+SrDCONIoUPBKL0wIjN80CePf7FXhbYzMdTeoaI4UVt96v9JJ4mrXPcTIkUsVB5nFVs8blmDhaFsB+o1E6zP8hmlm78NCE8l2AOqfUasdkc8m5W56et0APxOgiuBdBEMpLU6F1aA1jMAqjUsHJC7OADYFHxr1DpiFzCOQVChneS9EkEDGgMqrg1dNCvj+WsbaWIcZStKRheqTHwg+2OJljCIg587GCl3oPaKKXa4rfALty0bzJ4Tmt49PVB5KvYrg== 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 AS8PR04MB8344.eurprd04.prod.outlook.com (2603:10a6:20b:3b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 19:19:01 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 19:18:59 +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 v3 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Date: Thu, 7 Nov 2024 14:18:41 -0500 Message-Id: <20241107191842.3002319-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107191842.3002319-1-Frank.Li@nxp.com> References: <20241107191842.3002319-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0019.namprd13.prod.outlook.com (2603:10b6:a03:2c0::24) 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_|AS8PR04MB8344:EE_ X-MS-Office365-Filtering-Correlation-Id: fe8bb39e-f5cb-41a3-7380-08dcff6107dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040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pv43wSWHaAiSu6puAzrNFgxGgx/CBastcx2xK+8dWoMwzR+N8a4N8nBeuK3Mr9UFEqIN3o+OxDVCKY9btW9CHi0NsG0f9ecQMeZDYAogDA35i7h09SvC5Fo+1OUh/7EegMh6V44ZO+D8zd3mIJQ9gKRxrCtxZfJTxLDPwaZGXemDio2Jh5whaIWbY2Vi++DPqmp68qiYbjqi8BkaKRTd5wT0koNwgyS3KWpuIq3v0kF6Noj0O5+uZizVzng5KO69cS2dZ/SIkhmC4UD9BJi/qQzh/c5wpxULO/ALtdIElqmn9AWdfUp17Gy1WaU8LaEf5ZIqkn1lHvJnef+5GhGpkCMOT9eFz32S/zd4GrrURJu3DJeAj9fVaOV62fHFj6ReOR 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)(1800799024)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6Qe8Ej6gvf5v6hWJJRmA2pxvf0wu3Vt5FAg/n7fjZwzBnPa/UjNdmll0XJMMKqWAeKQY5M0CwAJwct7r3EevrvH3PthFwvEAqj85YK33NS5ye0XcyL8+oMnrgXNIhu5EwhS4jASoPDVON2fkVJMY0b5L84NLWqnpLAuNLEMolIx68cZX0eEWwdIiV8LRtbt32nXSCXDSA5ZRLGs5/+0pnNtwdrWZ/5O8F23hN1B+5dQyJ8YZ7M1acA/91VPf4aSx0zfPM4Zv7Co9lq4pdxlC8BwE4grfbZR1vsCiD3AcFSZ/BHs7+AoWHuXvmWI2qQWk+WyX9upSb3xHZj6qCmNPd3lJv0tvgol7KIAwHdXsGpo3A8nZLVNPPL8mfiY7oTb7OHEvgLIOYwUC4PRCT1NedFswDv9wQcYNCJcWNd05JrqAQRznXd9x8NU+JLsBloDWCwaAByORs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a9lHLQhr63ucjjrLOcRHOIyJDFWv/AIJuWvYeeRDUdT/hNuha8rFo+LaxsSOTVC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe8bb39e-f5cb-41a3-7380-08dcff6107dc X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 19:18:59.0456 (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: aPVfPlZI31Fkrg2fpkNoJ9Amge5Y1rjcP9TW1B45tUPCn+eFgEd3UI7sg/LKUGgso9ioWHzuzrjuHvnTTuVSaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8344 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 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index a6a0ada8a102f..36f6132bf5ba4 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -809,7 +809,8 @@ static const struct iio_info vf610_adc_iio_info = { }; static const struct of_device_id vf610_adc_match[] = { - { .compatible = "fsl,vf610-adc", }, + { .compatible = "fsl,imx6sx-adc", .data = (void *)4}, + { .compatible = "fsl,vf610-adc", .data = (void *)ARRAY_SIZE(vf610_adc_iio_channels)}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, vf610_adc_match); @@ -870,7 +871,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 = (uintptr_t)device_get_match_data(dev); vf610_adc_cfg_init(info); vf610_adc_hw_init(info);