From patchwork Fri Nov 8 22:26: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: 13869001 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 BD9F21F9414; Fri, 8 Nov 2024 22:27:20 +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=1731104842; cv=fail; b=qj3I6eeKo4GgXc3paljvHz1fYiGYPFzW/MaeMAzR+oq3oND0uwS7u3D5ig7AYKOJ6Z6XdTdIjKjCDgR84BDX40jA6hrfLKnqQ2+Sb6dPayaLgx/aKV1S+ZCJbDlpucB+XCGfbL4+NIrJcMYLu4XRyadhn2JE7E9Mhfs4b/WY2W0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731104842; c=relaxed/simple; bh=7vqUo8jS1tJGYAA/RPchhwptChqKVdHqHfWjBgds2OY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=AV8Wc7g9utpmyH9kAC7cPfJxEALSC9zune5HkTL3AxGaGAVBN5R3PNxCLKyiJCW9h2DwLATO3VsBkyQ8Efv6d86OgV6BUdVJfhSf0pFTv4HuBrlIuZwy5qu3Xop5J7We5XtHnNDB5+NmYNWcpiNx5ReHal7gDXZTihsFXFSXOAg= 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=l4ROD/yr; 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="l4ROD/yr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kQCOKadvvjCrpApWobOIAK+rk9H30+4C7yqdAna+h2pr7W3apSEsed5o1w7OlBTyokQkh+2PuT8rpUTE67o+cLX8d5MVyhepvytdmtoZCdhIWuqKSanxlpCRhdbdo8dxTNZZutEF6R752JLdkdKzfH2lPO3KTG1WoJNNMaJAMeH7cd3ieGcFEZdIxcBegUeT7CfZlJJJaj5dj2v3ESzLoabNLPTBgGkYh8jrZcMtIbGeatYrWmUfX2wnXdAJXuZkwTiZnJUWsMUw46IGDvFCEEwc0G25hjpBY+9mD2+ayVcarpq5TEf9DF8ENXdGQ33c5noqXuHUvCKnYUrApWpKdA== 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=cQxxB2o2JSHVWvb0oARWH5ibKPXi3Q/FGDb0iu0rvFQ=; b=exnn/gzOGArB8rIJh10KylMSQgVJfX28kxBog7WJHUTwJkJybC6mUfX2Jxb9D7xHzojIVoAu0bKGttYNAGcJVRR6eSllIu7h5vLgToKEMy/KoMBgjiB/FhmUSg4IbDcS94uaAgkVVKWtvKgQ4BZr8t6ghKJFta2MYY/+RqJPe0W3qmwxGmL2EFyc9jLiIHCq2ZVm4B0liUw8irikiQq1B9KA0pUxqZXlLLdqomeYSE+t5JrsqvY3YAAi6XCFc3CDyCMguqv5pysoCoN8dYdB+iRTBdu5TJXC9yjOle820K8Kromc1m0CeCfjBYx8t3qD9zy+Jd9d9bbar8yZXjl94w== 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=cQxxB2o2JSHVWvb0oARWH5ibKPXi3Q/FGDb0iu0rvFQ=; b=l4ROD/yru64ZeLjg6D+4n8mMZk2gGqXnn05ACMa1VN+HIaLdiLBOgkml3HPb8//veK1q6lztE3EmmxioOfXcD2wIrClTmhDNUU1QPee4gesQ9ITDAMosG2sAyJFTcPvS8pio+qIt5r0Tjccb40vHJ35Fu3A3q5Y6coiyfIy9qbYVmjVat5s4XfJT5I7Z73My6veJcRZEoPk/0eeEJsBAITtZv5+XqKN33UIUZydIFG/hRmKh8WZQq01zzMKzMX5+Owu+qeJG2hQeiTRcRxqd9KSI/psW2zJWeK9teEyxS5yH0AZBVRVGx5b0L6kWAvPU55t1WAG6Wy1wh1VBapwL7g== 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 PAXPR04MB8318.eurprd04.prod.outlook.com (2603:10a6:102:1c0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Fri, 8 Nov 2024 22:27:18 +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.021; Fri, 8 Nov 2024 22:27:18 +0000 From: Frank Li Date: Fri, 08 Nov 2024 17:26:56 -0500 Subject: [PATCH v2 2/4] hwmon: tmp108: Add help function tmp108_common_probe() Message-Id: <20241108-p3t1085-v2-2-6a8990a59efd@nxp.com> References: <20241108-p3t1085-v2-0-6a8990a59efd@nxp.com> In-Reply-To: <20241108-p3t1085-v2-0-6a8990a59efd@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=1731104824; l=2932; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=7vqUo8jS1tJGYAA/RPchhwptChqKVdHqHfWjBgds2OY=; b=IzeN1oI+bStNzAHrZzCbhvDeXZKvG3ArBDR+V7az5kHvP7mUDXeOCV05iQzqu7DkFkc5pzTsV mpom4z2QDnrD/9eq1qguYClJtv6IS4enJd/4qt66CFLmiNDeQ9EdAgR X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR03CA0028.namprd03.prod.outlook.com (2603:10b6:a03:1e0::38) 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_|PAXPR04MB8318:EE_ X-MS-Office365-Filtering-Correlation-Id: 99662ea3-c3ce-4687-1053-08dd00448112 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Xgi6tU/m57keFHhvCWSC4TQymY/f5Yn?= =?utf-8?q?AKckPLY9fG0BQpFQbuacyWtSDJCc1VO6CIsjrH/4aNdNC2okHqt9JjMV4XNKQ9j+F?= =?utf-8?q?TbD+h+VCrOqQa8ffv38EDL9ZMD2id1h/2nIH/2gyHl6Rr65hhjI7rkTvHDcasKNIb?= =?utf-8?q?KSruUNrPay/VJk1VdP5XOfdkog9C8Vs5H/zJqoEU+1dHK1wTDaUkq288Mvnbdx0Eq?= =?utf-8?q?rCr04TFBQBVraesrbIdfOpjP959zC34OP8Ix7tCigymRB2TQCdqEs52oOFJ3L8WFK?= =?utf-8?q?axnO8X3yQS39nyYWXdir2im6NJ8KDJo6G5puhGxsS6EgXg3MwF8LVaHNo8ItJqRr/?= =?utf-8?q?AuVDmgzivrE1Ey9KvGdYnDTOfb0p01XZLk7WMWCjvUJY+Hx3GY4zvuZgeJdJ42icg?= =?utf-8?q?MCx5Qmnd664u3kiRGB1ZYS4BPaBULhU32//T8WvjHGH8J9jrRr8JlAVbnTp4ql8RR?= =?utf-8?q?Blt4vM3XWazdPgmtMNPrdSjJ+Ni1mmyHYrk/5Bu0CGQXkkFGOP6DpZggldpJDxO9I?= =?utf-8?q?Nh/nTfvSGwImlLNMGrfYA8jFoTTJhHPWFAMprzC20Ms1e4BQxIrOTIk+WhW9TxIUa?= =?utf-8?q?z0O+7ME4KoXt8zt6q3u2lxlBu9ooQ/+w5eS6OwaYzUZiRxzmZvfJlejve/cIYzcBl?= =?utf-8?q?AJgFO8EMwgGL75nMP4lVqxZ3618ESdanrVAyELIA8PXsZveY1MSarORaGw5FQCgUx?= =?utf-8?q?33RXLGdnnFchTO1zlq4X9c1cggN1H/mVOiQqQ4ABd5/7wPbYcAj9nv/d2trqoB6S/?= =?utf-8?q?LeocJYBf7FOzG6DTaWqxu7Ro8AOEOZAUWg+R7Odecxh9/do4w0i4h188NcgoX3qMi?= =?utf-8?q?gEMQ/kL/mQt+9QJMdzcb3KUtZZHYSq7jfuReZus2bnxuFgzqH+5yGSwDPyFVFKgZe?= =?utf-8?q?obOmBP/5Zv90cVACAo90ZxMIcwAN340awIXcpuhJc/qvAvBQS0nKOkxarbIaW3H4d?= =?utf-8?q?ffFuSXOKNcRWaWTVvPBKj+nSNWZrt9N8NLx47fvI9pHR93yPKZyVF/nFTM1WOUOIT?= =?utf-8?q?AhKyhj2hmLyo5gnETxRc4EilW2MIImBnBEn/6aST/KFr/h1lU68NbPVONxRJ/d7y0?= =?utf-8?q?5c0ZZ9SabC2XC0bh5zuiLdcN5t6H2NeVuJYTtiyUApl8d5sNUWNc/1f1hfh6CECkY?= =?utf-8?q?TajAqvHwn/OvzVilzQ7RtsJVaspj22ID7O3v+RrBdW7ur+CR3oxyVWaqUU1WWxf7M?= =?utf-8?q?YVjiJcIcTbSHLxFt6GxUJgZkA0Pg/rtNINpSfN4tz1r96DWAy/uKygrQYTC76DAZ1?= =?utf-8?q?PkrbTgaH71iZH+YZKgP9mwKhJCI/RpwUz7gkqwJpYhEtcXTcNd9quVaqcV8Bs2gpU?= =?utf-8?q?oYHfijYqvNNh?= 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)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mWx4oN2nr4m4/bQR0/QXH7CdpIZm?= =?utf-8?q?vH7B8vQPLYJCt1fNxcvK7dcWQLrWu4fdSfU5l0fZelHAIHobvybCfiOrZ0qB4++AL?= =?utf-8?q?pbYRjKLfVFo24M81gxYL3tWp7ZoGsLBGEjLh7SY0737EmHAFEUcMlNGj5DM5mftcE?= =?utf-8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DsqXGwQzM6x71HEqF2NK89Cz3zr3LAThBq/tARRLB0eYIZf9Fk71LUIKA?= =?utf-8?q?tCDTRret7npe3L0pAVJoBFS/Pl+FJ5q8LNlQsLWZZsLKG5RbrOA9gY+F8YZacggcT?= =?utf-8?q?jqPB/HW01s1+mb6f/vPdHqHZBIhaZTOYd8Nq5DHoVFIJGH65l7TtlyaYkPYoYhkqg?= =?utf-8?q?NAaXGyuBj9BNRkEqj+B/D0kw9cbG6lki3whnYWQ8LnV331kVxasiRNE9SNjNeIfAP?= =?utf-8?q?YO8uhXKukCf6lLi0wkQMM3iOmMVlcwZYMpnHLl0PNcmdtUzIkrNETpg/98JXsNZuK?= =?utf-8?q?iuSw90M3dxGj9jha6nt/i4BsdkEUJw7DPQWr8uJ63maSpRg8ET4ZD/VnrzkvTYPCy?= =?utf-8?q?V/hR6h2jM1DOFDD0CrwQJrGY+x+6HpnzBC4WyXidtnOQXxFMgWGA8+TJJEW38xw+E?= =?utf-8?q?4CcNMOXoNxskbWVvCqTUm9U85Z0aurvOMp5z/o+G2OUhdur8SXZc46DA0oFG5dHCp?= =?utf-8?q?t5aM8HYy/edB?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99662ea3-c3ce-4687-1053-08dd00448112 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 22:27:18.0483 (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: DMjZM2xMQqpf3FUR9Zd6A1ZgiZcAaJMyu5PZb1tghRFA1OtALOEXFlRjRsnROKwt9pYChJF/N4KQzhDsGlHeaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8318 Add help function tmp108_common_probe() to pave road to support i3c for P3T1085(NXP) chip. Using dev_err_probe() simple code. Add compatible string "nxp,p3t1085". 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(). --- drivers/hwmon/tmp108.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/hwmon/tmp108.c b/drivers/hwmon/tmp108.c index a82bbc959eb15..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); @@ -420,6 +423,7 @@ MODULE_DEVICE_TABLE(i2c, tmp108_i2c_ids); #ifdef CONFIG_OF static const struct of_device_id tmp108_of_ids[] = { + { .compatible = "nxp,p3t1085", }, { .compatible = "ti,tmp108", }, {} };