From patchwork Mon Nov 4 23:11:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13862203 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2079.outbound.protection.outlook.com [40.107.105.79]) (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 168F616087B; Mon, 4 Nov 2024 23:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730761941; cv=fail; b=FzPJTQm2zDDDZvD9uzBE3XOZGXlATumh5IqVq8xpA8GzLA2Ft74ojTSy7NFj5sOj9zHo14D0k1WDMctWCwuSn4bRvFLw5+XP3tFCV7YzjqbRYGVyGZREeox68zhqyrsa3oDqncdoeZDu7OicuLW12M5uTGbDJoUC1/injD37YWA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730761941; c=relaxed/simple; bh=5++BXI8md2FKJ4/PmLSPUeTym64LQ8BHsYdHHAmH2bE=; h=From:To:Subject:Date:Message-Id:Content-Type:MIME-Version; b=CUcQcJKsJj60Dhj9ZKblKbiLZwIV7teulKo4A1w5AkVPh6fd1PvFXam0scsZvX4BNtzguMe+4NlZRQj3GhLKM6/NvlqQRUiGKnU9cUc465mE2HgTyJAjtQjK3mhd602ZZM8Tnn0r7O9c0CY0VOx+8exyikJP+03fp9suhuwaNI0= 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=Nfsk+/LQ; arc=fail smtp.client-ip=40.107.105.79 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="Nfsk+/LQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GpoM/TEvEb4ycmFi+mqmCogYy2R5VPxgYI2wi4LSPYBwBw3DXnq5baY7h5hG357TKXGA+d7KnNlAspmEAFRzVO1gk36drgdkojXem+l+pEiUxqWw9gISaCiuL600FtHrHUgl80qoSxOqzETpK/RZqNYMRSiXhYE6NKBJ1mH7FVBZi6GMnqSlzNfofcGK2hNmTJRJTMpMWUVBHPejRL0OVDqE6A6/0zbQFAW7IT055Kq2HlztjUrhAlQUZFmZ2Br7lTMe3Bx4INu/gPL1vk5t2HKlFBtZi7C4Wpuh2lPKEfDrQTigs0eWFcuba228Oc4LVVvX3ljVvrSQQadvjBoh4Q== 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=WLpbs09pRzhIJec1UWnAydZjyn5Qo0Nc8n2cBDAYUnk=; b=c4JljbJyuP6b90E3YO1saXmfPdQyKmdLG2geLurYDPefuX2q/QluQvsA0EPqO96MAcjcWynha2dVksK9awR/N3qbUCdYStrXQizmJCe4yor+Qv6rp+qprTcrxREfb7XisG7l2/cSIizie7xn7NqNxYOahzkJBBkQXIHFpxVpnRYoZG7Udh/C6r9FTRocwlN1TA6ZTE5Kxc1qjlV4kNHgpkforaw1oRnMvbWkVmtVOktk0vuxNEyGC6Q3z8iAT5lC7+W7z144gM41w4ETOCfeUjfjNb+ND2poWKLOcSYZXJX7LbEEuID0cJ84YnzXHBixaQTQHnWwfhCCokGEc1AfRA== 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=WLpbs09pRzhIJec1UWnAydZjyn5Qo0Nc8n2cBDAYUnk=; b=Nfsk+/LQD1vkVHpqXScvqVedU8Wcm74q+uT4ls4ENp74TVIyg/kok9JXQ13MUrjhkE2hCq5tMyCwXA+w7CKaoG23/IYbbN4VSOSe8H1h+R6U2xqh4tHO7iPHNKs7NpCqdnP8nJrsKBmr3rqxQ19y0oe2foQnkX/ry4v06p7mt3hE0YKqzgCymo/vkprfh8h/EHGrS8zZ4GgGci7hzAm/c10SMs8urMEw9RNd6dHokqTY1nGHHY2Zp1nFqtYofc1EPHtsaFfKJctnQ052JbSPmck5xe3WovxZ93R/VEx9Zu0smajo8MW6Bleyc50JNYTpEzDRkWodYJObsqVAVpfNYw== 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 VE1PR04MB7357.eurprd04.prod.outlook.com (2603:10a6:800:1ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Mon, 4 Nov 2024 23:12:15 +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.8114.028; Mon, 4 Nov 2024 23:12:15 +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 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Date: Mon, 4 Nov 2024 18:11:59 -0500 Message-Id: <20241104231200.2745342-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR13CA0160.namprd13.prod.outlook.com (2603:10b6:a03:2c7::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_|VE1PR04MB7357:EE_ X-MS-Office365-Filtering-Correlation-Id: 50cd41c7-28c1-4e84-fc4b-08dcfd261ef5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: KtLUIFPDiulpBfOiqq6uGoZalr3ClIiMdlB+nyXG9JQ1X7QO98L/MHMVtT5GglVj4z8T6KKKvKgO09+RYD8oA9soEnQSTgMOZJsr9geKlvN8B4bjslbtti20cYb1B0Umz1fIWGt/xYgVlg55r1pfzoetzXl23NggEzfKvx5c5kOyCjVs/HuIzEeR3ZdNeHoiVdnGmNjMSGom9EQhaeUycMo1fJUTP9H4qfpuhuNbrgXQJS2+wUr+6X995Kl9dDTKp+QbEdsW7qY1s/nktp62LxLV6PzZuAt5FLvQCoO4Gm0r2GXTFbaHvsvjTr4V0sG7X/Qd5G3g1ULo4MBSqPSbjML57S9KSwdRQJxOm3qGGCFuYHwyhNsW1FLZ/EI/4WNHdBeKpuaEK2T5BfSKaAQSKHUMu2qlriDlnhQpsO5WVZoLz7hGWaumO59Ap7UnmHXHPjwdpQC0RTVwuyJc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Qatwv6N2B98xGsAx/30eeYHGepWYRDImmtflNQvBrdvSzibpO4VkvdE4vqE4dxGjk/x2h4dpFSLU3Z55ULMqgb/K0Bfcf5Ze/xaI9sw+bzerRL5bDY3OyeIoFW0H4BbVl8MFw6FmgC80YfdCc5lyr/wwPAT9abZhhKKSVm1x82II5VJNjnlZwvDCIDSRE+XRi6ZmTefYfhKUxoi0BPFniOQSXNvNQnlSPxBDmpykaYfwr6G5APbOye4pY2CC3mQI0Xslh3gKSOkEiHPKayen7s/goFYlrRC1woWyEizUR7ZqR6PP40yEiqM3uY9/vehPqCizknHQAvMNBdnqGU/r0nmWtPM7k9SeJ/QdDWhrlPBLRSXIbRJKIZLyb0e2ZpSrqoz8+2TSD0Pj6C1+wmlcPivmm+v9P7YOg1yfCkand5Rwn9TTEgw7pZUtW7I4Anw1w8Ck+/JNAd2XjB4Hlwyj1TgfonapRnxrs6OgivoHRmPpz6iJo1Fa3DTUNGja5dAuXLuz8XzQxn+/PCXG+UoW6U0RkvjDztXUDNaHNc1GsYS/jz33pruRu39WN5vuJ0= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50cd41c7-28c1-4e84-fc4b-08dcfd261ef5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 23:12:15.1290 (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: aJ5qFzzdxb5YZELLlfYKzPIEWgi+VgLBZSFRH0ACpTV0Kudu99NhXQDXl4rDG7L8bqlmLKvOEzZM5Q0lJjjYXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7357 Use devm_* and dev_err_probe() simplify probe function and remove vf610_adc_remove(). Signed-off-by: Frank Li Reviewed-by: Haibo Chen --- drivers/iio/adc/vf610_adc.c | 77 +++++++++---------------------------- 1 file changed, 19 insertions(+), 58 deletions(-) diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 4d83c12975c53..4e737b193c012 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -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 Mon Nov 4 23:12:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13862204 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2079.outbound.protection.outlook.com [40.107.105.79]) (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 DE05A1FCC7C; Mon, 4 Nov 2024 23:12:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730761943; cv=fail; b=CuctUP3zucs8HxfSyPkc+ie8GcULDVwFAyuAzD79+znv+pN4KpaIKPBRISSUrv21LeHAQKAYIbmzJlPS54UJp+BllizmNp9mjEZTTfwQtY58DW53VX724+7ynX4ZKU+HSNfxFQRq9Hw81Xa6nSpFw1eF8InRpBEElDht7WH3M50= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730761943; c=relaxed/simple; bh=9A66vK6rBbTba+6yRSom+iwbF28M21m/zwp92UEkE/s=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=damuKDZzOGtAQ5otoBTn7dLGwRegBvHsm1fUKNkvzo4ESp+4MZUU0lxCR3BLFJTCvq7psEcUlmXoAfx47M00U1fEpKYuBCwno1UZr38J3TjwYiOAMVBvsavkGALTzVua2p/DQMdXWF8cn9Hfibpnt1VTrxaU0Nc1ziMP9FrRe8c= 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=eIgNwleS; arc=fail smtp.client-ip=40.107.105.79 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="eIgNwleS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iiJtHeE3mq/HQPqCXU1RdTSA+5hSEAy2Fv6Vb5162kkHF1bITm+WGH4uuQwm4hnbf9/2SzwN4mZn3st0CFzym7iKALIK6fJltr6OfJMH2/C8F/yOR7pzz/7bnjiOJUPa61Xc9yPKX1Uq0AJmRN8umsJV31Jr4K7Vgb+e5QMpgH+23lsoGZQu/IOi+PWDyktCpOD5yUPDNZoM3oJs1KYnrgDVtXlsHARUnJhVzlY999i5Il93oVCfv+wXYG0Q4KCtOa4gbulDX+YfxCja8GonznJTwi3Te8kRTt3wS3cfYWdPxWrCNEc1G4PdzAsXTitaXdPF749E0AVeldLNUXfE6w== 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=kGES0RxWgd/uohnuz37fTKCIsQNEhCIfA2Q62dQ3BrA=; b=zWAax7dNdCETaezxVApTomlBm5Dd9Su4e8JuMIsK2v0CtfugUvcAdJXrSEx37RcFNobI/TUNjlpWGM+Q3yH5746kp4dOuAhyu7VjqCpiWdxfrQOohkFtSubHMUY/A5+p8hjqx6euZREqc7lQYwrdNBGxLODHXJBCl/6/vzgSz6oqLGKsqWKDO2cDhSOsUkwjn6xwBwvxkcddHLTF4xj9S9HWAjArxo7V/oJdE/n0kS6LZ9/X1YJYiKEdB1kxrsZ99RR9hYa8F1qC4eP7qOS2gphVzuCpBLOAZLO/OoSLl2Rhu6lNBoaS/aqdZGg+8STlH+M5nsUDvk86sXum5fHsug== 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=kGES0RxWgd/uohnuz37fTKCIsQNEhCIfA2Q62dQ3BrA=; b=eIgNwleSh09JtxUaXJMa6ssrbi/P2JMPXg+ZUU6MApJhiA6agrahC2GKVb5nrNUqeiUWFp044OREZIPXeyQ89PiWBu1l8IFaf66KkbnliN2IVX52YKhcA0GqTVqWCRPGVYoml6ETVxsUIQnmfHhY3mBs8EQBmfF7YySleebSWxs5eEEiRrdBa7Vnc7Pbr0VbR0psgyeOqRkShsBwRSPPZgFextHGQai6hyuO4PKSIQhFTNOJd5/7d4g29/oNBHcx5p+Zfrebwp9OKCJE9Hv0oUQ5dxOJBx8eh8n8XMHqzjTaLyL/A9Z6o4U6oNLPFwslaF6U2Rf7Z2TIeFPsc1qqeQ== 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 VE1PR04MB7357.eurprd04.prod.outlook.com (2603:10a6:800:1ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Mon, 4 Nov 2024 23:12:17 +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.8114.028; Mon, 4 Nov 2024 23:12:17 +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 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Date: Mon, 4 Nov 2024 18:12:00 -0500 Message-Id: <20241104231200.2745342-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241104231200.2745342-1-Frank.Li@nxp.com> References: <20241104231200.2745342-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0160.namprd13.prod.outlook.com (2603:10b6:a03:2c7::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_|VE1PR04MB7357:EE_ X-MS-Office365-Filtering-Correlation-Id: dda33822-0030-44f2-45ca-08dcfd262056 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: sFsEF1VHOCAGF1uKM8N8ZRGoUFGQ4KPkzVAZH5Trj3l6i2Z6PBwRygmKINdboWMEkqAQjNwcQLWvp1AAIx3SsAisSO5LfWIHarRA64cx5he350zzLdXNm5MTOCjan4m7NpZi99taCn8UL5f+D69PjkjE2uyJObPG/qZhhLXFbjVm6lmNrlrB+Amd0Mu1Wtj07spUMLvJa0ab9x+Fr799HKV0PAXGutTElsv62sytTwLrKKSYHGgIglrXRU6VIt8aSapN01OeVvVEWpWaXnbobsSDeMgZRjA/jnsgtWEeJEefkRB89lbfEiDiDOxx1MKteV+z3lFPPqKDhhxxLB/6VKz9zUwOp/A/nbygOxR3xqBDYiksypR8FwUbvtbHtAicWi1diyH/5B5vg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;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(1800799024)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vlQJQ4we2l98HGI1a0luCxsjEMb9Rr90H4g2SgruoIq2BfYHadYSa5HWBHEZQUyZDEMchMSIdCShvhfQ9LIUiwC0OZXcyOkCPO5JSHohdSG9xYUlXHTev6FQSjJlZo3tqvDV3Oy/HDGKcVIA/3Fi96VNyrAlDGIQ0zpJUEDHNW4FyKvzgUoatYxX5DvJbrkfYPCKn11JWqdVGe4cxtGdF+lHS4+oDNv+iWJ7+MlZLrCeU7p3VgBozs2s7WO8WXmsJhIKqq4Xip5ZMYkrSXF8PWkHIC6qPR6CHJA5rVauJ9wJmcCvaeY2y3xqYRI7r+SMP1+u7Ze/iyMdf0pxzpVR7R190/pM99/RaDGa2LXZKYW3HSc+mReMyS1qYpIhgyWbxsgi0YfnAqoggakmw0uQSVypNBSGGEmJ03cALRX260/ubUeaK2H9AS1CJx3ljDJPIJMxSTnxbsMZv+1wjulODrvEC2LMyRkR09ghxhm7GPbf6pHYZHeda3fj9mIOOk2nzlpJA/m1xPMKHHOL2P7SgnA98pu2QTV8ibm1XKJh1XQz01W9Ez2x0KSuNLJtM1lzYrKNF2pqLTIDhQhR46OxalhBW2vMBpWtUfLb9gpG2ll3HxTs3xKh11mmSrAok1j8L6fYY4oSHLJd8G67oSXDkb03xq25c0CjdWaYsT/wrtgpkZefA6/Gk2G/8n8govG7BL088h14kpTRcWMK37XF+AUsWljiuUlDSz+W+SbEzV6MZOlN5CIGiYTfEmCahFpN2GNALX/WjgT+6qSeLvMalmOpeALnZqAU7neTdx2zkSpYnFLTfvar+YOJ31BJylHr78upWo+z3kyb6m5SDH2jePkOkJqymhTX1zoMlwuL3adtR5jxeq0d2EmCWmh5Lrmy0t6U6jKEDNWU3zjgDUk7F0zpmoqGutnXG2hwv73KP+igejDC6wc6R52hVp0qjE1CvQL7u1+eK45DoA+MQQHWkYdDfNXuitl5IFJwFNvlCS8rpVhxk2QXgU60N8L4VxBSNiuleiWj4VoT/j4qI9dkr8qOeaX5rdlCz73AfR1UHsBYbY+7tSkOqY3vS+YcN4pFaymnL+fcSrUd2BN5mNx9/q3cDZ05++vzNwPHr/KPk9wxCzoAlHQq1c3e8jGWKs5yaxOIeD2xSGu6mx7YfEVwBdEf5yafzdPQUkecgE0Tmx+Eo+WvYah55QuRWusKs3C7qSUhI8H8h1dguyv7SWzYJ2GsecaYQLzq1fyZLSCQv/DBnyJTZzltP3hSmrBqQYQozOr7BoxEKC2zDROJAXf4/SIznHP4jIJEl0272Mllu9s3uMS9UfggdXFBvm4Gx3ZBwhXxq3qUqG0loAVDkQACGKgXMEJFEeEa0VBbXWldXqzdrVtmMnqzgt5dZdrsH2dKLJWCVU7/V6jByK9ll7a7wufa3nQaRmVgmjD5oHez3vwMVpalyLLx3pLP9fKCsC9NWB4+5xvmAYPVmqbIDULP0haqggx054BHam7h+adUn6JSioTEhsdjojfRpkwzxskngGOLOGzXZes2WK4+9fafYJjbHWkJ1PlAvDQ6p9njUEk= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dda33822-0030-44f2-45ca-08dcfd262056 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 23:12:17.5842 (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: wWowfeWOM41nWI+zaOhdRY3Zs8yzUU7ntpd67/aj5y8VlzKkN9xbWa/S4ehzzh03Sz1kCN2+zlq4QxRaURBPvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7357 i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for compatible string 'fsl,imx6sx-adc'. Signed-off-by: Frank Li Reviewed-by: Haibo Chen --- compatible string 'fsl,imx6sx-adc' already document in Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml --- 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 4e737b193c012..84573cdfce5da 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 = (u32)device_get_match_data(dev); vf610_adc_cfg_init(info); vf610_adc_hw_init(info);