From patchwork Tue Nov 12 16:51: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: 13872533 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011013.outbound.protection.outlook.com [52.101.70.13]) (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 8CED5208224; Tue, 12 Nov 2024 16:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731430349; cv=fail; b=tUOILClzfhFlGJ2yDP5Qoyf4gjF0FNnmYw3ut3XY0P/R73oXcY5rXF8NrttN+AZWQlUtIvvuLeneBfZbQnDYk768Rk+b4qlNtGC2TA8ut5HnYZRbh8S4yn8fUVmKGi48nIF3NvLkb375j6RK4BJv0nzsV1NDMBNd5/fAdvs7Qas= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731430349; c=relaxed/simple; bh=pHdcouA8YK+jThZXHKLq4J7wOSdvJ4TG+3dUQln/lGc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=gXxwHq3Y+qgiOB1N3gmhxI+q51wHl+BBzstEv+P/9d4MFTCZ7qjAgoKZeXW7dz4UbC7RhqTwUkHvhL+wnAwTYdQC93UzIPoZ/jC9rK675AcfFFlzmOrVxSlziu/x+BeWym/ZL7p5VCbclMKZShb2lglZrStmxIFWL9jMuuKnrI0= 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=kgA8mlbp; arc=fail smtp.client-ip=52.101.70.13 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="kgA8mlbp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hxXQMxT7s5oPgrhSPWogO9vzXEbQD9bw/lacePggg1WK2PXyHLJBuNy8JOsIz2vh55Itth2aiszF1t7ie3RM3H7z33TSxNjI/0Xug67k+zKXK+TnzMhYEmpRN9v1rUtIJBgEB6dY4eMSa+woMEgNTAeAZijyHS6vTvtLPnNyo74zPnnqM1DxII4dz/z/yKxRSC8psI16aLi+2eb1e5uIOcJB5U7+y14FuQtKoKLHSC7nfL5jLUdCv9amqs9zlIlzciilbrZB9xcmISOwCLSfKtdDYo5FNN7C3E93ringum2d/HGAIhE284JKjNrVftPCOa7qN87pqyS+XM94xHhieA== 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=RTxUcGEWHvp7e9+sBMtLPKUzbzbsN2et/K/W1RTGWtc=; b=cPi5iVjeG8MSjljjHkdiK22vAnLi/LAx53ZZ1IaMETMxeOLE0qb+cVKSEnOQzmfMJF+3MWIAey8skNos13K29FRXjeuyCnwuUmdXS3EjtiU2N12xyx7OYaxHlqtSOknkJ7k9x/yUN84I4Q0r1bdIqvMoMlaSDR4i+cDMouLLi+FpeCTWw6XqTdb7S5tOdj+ycUd9wCwXaao/Va3YTxtzFos8dr8rXQR7n7mlCkcEZLDpU482zYdvoIIocAWYnhkQkfb4FaxUiJVuHWVytDDtgbCbJWZKARg8b1AYL70ILVk69+3tS6Bta96XUq2xl3AZfGgapqBJEFj/kZCypxMR/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=RTxUcGEWHvp7e9+sBMtLPKUzbzbsN2et/K/W1RTGWtc=; b=kgA8mlbpCqF1UyV3SC9YYQCp1w32xN6QpVl6kl8NAPvYuMryiGT+Kf0R0FmWSrxpgy1FA4mod5X8gCMAe/xMwjEQ6EjZsJPwGNsSObs1hnBi8vO5S61S6/0KT684r9a3a0y31Aee8Zr+RFCqTr2ou5mWG9Gws0SSwQtcaRUd+TP4gT+qNcfmI5acojHt7doGqqXHeweR43a3AMr0jc7YWI+KZeKx+7CPyLoYF3YB4VsA7s/FIAmhPkhW90L6OvnwYaCFdK25r12a+Hat2P3cU2yVOvMYN/YhNm0fNzQBzgZ4jO1I4XyI/sfTU5TQPDhtSzCxwXH7IeT4xTM8Oebsng== 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 DU0PR04MB9562.eurprd04.prod.outlook.com (2603:10a6:10:321::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Tue, 12 Nov 2024 16:52:23 +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.027; Tue, 12 Nov 2024 16:52:23 +0000 From: Frank Li Date: Tue, 12 Nov 2024 11:51:59 -0500 Subject: [PATCH v4 1/3] hwmon: tmp108: Add helper function tmp108_common_probe() to prepare I3C support Message-Id: <20241112-p3t1085-v4-1-a1334314b1e6@nxp.com> References: <20241112-p3t1085-v4-0-a1334314b1e6@nxp.com> In-Reply-To: <20241112-p3t1085-v4-0-a1334314b1e6@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jean Delvare , Guenter Roeck Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski , linux-hwmon@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1731430334; l=2743; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pHdcouA8YK+jThZXHKLq4J7wOSdvJ4TG+3dUQln/lGc=; b=GFJW+KjOb1j/+ltPPomYrHhu6LX5ffVbhLVaAmVEsdL4tbyj6INmTjSJqfRN1QYkLoDrwEJNC XF/2EGOIqMfCt7rKh6h/Pzv7ie9odDH1JOjw816ELdoW+gVYDKXguT2 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR07CA0066.namprd07.prod.outlook.com (2603:10b6:a03:60::43) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU0PR04MB9562:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ca5d2d9-f579-4ef0-37a0-08dd033a6156 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?u6kcYnNF/SZzE3Fh8DPAWuUGj/3Da9B?= =?utf-8?q?m6rCtBuPxRRmC1ou4yGYHQ8TeqWMf2E6jr0Gt9nksu93vmAE4uVxkArAzztVbLI3u?= =?utf-8?q?7ffxIKpEDttoI3/HkmdYLCpk9CYyPy7UCYmt6wcS9gl4KiUWz8MUYPAiBA9GsI9VD?= =?utf-8?q?tLhxGlqkK71TqcO7xyJgNmbpGNLgbKfRMfDuTWrbNixLKuWDoU1CvhOw3p9/yts2g?= =?utf-8?q?qylGdb3ihSoq15jGhThQnpOjZdkD4dAlZFOHKC0LtuG13ydjeeqGhE68VHPY4bF5Z?= =?utf-8?q?4tTQKKLuHiZcTISA0tYrB3ShHfhHE98UoNi/qm+VeFMfzanMzfuSBwey6R5WL/Hjo?= =?utf-8?q?/m9uFw3GqXTukdMXOjCW2TGDK1Nz9XWQyewjrFY/a4rXuTkl6/jw0a2zVbez+re/o?= =?utf-8?q?5oDSbAES4FBpON6ibXCNDANLNSekoZPigQ9W13U1H1cBRHXaEL1GAj5WhLTl8kFzi?= =?utf-8?q?H/YxdK6XttjsBOevBXOqOqZlG2hn4ycLF++G1ZtK1+flz9o+2t/GG61mFEPO2gzwe?= =?utf-8?q?daJ0pCVpdCQwhsSIpIjk4mwALk/tSbUYxN69A7Q2zia099jBxbi/seoqwdeqf/Hkk?= =?utf-8?q?1aNu7pE/aYvr1G17d9be/BpIf3XZzoK+Jf53h9zMKFsaVkiFI9++zyLlXLU5kch6t?= =?utf-8?q?7LsUvC2UVfNV2k8qq37qVqHOyox1wxk7QG9oOWHZbgGBA4+X4ErBGoWXdcIk1gAWn?= =?utf-8?q?5gYMc3DXbyIKoSZrCgKP0AqWHDiq8nw4Jca+oscXoVrCh2kGujKTxMrKwblffRbHt?= =?utf-8?q?2j/8XWtTnk9uY6HlyZ7QQ6poRdsir5YFEGmmcmL0qVRalU85AQGi5QgbYaAF2Wz/v?= =?utf-8?q?lGGK7t8uHN0TXtI3btZ5AiRFoFMJYAH7c0bPNAa3LG+e77kwgrFlahHpZymnunRQ1?= =?utf-8?q?qs2hFC1kk5+T0b0nul9FU+WF30N4UK6UQBb0/+1L8ZMw2Pqy0V4nMSflop3nu7MYw?= =?utf-8?q?Bhgsuqzd942zqvXkyuXRRhAAct23zpeBIRgq2EMOFPeA9/M1HGAatXqLWSM7om9re?= =?utf-8?q?fBq6Z8VvuS8Vr7buCFEMNfYxQTJQ21TPTLQUSYBdPvVUhllSONAeuhtut5ncXC3AQ?= =?utf-8?q?jAUcrjLYZJTGmM8xaTzmrq5A5xraqgJSyvVggNY5qwcAC+yk/b33zJWly2CWKU4lB?= =?utf-8?q?q8F0jxqLYLcB4rNOgHP1rUhYu9bTVZtK6muwoVAxXyiI8zKX6UKtKXHaJc9RMz6aE?= =?utf-8?q?Q+dmNWT5ofPk5yLv74iAAOfn2NUCSQ0eSe4EgWGLeUk2bd5BDByvOTGOwAmPKbg1S?= =?utf-8?q?SZVLrUq7A25xShmAdaOd6HDkm6kjtzBer7AG6dvOlBWZ8fAxHiaxBXCdWEgaXl1oq?= =?utf-8?q?64rrwPmzYGDF?= 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)(366016)(52116014)(376014)(7416014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CoKojSWh8LY8MEtGkGwwROVatJsY?= =?utf-8?q?tEnu7xQiuYYlcshiM+HDpLFNqb5YHTBJxyhJhsQfpPZQCwID5ouPyhwvG5GXvXJ2H?= =?utf-8?q?UFzzq851ZCUXOUhMTb+fXlomBwQ0RYX0HPL+x6t3a3OwPlXnANVMU7BUV0sqby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k9?= =?utf-8?q?H775RMpniwFc1ko1dIuU1FQqVFTGXdp4iedmO+VD0q6o9Vq35KWX/OtVTtzcdxzoY?= =?utf-8?q?GTcfwShsLrZVbEc3W7o/RMhzpPlPPsfh3/PKOT3xg4vlfAMDYZE5RdnGB2v4Cx8gk?= =?utf-8?q?Ika//11Bs/auAB2CVJOzWibtE72DbcqExq8nPHm/cNus3ecForfSzzwju++ZvMIDl?= =?utf-8?q?Ymed6gyHe68k30G1J/QUMLBE6CsgB0ZBURlZZQxKA4wHhjBFJuulyYhRMWOvHtzO0?= =?utf-8?q?FUAzqj3SV9FZtRpG82NriQ0mD7SYSSSn0MOmRxSvo+AZZ63sT1ca9uZ9rzAxbmlv0?= =?utf-8?q?QkLniAdd4FhnnXOVt3uoGuLWAR7LPiy3YtemnVMZ3MP/caOG7kkIzEsawnLA5IalF?= =?utf-8?q?z1GuQgtAWh8p/6GlyR3FqmXZ5/UeCJ5ppB3EgGZKY17xlgtMy0kmEprLI9bHHDJzy?= =?utf-8?q?oQZ2TwqJKdxfnhYDX9eUqMlxuH51MLvmde1vEjQ9xvs+A/tRuACxNv5egPR/c7cmj?= =?utf-8?q?f5STK+L+WIok?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ca5d2d9-f579-4ef0-37a0-08dd033a6156 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 16:52:23.3821 (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: bAH1C+i38ypPZnvxGO0S9/Pr8EZ6KTj9VBaP7Lr1MdmsLkNa6BKTLZFvv8CAzYL+yUMLgJLQZKVRBls3tfkDjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9562 Add help function tmp108_common_probe() to pave road to support i3c for P3T1085(NXP) chip. Use dev_err_probe() to simple code. Signed-off-by: Frank Li --- dev_err_probe() have not involve addition diff change. The difference always list these code block change regardless use dev_err_probe(). --- change from v2 to v3 - update subject by add prepare I3C support" --- drivers/hwmon/tmp108.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/hwmon/tmp108.c b/drivers/hwmon/tmp108.c index b561b452d8d39..bfbea6349a95f 100644 --- a/drivers/hwmon/tmp108.c +++ b/drivers/hwmon/tmp108.c @@ -323,33 +323,19 @@ static const struct regmap_config tmp108_regmap_config = { .use_single_write = true, }; -static int tmp108_probe(struct i2c_client *client) +static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *name) { - struct device *dev = &client->dev; struct device *hwmon_dev; struct tmp108 *tmp108; - int err; u32 config; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WORD_DATA)) { - dev_err(dev, - "adapter doesn't support SMBus word transactions\n"); - return -ENODEV; - } + int err; tmp108 = devm_kzalloc(dev, sizeof(*tmp108), GFP_KERNEL); if (!tmp108) return -ENOMEM; dev_set_drvdata(dev, tmp108); - - tmp108->regmap = devm_regmap_init_i2c(client, &tmp108_regmap_config); - if (IS_ERR(tmp108->regmap)) { - err = PTR_ERR(tmp108->regmap); - dev_err(dev, "regmap init failed: %d", err); - return err; - } + tmp108->regmap = regmap; err = regmap_read(tmp108->regmap, TMP108_REG_CONF, &config); if (err < 0) { @@ -383,13 +369,30 @@ static int tmp108_probe(struct i2c_client *client) return err; } - hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, + hwmon_dev = devm_hwmon_device_register_with_info(dev, name, tmp108, &tmp108_chip_info, NULL); return PTR_ERR_OR_ZERO(hwmon_dev); } +static int tmp108_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct regmap *regmap; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WORD_DATA)) + return dev_err_probe(dev, -ENODEV, + "adapter doesn't support SMBus word transactions\n"); + + regmap = devm_regmap_init_i2c(client, &tmp108_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), "regmap init failed"); + + return tmp108_common_probe(dev, regmap, client->name); +} + static int tmp108_suspend(struct device *dev) { struct tmp108 *tmp108 = dev_get_drvdata(dev);