From patchwork Mon Nov 11 17:32: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: 13871029 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2078.outbound.protection.outlook.com [40.107.21.78]) (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 474831A76BB for ; Mon, 11 Nov 2024 17:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731346371; cv=fail; b=lFEVbqANV7M+WJYTb3/3hB6ykFfe+QW62nfy3LBA4z19vzII1i14WntkVr2iLPrUeQl4/dNnGxWa5kNMzGuY5KbrcwJt/9aR0e1xAte0xX4oNC8v8ugIQMJiXFlRcAeJgcsNTW1foZsYaIwVSMORAzlUFFI1wiPR8640PRwZ4yw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731346371; 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=oPo6d9zXY7NFtvL7p9pKCPCE2OaM2B60P/vLF+t+VoOEOhbeWa2rUgqwniSODGBvFz/lFiAxilKZkE54aNOXsU9KUS9CNH4t1iRQodGJ4P2e8UbEu5bmhsyt9ObTrQa1ZRz/31b3J4NuMzokMyh0rRbdAP7Sg8K2dR3Nozbv4ak= 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=WG1QeB+U; arc=fail smtp.client-ip=40.107.21.78 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="WG1QeB+U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ojY1LZkljoTykY4b21t90ct9xOcNjNzR3YW2mk+4yA8ux5yuIYng86zBKzW1r3W/qOa4ew+WDkm4XGZg966UykJ+HGErucWBYDXBawXxENo9j31XOUOAZWmK7AVJm0eoxi13x5ZblsUbV1gSmGDlEtrt4usQ2t3xxrvetWtB9O7HAHFU2lyD25ajoVGbaQBefwSF1F9uC/mX71ywEUEsQk7SOh8rhNXjkG+CxcUBsgEr6yCw4FYmVYt1GZ52TmNndJ349r8tGUP4DLmpFV1rqchLYvDAl98ZHiwhfS2mWLX7qgzmuimGadR5fRJFCXCxJQ8YPm8HXHKSCjLyZ+gk/Q== 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=FRzHwrhOWSc2MvV3vUxPH1kckMeEbfAhxJ2EJmOva0+BMwecne3f1NbhdXuNhzeRImZ2Y9okq2/s4c7AlLns646Q+mjzhFCsH+1Ocm+C+zR0EdHPJHxNPuytue5IynMjtMRjLE/CVPxjUcZ1cM2O1GROoEjF5z+kF6eTLBkE79af8511JUlHtMeS7nhhx7ZGYekaeJTVBgTeVl2ga1rqK69VFiHtvXcfQtnDOUTo7L1EQz8GTsaNOc42SynI1CwlIa7KTpGWE92XvImF89zMq8pBQOF0u7jFoY6qNxj04PVe1KdECtfW2vApHKblfy4M5gGuI5WnZvpmXp+ixmx0Xg== 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=WG1QeB+UEg1XlxaaWCI/xbQUYlqfUu9NEqg6dfgaziunwdxENhmFGIykLvusZ5wSrbUF8FiuEQEEZc9NGMo9wXc5/DerhX7k2YHaxpKZm160LXVpuSQAZryOULUazSokqaFl2Wqzx7aXykzFN1zO5KMYHL1oXaDyx1SQC02Ng6A0rRGOiO+UKTLPXVenbJqx+ApmzDQeMwDWljdZMKBr8tF4G78Iqhbb8/POVYunI7uuLZTcpyp8Q5X4NPr2Qjde1800W7OIk0XT0lWcB7sLibiopoEg3ctvCZ3E9wwjxqXEe4/IcYcF7ZueYP9/yzSZVFd0u4+5M+57pM/RWty0CA== 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 PA2PR04MB10086.eurprd04.prod.outlook.com (2603:10a6:102:40d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 17:32:47 +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; Mon, 11 Nov 2024 17:32:47 +0000 From: Frank Li Date: Mon, 11 Nov 2024 12:32:00 -0500 Subject: [PATCH v3 3/5] hwmon: tmp108: Add helper function tmp108_common_probe() to prepare I3C support Message-Id: <20241111-p3t1085-v3-3-bff511550aad@nxp.com> References: <20241111-p3t1085-v3-0-bff511550aad@nxp.com> In-Reply-To: <20241111-p3t1085-v3-0-bff511550aad@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=1731346348; l=2743; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pHdcouA8YK+jThZXHKLq4J7wOSdvJ4TG+3dUQln/lGc=; b=bfBhmVCVa2weYkbM23SlmsWKV8wviDQ58GykbkhfkF7BK5o7FeV+W+zLf+XAnAn/1MZhpsDse 3vfSaAEoqS4CudrQBUDTRBAM3YOa8RNH9NNssuY+9Pj5fHRVmW36XY9 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0044.prod.exchangelabs.com (2603:10b6:a03:94::21) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) 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_|PA2PR04MB10086:EE_ X-MS-Office365-Filtering-Correlation-Id: dfa1bc41-9873-4ece-36b7-08dd0276dba7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|7416014|376014|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rpGl/AupcIW/Qf3EOdb0eK5E118SOZp?= =?utf-8?q?rvwYpmsbry3YcVAWktinGvFqOGwIjLDxS6x2/KlqS/nr0mpwFwW179X/uTPGqSnwx?= =?utf-8?q?VtQoMekouevkCpEfhG4i5AyxXojZYR5S/FfEdbbTKL31QYwZDDUKhZDxJLGTNbR4N?= =?utf-8?q?GgkDAGEx966dN1k+KAI0ZR/+hecRZB+cjrUC0SXF97OTy7vA99HTtsuZknyFd5vlm?= =?utf-8?q?91S4P2SUdW0T3kl31QKUrdPNxhajO78Ygwmr0UuwZPCzE1lEslpOfsOVcTXOPh6Ev?= =?utf-8?q?dTMT7/ESOJxsXIM/CXu9Wk6M1N8B5/PQ7pgt8OBtrrNvhhxdeTgomG4jANIJWOGdT?= =?utf-8?q?hehSd1P9SwkUskrhJozVh0TCHoESfR51/u4HU0VcB8mDvQdvBDJkhZ+fuZ16WrtXH?= =?utf-8?q?inEZwbD/hPBNsS+rF4wyaWurCAh8NQ9Z2MEI6d2XNwIEmCaXAqm/q/BUchUUN+zYt?= =?utf-8?q?/AOEhrPkk+/YwIzuoHgaMwJkX1mPlXopui7Z/vK6qAVoNwwS0GRPYHLcv5nqyugpi?= =?utf-8?q?ft+sEwLLLO31dPrLihALWKBpKHle7xPV5oZimJvjscrqnXsqQDpVvyB5DTOziLMFU?= =?utf-8?q?wLdC7csa3DcArZQpu9TXEC21V+iuJSvLPTuYfmO+IbuLaOFN2PQWuPjRhmg04uQRh?= =?utf-8?q?gPOzGPGG3MNR1P1+m1/TJInR4TOsbc4bMhALLTJQt7T/FRNztDW8G4i0XZTjrcSFE?= =?utf-8?q?8Z1W35CXUTjKWiY/EgLwN55UYotO1LzazUBYijvY+8/aTLZenahAVdMUlodp+QD34?= =?utf-8?q?4C7IYi2JojwwMm/htbJwEYqEOgALwTBf7HtaPopQxI0Z/d7rn7g8ZZ0fRnqor8YLZ?= =?utf-8?q?lGSdNSsO4PaMMih2VVipWoZznLI1xd2CrBupyduVU6v+d1HcdcVdt/3gWQhcdxcD4?= =?utf-8?q?Tmoid2BEfIjdfYkFlpKO2ZewkyVdUBDjxiPG1wrIhWdWUSVCY1VnxJRQwnjSuCbh/?= =?utf-8?q?UbGOvHnzVsvb+wHXd9jq69xTDwt+lS3F2iJdbJv9pNV1Ka1SinFStjfhKqE8UQsRA?= =?utf-8?q?wila8Ba2uRkbqwIF0uRJhG9NJy8FJFXtaRQkz8AXEnHt0qU+1hhm3nycBMoGskNJN?= =?utf-8?q?adOXcuefyclGl//1aJDGWsre4ippDgUhLkmlE3aeiSXdBxmcU5iLG0ONuEbMLiro+?= =?utf-8?q?xzwIswxm45Xxq/UOEXO9mltVYFKsFSINn5GOb06+nqvyi9f/DdouQ/+OXcZJg+tTI?= =?utf-8?q?jMw1THpRCBdF8hDm4okYZ5FHZnTxgWpmM2Lp1pgBWyH2wyc8pRfgufJ8hdUfKhCCG?= =?utf-8?q?9Uz3hfsWuuOSi/sVlkK3MgzkmsuCJiH37rQiEzchZTc/55LatvRr0Qklvq5FksQM4?= =?utf-8?q?ZqE4wPe0MKMP?= 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)(1800799024)(366016)(52116014)(7416014)(376014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?28w0ojRGHoRozvVd3YALIxhaXuKL?= =?utf-8?q?+e/2B3MMsU917759OFz1WHt/pLEA4yNuZAxvWCJ2xIzOwzMwcCi0jhfZJDWOp0IEr?= =?utf-8?q?6AAvk7TuskBYAT0VuXLq2ThwdfMqaKSiqqunb/beIUA8J3rINdqMH1aAxPp903LvC?= =?utf-8?q?7wtt8PwBYvtmqlV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fh6kLVl9b4gotbh5yRubhJeyJW2V7pasRVp0a2BEKLHvy9Pb6Sn?= =?utf-8?q?w79z2EcmGkZw/gjNw3OsC8sESrGocoFqJgDs0IBrrQc2LMrsHiZQa8RCzKzSwm0cA?= =?utf-8?q?WP/N3/l3Ku1jVHJkwnBGUNZa9MVpK0Rvj9tC9yRIffZkn721twxU28SsGPwzOI+Ud?= =?utf-8?q?iSkcV1MB/GYMg+Re/fhqy2DxpN8FQIiYv6yuOT15+EW4MUBZ0SWXlQiIOo7lqhrEH?= =?utf-8?q?jVcoknpZPU6ffQMVEGgcjSv/50EvLQa/3U1JLspHsvncY189oU6sv+nn7b8N2riWz?= =?utf-8?q?VIK+UB5ez5cfJWOMOw6vrpiIF2V5zjBPbv2xsl0M+nNpNjwViJHVaSUyYC6akqSkI?= =?utf-8?q?ZQooRZY8wWASAcXlUY9Zwyu2sQsScaST38Yi4XM20XiLO17rPEWzUQqBv/AEFEkXE?= =?utf-8?q?0ZbhQIePIzWNjEV/XhC1x91FCh0WqJYR0++InTE1QxLpKq8TxKqvrIztA9MQIaz0G?= =?utf-8?q?+zy3VZxomTO3?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfa1bc41-9873-4ece-36b7-08dd0276dba7 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:32:47.4537 (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: AKyzUccjz1Tx9AqMIz2hU6EBeSdfGorlqxUv1MuzgznrGOdmAP+0GAHoDZ5cC1loUJinnBpecQpVknmdx9+fJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10086 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);