From patchwork Fri Dec 13 22:23:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13907999 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) (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 1F2081B219D for ; Fri, 13 Dec 2024 22:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128614; cv=fail; b=kNV+GeMPTk379MrlcHYNt9oMyghHkH5jkQ1kND4OqMvPhSeZZS9VuMXHuPUIgeoRifXrc8t4s+GdeXCANYniRzyP0xCbK9A75YjQlz+HJFEChTx/PASXfgztkNaqUxxfOKGTklSVlvsCXE0IbSwmFiZQ39WM1h+4atexfcB90UI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734128614; c=relaxed/simple; bh=cOT7xf/RkLx9Nsv2I9mWRJmJKXTjn7v9+2NnLONMGKA=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=p4LrR9wY2F/pfJ1MU5+Dchda0RYMEULVIfxmAKa+5HRH255uJ0Dqt2Y5vV9y7YNUupL2WdoFGdKRBn3g4zeKJO1ldEidZTJOUgsXlScFEKIlYDBVKY1/XqR0pGW9OMjzZqLHCTaUayIfiSxB3JrWXR6BTxpG3thXFmzs3I9tDpM= 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=btS4p3ti; arc=fail smtp.client-ip=40.107.20.70 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="btS4p3ti" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qhBF9rTLceS94LQBigvKOAZRxeG86feVIy4GbravXJcLB7GHunTPTW4kriW0GjL5yZcFN7gnoW6UeOF6WhxhFA8y2C7SOOqb6TdbwC5xT1tc+fsBIU73WeMlmkFoKksGXfNnVCsw1UxITkztsbVvhapoN+H92tLSZntCaXPRwXRx88EtIlvytitTe5F3YSciTU5KoEOi8EatAY+WTrZAB6tUa9DMpELy1xF1aifSto0ItGoZImS9z3W+Ty9jqIbBF/M8c0OTj/A1s1hVQp0G+BjalOf8YVnek2y8zFoL8knGjGi3U02AATo43YY68UQZYZoQxGp75rDzxp4Snhm54w== 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=LH4oi+ZePpm6ZDGS61ibs9OJ7zE6PY8ZChOG7YDNal8=; b=fkPjVzUa1unCaROBPV6IVYevGPu9dhTGX2pzf2YreqyR5FJfe044j/NTZftFwmQfpuziEnEUgxavlsl/TNoPgPGxq2AayB6o2jIw4pBJFVq1U2ms2Apnb4euQXuzn5Qg2VTTWXTRBEuKbbOms8Bdajh0ZbcVMfG6eRSnR86wYBxS/UarKMcNjqYfu2wCrQb4nvlL0NBMhIpaTRgv9Z2XnwavU++CvsjwwGnmcjIms4690PMDrI2pkEy14s2eu4HVNEerUbW6K7f4YKyjDC8vMLt4CvlMHk5WvoTkgOVZpek1wG6cGo4BjOVV/OTDEelrFqtjiw/NnRvrE38uaGd2Ow== 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=LH4oi+ZePpm6ZDGS61ibs9OJ7zE6PY8ZChOG7YDNal8=; b=btS4p3tiga5RPwyeYnj7C5ylEM8W/M59Rp/m2yw3TjxZFe/bbxOWI4lF5dVoBnvJz77ax3No39m9/hRBmCTrbBPh0Z8Un1kGirIuSFEGU6JoEMv9koapA+uWrag3aEfTSwqX5DHXkJoRLjj40IoRsFHV+G5c+qVoDFw+Ak9hOjUphE0RbIlIHvziBoVM5au/1QXfvusmLqtwtJfya9x/e025l4pmUVy1ZSZn3Had6toIsXFnSoPsPsN6jiB182RK9zMX/bYSgo6l3sUAQeuiDhYBKR/HBZgr0FYUIOKCVlAImIafQjDEc8Ea02xA8CdyW9rgV9mbKFRCQjt66+CRSA== 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 AM9PR04MB8810.eurprd04.prod.outlook.com (2603:10a6:20b:409::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.18; Fri, 13 Dec 2024 22:23:28 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8251.008; Fri, 13 Dec 2024 22:23:28 +0000 From: Frank Li To: Dmitry Torokhov , Luwei Zhou , Vipul Kumar , Dong Aisheng , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...), linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 1/1] input: mma8450: Add chip ID check in probe Date: Fri, 13 Dec 2024 17:23:09 -0500 Message-Id: <20241213222310.189443-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR05CA0176.namprd05.prod.outlook.com (2603:10b6:a03:339::31) 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_|AM9PR04MB8810:EE_ X-MS-Office365-Filtering-Correlation-Id: cbe7ed30-9a43-4d07-0b3e-08dd1bc4c4a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|1800799024|10070799003|921020; X-Microsoft-Antispam-Message-Info: 1DNbQ46F/MTXyACq1HHTHL41n4C/h7a32F5AbpZR3+/2cE2mGur1NF3m8VGef5gXpO+VInKY5iuQgMxVZjhKCeC85+qmyi8W8dbfthaZcunZH8iKSBCmVQgJHMetmNmmPHoMSg/IldOD4wBF141aDLqLQh127J+2qzGrA/BuWX3XLVnbvm+k+exVi1a9RJ8jX1Bp0h1G7SXqKuRCrRHJSjYd6bRw9p3GTAg2MgVJWGPpxgd1OG7UrTGb9kdHqE9wK98+/Keo39u06IvKhfq9UNH5laqOnm4DTKQ0pSqevP3inwctUi8zLpr3WtQPvsqxVG/FhtaqEL+FmdZCWhNwKcYXaflTz5hZJpQIpXkOFrjn8tfM80b66zxJAabOfn3AxjgmneCe+VWa97WZN/mie/PSPHdIrxqpBJ/hP7AR4eUu8+iZ7ujjeT8DcoiOt3VBHlsEqPtQVsnn1DYRKpB1yaHnzD7va1767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)(52116014)(376014)(1800799024)(10070799003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X/jQ1KkvcVzngr8sIbPHxzfKV1fhAprGZZmZrrE5x4uqsk7Q63E4Y28Xa6zRHkez/PP/pBqkHB4nSmhd0wr4BD0jMSFjOTPQjrlzOM9/aqTTKwwfAMcq6VuJDckrxE0plF0xK6FkDCplHNRyzwj5mgyJGxDmJmQpiYT3hwj4xW+FPKBisFUYm/dwtFZxG+JBY0n14ZkK7w/uingIbMj5bVvW84LbB+Zh5+Ku/V9LG5WmkAKOzREn/agAuRAEjOGlRkp52JhRR/Yb5KAeUWG8H0d1qT/DC99zr5u7qCVwfJP88ZpWIVbYLWCtGe4rcylNHz3zKUnvhirCXviWFUpuVuI0WJFC0Tb/6vPQasDSGY0DXsDUu3BGRyYGnfn4B9u5wNnOWOnyqoPUP95wAwTTRcC+VmuovmY4go15SvZ7awalaLGybPzRrxYBy/yEW+h9gpe/8tcsLX/elM835Uf5WiW7/jTNaX5627cBiTiEv8ygsJjSUKdNDtwUBHQ4ht00b4xuODGAsRmN6emPyMq5SE54ugloAFTRej9mWdcvs3psNCqLzMLST5AOwUKags3paAO4hC5l5W9n65dRig2is/3UO1aSumTMyxiIFhMwPazIgVDwnIOmWZWhCdB8UVUD+BO05V7DY3+F9daMBVkMrVrUw2WldMPZIt80Jxak4jALxPLVpBM8voRuG+14U6lLn90kSA8Zo7VGHAEdwfl0wcy6TjM31JOMEbBBkOQ/WDqNFhX28fI/XhLLercx2+3QsGJTVixGHKm2dCUqBUX3yZPhFSby90cyzqnF2G1Fw+g6ciNutEfPq2qCWXZzNEWH8/BERU4aOuBcQA2FdGgpolB860BIt8CFEzIOxIalh4+M/eTm3uMVf9QCk7t3aNE9XPsEWSLNn/WgxLvs4Aj1VVNxwb8GKwH8IGlK/rocvxai4JlbzUGwPgfeyU1yuW4ZOjxp1Z13jw1YPlh1Doy7gBkFRAzmkZGUmjaDz/ncfSIYl3sfUb2hYvo9DvOAP5wu6hBXtaZkNnwM5MpL1cVSPqNTBwBYviMepiYaWpTNFWP1TpcETC9tZzXeKKL8GBbRGhawMOVL9aaJK1YHziCUp1WwcYUuML2bgGhowSukdquvlUz+L+lUSErc/o9VPz6bQ7R9a//KGHkGMH8qARbmag9MdOOPs4GHw971/r6ZPUUy8VdYI1pelt5dHfRAerZc6px0g4XFLEsZkb97TatnCA9Fw5CNJLaP83jVKvcT5E88IybFZWhezvDZdNb2l59HdK/T3gMRlD7hM5TdRI55u8TXvny7a6UWVPtaihlBkGwoLIpwvRht2t6oaxgCrQyiS+QNAIAo9Kgg1AN1+P68Vr9QbMJeohXAsbSFfIo2Hf2TO1WbJvv1Wm+czXUtkeTt4Jen92RkYrGU5dabayEpxD/POBSn0T4cSwgjB1qt8tKbupzA5FjodBZ5lQ/oNpqhzes5Nk6v6Mo4vN0RYzmWM0iFtB/kZ7CyFLIxJ1Z5mqFqJtVxoJdeYoAVDsAD1h9tkLiczBOFzK2+GBIO3NIqED1IwsyvZ6QCCNntLP7Zrp96+KSyA6ZgWUb1HHazkg5DIEWKlm6CPdZgsqUaYpXDtTHL8pmU+/Oq0hpAzm3+33DePwrjlfp8jXV5M8wQAm9k X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbe7ed30-9a43-4d07-0b3e-08dd1bc4c4a8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 22:23:28.5119 (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: MHWWfU+BYktRDfJGn5Sr+aDvdR3zwEfq3k1rI2JqHxWFtKEIJ68fWrqV/jV8fAfdKGd72KQ94YUWpmPw26pR4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8810 From: Luwei Zhou Prevent continuous polling error logs by adding a chip ID check in the probe function. This ensures the driver only proceeds when the mma8450 is present, avoiding issues in scenarios like missing add-on cards. Signed-off-by: Luwei Zhou Signed-off-by: Fugang Duan Signed-off-by: Vipul Kumar Signed-off-by: Dong Aisheng Signed-off-by: Frank Li --- drivers/input/misc/mma8450.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 08412239b8e69..da941748ed29b 100644 --- a/drivers/input/misc/mma8450.c +++ b/drivers/input/misc/mma8450.c @@ -38,6 +38,8 @@ #define MMA8450_CTRL_REG1 0x38 #define MMA8450_CTRL_REG2 0x39 +#define MMA8450_ID 0xc6 +#define MMA8450_WHO_AM_I 0x0f static int mma8450_read(struct i2c_client *c, unsigned int off) { @@ -148,8 +150,20 @@ static void mma8450_close(struct input_dev *input) */ static int mma8450_probe(struct i2c_client *c) { + struct i2c_adapter *adapter = to_i2c_adapter(c->dev.parent); struct input_dev *input; - int err; + int err, client_id; + + err = i2c_check_functionality(adapter, + I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA); + if (!err) + return err; + + client_id = i2c_smbus_read_byte_data(c, MMA8450_WHO_AM_I); + if (client_id != MMA8450_ID) + return dev_err_probe(&c->dev, -EINVAL, + "read chip ID 0x%x is not equal to 0x%x!\n", + client_id, MMA8450_ID); input = devm_input_allocate_device(&c->dev); if (!input)