From patchwork Tue Nov 5 16:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13863178 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2057.outbound.protection.outlook.com [40.107.241.57]) (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 A131C13E04B for ; Tue, 5 Nov 2024 16:08:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730822925; cv=fail; b=W98RefORAhWEO33BnnFotuZwvk122l3uwVD6w/j1cNWkGCoHjzV5/UH99w0im/assn6d4rRQTMBtk80g3QOiQz3s2X4rsXoe7P60TBLDMI6tNuBxuncwWFBq3+ZtZqXwWTyNM0V9NLDSfsK0zoECysHZbDlS5FRrJpHiTsumPG8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730822925; c=relaxed/simple; bh=TUnlzLcF3+E0x5Mlv1/DCEfdNYA/D2t/mCPILwul+3Y=; h=From:To:Subject:Date:Message-Id:Content-Type:MIME-Version; b=exAg83ZQC38Z3BxlW1dC4nn02eUKvYNA45DGgMds8HrBeSLJDiMkEAE0L++lJKeQYcsFxX5nboOfMzotBVQCAgcAWVBJTk6dGcxiAGoMmVr9txHE+dc/wWrco/G2bwznaq42K4N9va94m2MCglWLR9ubqfde1V6ggM1+ItCf1is= 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=HNR3RftU; arc=fail smtp.client-ip=40.107.241.57 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="HNR3RftU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DdxVO3P7b4Bl82oXbJovhQEd8gcB1JrP+8+bDPxcvuUIRhWUDxOPAkfu421vnZAgkorJFeHf5cW2y0HY9PoFiF8QFyKmqnfgt7CMwz+G4i24oTeFLERid4pIrVAsgFE416PPjpvIASRuNhFmwFonxlC91M8gaUJE9+sz/cM9yDIRl9VhMYXvT2B+G4bmPiItMfAPGb2V5K/vGPcNdyGcxwG+D8RUR/H2ixg424kAQg2Jkqz1FSmF7JhV7oPYCPt5G/zVqmQZFXwH7FMfIkrugQ+bjJf2Egp9mQMT+QQiP0wDCbmRpPysf+gWv5kRcAIXGm4qxgrhiZxBiEgu3CxK3w== 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=14ldxjT79Z9TNU3HWaDozpz+gayBH2SKctJI+DuiX1Q=; b=SP/hrPEoOOmBL+r7HJILMKcacBwXgLT3vbe8tRl5p6/r9J/0+UDWh4GrDEtGiCtQPF7o5yr5u4bNmhISjwsvvsvTIJt2V4cvf0GbaID7tKbq4zIxkJTEV+fOrlJNcPkinlps4kzRVgHVhEefC85C2my5STL74Sy9Dqed7nQeSNZzlbxkY669Vg97I5Bts/gf8S9gczhrkZE7BSNv8pfs4Znuh6ubbGJEtERAhlaiMMt/dis6X3aeMC5gdplIchYfbOVrSQTGNYL7okv8wqxOG3sHtyqIo1Pzs+DS7kBA3Zu6dyLvVBGNYe/tri7p99/sLcjQt1ZYjMck4tpaWWGs2Q== 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=14ldxjT79Z9TNU3HWaDozpz+gayBH2SKctJI+DuiX1Q=; b=HNR3RftUc23UDQvQCn7s/+QijwxDYoJZjX+s/8NBdbVvVKXhnwYKzwx9efjpmq4l8IO9FeTqpKwql0Fw8AUnRVTL/X8qMNCA0taOQ45wBLa79GWLwotjSpy0xw7UKRV/IYwSiLNSlRiitcrE3xUvav+S9BPlRQcOA9/KK1XSDg3JwCSae4woIL6a2jsx6+qc72FL9/kGWOqmgxHw2U2fU7i2thDbsLfaIl49UOVo3MVfM0I1yek2gNiS/kSXprZIeqfAd3dira+QUhZqprSHJAvkVCx6J6bsi/jJzzNHx+V9OAGiDMRGNt2wLLSYRun6zRP+nqSwFo3CAGgu+1diNQ== 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 DU2PR04MB8501.eurprd04.prod.outlook.com (2603:10a6:10:2d0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 16:08:38 +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; Tue, 5 Nov 2024 16:08:38 +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 v2 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Date: Tue, 5 Nov 2024 11:08:21 -0500 Message-Id: <20241105160822.2761261-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR02CA0025.namprd02.prod.outlook.com (2603:10b6:a02:ee::38) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB8501:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b5bbc5b-e98b-4526-dda7-08dcfdb41bd5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: Tdch5rM3qNVGX9wXfvNU1S4rj5L2OKPuSDPasiqaDWOj9KkSNpHGyJDwXm0IeYurvFIezJxV30W+Rqd6cM1uQ0kD9iPNDooGc4ZUS/kTrc93qaQ1f3lfvIznNjHC8onCM+oDuyPHqPhATRiEM0acPUA4Iol8bTvJAJqipeMIDOuMBI0euj2HeniacYCk7RmOIWLS8DXSmZ2xUwWwlU72cS0aUI1vD8v7f+BU8titI9/TK4tSVXjbrLame1W4o6MuHZLgcPNo8xxV1GXS3xOyldcGYkE03gZN5JE7YlVIVpU6hfLHRSIfaWuUyofEg1IDJ3peZyUXCww2JQGKj13GXWMFBdtRFIkJ9/TdpWZXpkg6pd6/y6MelwH8svoq/Chz2BWR+0P4/xsaciffeNFwwvM6CR2atSVjPTV1ZknYGEhs6MIUkdS53Z/h9kv7hBEk6j8ecvJhZZ39pPDWH2HMHVfISChPbkENOUzotHR16XOUzHayEnRfnqkmY2G2ROR0bkAP32qVLVpF/57xwH4V40AyviFHHowyu0nj1aBVAfjzKOXfvQt7d0tJbt9CSnbw42s1/4Hj+ffl0rAYfvbsiJPhoOdRuzvyV1D270cY+k2Y5X20Wm0eVMmx1Sb1vfcPz/YI6+W25eMziMkKFxw5wcrYn9ILxa4kPybtFnXww2HPQmRpnMXNrthbGbqF4DqQiBgcNkLMUqtI6vKQHZe/mpSrJUUSpuHz0nMdfi/5NB5aKCVFdbrJl67/UkYq8nAs9pe3mWh04b4jUQFgFpv4qzlCJON2jy2O7cfoqQ/O2ljZANAARht+WjiuZsLfhPqFlid7nQIXIPZ44gIq/cFR1Dm/8il+yMTjausMAd4qoW8xXw1aECw3EouFZt7zGAnoBFZkoPlCIJVqMSrwStaumaS5mO4moFovb061osw+Y9UdYMCG3kcND2UmyzcyEuATjBr9dySGPLxDmhgM5sDRHq6xmk8K0clX+QLK6oJMyZpEV6B6zCmb5oeXpBJLGVbUxfEx77mqUmA5/niYGUmHoBZShnbNR6NQZ/XIsQLxLleTpc2QV21X+xw/UkMBc3mvLbRcHZRCBgm+cRZFOy+VwIRysZcldj8RhphqFGc9CoafUNodFg69hA0HTMN3IKU6pj9Gj3j1UsIezLkG7tWBd3b5JayKSDHzP2HqqmS1r49Wjpo1q8vpO+oAly8linNwLy6O3AfyAw15D7R7HFAFJhdS1rANNfgKmtIScxcTLAV5r97her0OgZFGetEqdUqt4t0q8q8AxaYZqrv14VieXVVvHAYUsByTgP/g56u3VtLNZ+M9/TPUczsTn3oi3hGk/eNa8NIDocL/kCuc3zbx/p5YtNjjTV7REmrMmofGiss= 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)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiS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xUmNJsgGXZOYFki8HgLaqZgkhnxniQp+5LqCtDC+fZu/Im8ooXbuUXTJ3D+fPaUGdU8ZeoDhqMAbhHfL3tGk/qiR1wFnM30tabFg6cmbu0uyYy/i0Ibpl+UrXrog5tygIxVY0c8yvhEpSqwZyGZ2tTjFEIcfg8biS9f5aWphwzfSyidNaDwPTQTCvQ4A3zPj2Vva/CBQHNO1JYJXJYLsPCbEpE5tD7TZbFZqTO3avFPQIJf5/lE9B0FwgKYIp94BaEFFJDJHkJ9WCivAlhkEzFuGflTl8K/JxtEGPytx1wqklGkwIkExgTVxeVU/AxRclFCq8qP5aLlo3jxKTNmHv4HYHW2rsx1q9xZ71YgV6YETt+auwItIMH1PCRfBsJpa3dNBYAUExVtYeC2EpB7Pc1zSi0+v4OzNXkqyTb7ny35zuPRK4jlIVMp7SO1zwfTDskv6sZuPfqih+NiFhBU9t9QntXGu5aR4ZokOLTlZ2NaZtHrlaTWTmN5R7Da2Zv+AsLL5vlrcdcSnkIKl0c/KBGiqwNXK3/k94shpRZ+DLSeNAy3mw5tzCxh4Fhlo X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b5bbc5b-e98b-4526-dda7-08dcfdb41bd5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 16:08:38.4687 (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: B/U1gZMKjRB5Tc3h4hwp/xE2uKDndHGW11mX17v39IKkWUfnPFSWJ4rC80iZ/dfcP0B7w+J91/6UB626vU6AZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8501 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 v1 to v2 - add Haibo's review tag --- 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 Tue Nov 5 16:08:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13863179 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2086.outbound.protection.outlook.com [40.107.241.86]) (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 2AB7E225D7 for ; Tue, 5 Nov 2024 16:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730822926; cv=fail; b=Qgz7ORec2rAgJehqB7jHgtTYjdvN6s23gIHRMP2SF0wA7kJ6yTbaYh6unEHnVwZXinMABq8L6wHQm7TS2nEx6XCbc+4QCuRZXPy9nNVqhVweeeUlgUjnKFOsUiq9A4ctr6egvFqN6o3ML+pn/aPSTH+nnSW7bTCzB56r045vHb0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730822926; c=relaxed/simple; bh=qFtJfP6a/se9EE+ETvxBNryfW7htF9Q+VQ14nX1Dgr4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NP0ZHP01mT6fkQ18neimP2vATQEBTMFIJpgoqEBZiWyWhgpJnZrtEam0jEgOlhs51VfZZki3zYBfGk92O2Rj/hIpvLLKH645JjtN/ekec1WePjUI3lhZOWQz+tyNZLaYTYq4Z79/g8EO8We0eK2gCG1CUY5IXlK5/TPcmt8WCuU= 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=I43rbfkx; arc=fail smtp.client-ip=40.107.241.86 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="I43rbfkx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f4U4GN4PB0PS7sotse5K0ZWaCdOn8Pghw03ieUgzmQsc6cENgrSZ/PWeJ2aNLrFYDoWtdxRW1z6Wh+iC6cNg02wzKVWWPlWeOYcftt8aQ02FidNZSGKfZDZ/PPrOGleXfv/JZCA6a/Nj+ovk/zzeQuHpV4nx9+M3Yi69CI1cc101DEbb/eU4aPHIRULCWRq7SeMsdjJA+HzP0nSv4DOqBbR5JfnTsXjnLFuTNqcX2H5r729l8m9c5NvzlVufanHTa0Bb0AOTZY7ueLZtA2kaPm2Lm3E8FlQsHSOZzivFDrCi0wXfE388rQNsZLvNMKP/fMXr28ypLMyqelh9AVEsFg== 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=1LfPY5OmZyA1fsxkEDnh7rLCuAzi3d70xUbAghqSQ+Q=; b=WlgRNSafRM3vssAlUQknxQTZ76vc8BL2XYEhXB/Ehzjhl9I9kVPUFMEjsHABvIzTolhdldm9vOlAv5g8wNWK5oszC3FAkcgeRU2zjOetQvAcAtws76aZw4HYShJJGPRh6hxtHDFDKIzSV7f/p1ZQNbGNOMGvzpmN16gQzvxXNm6pdWL/bEL2scg6WjDrRSJ2grPXx2/WhLO/u49g+U0qOP88T4EEt4z+10c4Mzm/1WIw8TPE15kwOfgs0qSozxUZrjP5RKiPkIDO+wWBPwkw7flqplJvrMrQB29As2MJLpnIyDcjqdjuD32xfHUNn2j8FPRJONMWcWCc+2mPOprVYw== 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=1LfPY5OmZyA1fsxkEDnh7rLCuAzi3d70xUbAghqSQ+Q=; b=I43rbfkxkTbhqi0AoRj/HUSqtV3lDAH0fakf2c3LkC2FWWOkNH4Lg+7W+iHfLE2XPHfR8pEdAWKDnxSIoebFJLW0aTUDn0f0tZBRQygyVco6ubP5Nov6IUDW17y+rQSDXr1xVq+E+GvNCo5Z5ryTWjVhqYdJiK3o7w8wn7QgDjsIbhQyl5m++kiOOX2QqRSFmMvYHTTEnEEiOerLaK9ygcH5/3wUGKf49tiXJ674b5Sl6CalLYQIEzFS40uMBmxBxedjs/mmTmw8DUbzoUmhK7w8c9iQy5foe0anGIffeKeIK8Bk8fmi58JTY3tbfFtmZ5G02X1YexKn45IaMekTKQ== 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 AM9PR04MB8225.eurprd04.prod.outlook.com (2603:10a6:20b:3e7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 16:08:40 +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; Tue, 5 Nov 2024 16:08:40 +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 v2 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Date: Tue, 5 Nov 2024 11:08:22 -0500 Message-Id: <20241105160822.2761261-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105160822.2761261-1-Frank.Li@nxp.com> References: <20241105160822.2761261-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR02CA0025.namprd02.prod.outlook.com (2603:10b6:a02:ee::38) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8225:EE_ X-MS-Office365-Filtering-Correlation-Id: 02ed05ec-55f4-4d23-5947-08dcfdb41d3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 4QTDk3jYQUt39FSSMcuh1ng4JFoU45rZPKkBIx4LtgLTpW3dqNvMHLr+O2RiSie+FRcuxmMtDkrsj6KB6gPMDx6WgCSdmJcFZkPLyg9r0Zk07tL52zZ8BdXqYISc+Hu3OIMqTsR5hAbfbDyiLn/SsHSaDcDPtsLcoyOYlcFohN/yAwOOaZpUYWE0dKPiE3pY4uvYjmMbJuREwBS21bdI6j80K33+ny90NdqAOVYhzDI4bTlfYq/B2/4zSFGrujrd97sonBYSx0KGfIot2I/8iN+tqc0eN+IrjCvj+jK3bu4oLl7yN3R7hk/XO3j86pMhxOAEy4Ismf+j8+PQr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-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)(366016)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iSq/RdeZ6rpizFBW5N1/GlSzKYp+uGLnNHxFJoX9dNxuJaDw1k8t3ualH2h7qYoBZdHvsgpLt+aHCzHp+y/MYye1pVthnWqmmcwKDRzRYSwhjFyJlbYhPBwYLs8kxdkasfsNADTN6cbvt6OxouH3Hq2BNvreKn/aL5bmdJFuJOcAAE1L5TRGFJqSIApOhO/jSx/FMmL/AYXIcob4eWNu1fgdD71aIpqVQhqhmvUpuanhOmGbv0PRhD26IrH1r/J6DmXUEWq9rTVg8dBrabMQhvfXAQWKaN0ONNc9yVnTbrcGoXmpTUOPA2f7Vo0C0LMexeu5jzskOwsDKnKctW5FFpnRQjUBgOzLK2xM/6soEiRyl93quiwghHnuPEcAhIQEt+jEZiUMviAUBRCv4dVEgwO38T/qchzXNZEzbdsTX3qvwtqPECr6wzyMZWCrJ0ccp1r9ukDnwwG3eUJTjPnVtp3G39zwD9E8TZIj5ZO02JHpaRGtXTOwNYP10TcFPAKh8tNZX1K0w2lGuSV79ZgbtzNSPyMxS59D+BtP8kDPQSBOtdX42iPZRZ+/PuVPRu+/rl8iuQu5VPwWBiFzzxuq3Xl1vpC0xQ2tHdVj1CW6uwO2Oc9bLB6L/hfQ7D1i49UpkUTpmJLDvMl1W9L3AkSzaJZ/t/hDdm6CwOh2UWnr2sUYX1NaInyZqGZ4VkjfyISF7g+0z1269VZkR+0W7QKJBEfWxg7mek1H7JEPL/y+ADDyOYxefIDOTiSLlL33v1aZfF9zxWd6vSFaNAVX2/JW5FlhvCasoxD8lEz2xPgzWU8cvCLXj6m2K/lbTDujKGjlPssFXBRK78Y7hwuKDRVgPa//bu5ylScASAhRkW8K4Y0vZd5553OimDFM/k53PRFhV7GXXTGPV9x9/MkGtXeGJQvtpabds2aE3hxGimPQU12ljXt5TNvCK5fGoq2YpmLvnmyQ/8c3hKPvevDEE/3K7CaocJYA6B9cbocg14Ittd6dMNZ5TUdrgQkci0/WegkIiIZr+FIS8CdC4JxRaT4LAOTIM/ddhqipNjFhA1Evdzed3rvAuMR3bL9pXSQP5ukCdUCAyAie8mBVYLIWNly70BnBL3DtNjtdmqe8dbrZBby9Q44ORcEqAyPQDrDn0su5AR4T+rL7sl4U6XvEtBYh/gd2gFwed9uTgq24zEdfYvutOR7DcYMD66TMcTiLkGItIqt7y0xkEivXcPM6fmMJngkE2GgA3p6zq1oWBNl2+J17l+8ETw9tXGk7K03oWgZZEl4fQ+m/zpIzHb6u6VAC+HnMQbgyJs1N93mvy1aDzqS+Dr8fcBqLNO9TxIzQNYkd/kbYQ0MtXncD8RkWPHTpG7QG1wzZTZibYcZctsP0i49om08QGvbIXWAU0EDP5fdkNrtTUGQfFnblGh5w80VKlqcqzRzPmhm1Y1rCTnBicDIWfKm2M7CN6+uiFEhbL9tUs0D371cyDk0efoGzk7Ld7r48ZMbwf3d1Vd7cH7ee38Q907ziTrpUA0n2mQTrQlTRmez1W6Kzad1C0wCwtOSYlz8CcGkiZ9vcixygyW2lrQLf7O8EF10BXbS5rjWPUlVE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02ed05ec-55f4-4d23-5947-08dcfdb41d3e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 16:08:40.8302 (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: A1o+ijX7vvmmKw/jdif4KkRKWg2f5KsRSylp6ljz2aZJyqLuMi6gkQJh2i2ZW/jsMw16/rAz+TyBabooHPyVkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8225 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 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 4e737b193c012..b2e83da637ff0 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);