From patchwork Mon Dec 16 17:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13910127 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2078.outbound.protection.outlook.com [40.107.249.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 BD6BA205E35 for ; Mon, 16 Dec 2024 17:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734370346; cv=fail; b=EXvJtmnAfx09fDh66tQLVU+IQGlM89XLzNbXCwHuXMeLyXAYqcIVLqqlCM7J7Tn8QUR2zLg1TH2HnFTBhtEmysSkhyCKNeFj83WFw1cHBrkxI4zdD0j+G/Z8hKeMfV2/7GZDfx/2oTlA4JthqOibLw1McKla8JpClXYE8E809ms= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734370346; c=relaxed/simple; bh=NexfQH/TRokFX19TTVqeQYjG9Su1b6YKAgPL8Y6b05Y=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=CVhoJxapH1s3zKwdQdFMvglIb9CCK/tyU1qgzLpw55Nq53oaoyvd1AqqY+oCLRWY6cCBL8WZiFLuj4teAUdQPJC9w/ffIA7rAjf0T08IWQEnZK2avLkSzgN1ji0s58rotfn0TcVOC8ndtlVTMUr/QlKItuSkJzNJzpGwBeRKAvo= 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=Zyew8B0Z; arc=fail smtp.client-ip=40.107.249.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="Zyew8B0Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Waq/ZwTRtnYAy3eh3fWMvZGQIcPEgIkGpGg5AvhUFxvoj7ml5AhYgcdmdzYiYdhXlesmu0uFPtD8wr5t+5sysdosP7oWoRbTGdpbDOMH5oEqb7z50Bgcd44N0guEiuoTlLScAg+tvbJlJ1Le85I2wfU0p7VdJ32FxAzhS/lbhzAUsipbEhD+65Hba/wgAYXreSTGs1rwNLWVIerTYCXGVNSNCVtApHUKY125/46ZAbh+fyjcyNfkkESLTDjEWlyRJjaSAvFVBP2Dq86BMU3UNh4iwtxxyP0okg8uM1fMqW+SGTy1JwJQNc+QzyQENNMH2NHJHkaEHJHfrZuZbDBWtA== 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=hoVQG2DKM1+4Ul8Pneyq7Y/Baj/0RzZb6FI3x1MyOPk=; b=kUyq6fsUl6jwvlD3PIjyyYGdBamyu7xQsudTyGGB87qaN2TeWGxOS6zMWqcTW+6ntZVNYSzjop5Kd0dJMoZ4/YK2NqeSKR8YUgjOqGHtzJmS1mXQDKO5ZU20wb6Mm/Ewr02wZyjCX6mC40lRYLa6B/NlVWXdleycwtE/G/qmniMZhEj1arOnuVRn8sPgrfAT10DRZasqcdUqOJ/OikFP2IwiXqafHVgyYCc5pFwxldlFvqwBtMPTtkZLp83m2ib0oimnNVZGj/R49RmVqDAYWdpYMy4EW+aP+pQ1rFf5VufWMB9T1tZptt4nFV6CrUlTUiYMvKh0Sh7wm8k80cs5xw== 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=hoVQG2DKM1+4Ul8Pneyq7Y/Baj/0RzZb6FI3x1MyOPk=; b=Zyew8B0ZABUGT9Wqz2+iIpMiZWvE+XFus0PhR6KDRu3iEk19Fo2gMQnPH693N6IzIflTOUptNVtDQmG9eGT/6ztJdAK3QRNgR6AIuAm8qMYhVplUEvRDcPfIS5mZ7NFEUB8uqmqV/szZLfG14akQicIrV42f+NFZZxXjuWMHDPlVUyNpmgOXrrlwtJT48+YvkVCnEGgPdWe5gaRWzgZc2KM4LPFuvVbMHtPecjvbXOoKzWdIXZqwbymSF/fYdgLTMo2GX3jCXbnpujvjSjprmykQ8c3sp0yuipe5tfcfLyOhbGU6nZ9wmm2+bTDXDxDlk4kEXqWjfnCImMbSqH7JSw== 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 DBBPR04MB7756.eurprd04.prod.outlook.com (2603:10a6:10:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.21; Mon, 16 Dec 2024 17:32:20 +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; Mon, 16 Dec 2024 17:32:20 +0000 From: Frank Li To: Dmitry Torokhov , Dong Aisheng , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Fugang Duan , Luwei Zhou , 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 v2 1/1] input: mma8450: Add chip ID check in probe Date: Mon, 16 Dec 2024 12:32:04 -0500 Message-Id: <20241216173205.211058-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR03CA0365.namprd03.prod.outlook.com (2603:10b6:a03:3a1::10) 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_|DBBPR04MB7756:EE_ X-MS-Office365-Filtering-Correlation-Id: 2eb85eaf-b6b5-4264-fcd0-08dd1df7983c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: Q5bXBwyLuJPE1cNfb13IIUUmyxqWHvb3Df9DZJ2hSxJjn5iZO0J2QEvBUeidv23wXe5s4cU2qM6EELe9S25WJIj25MdDQaYKnUZBbTcQyAu+/41tE3wicG0RS6sTKSYh4/sXE5WH+ylHTvSw6oVPJSR18OoTXIi9D8csIrkspv9yl0rWqH20xS59IwfO/xl5yEH2ycmhMpmhnO2or9920j5WjOH162RY54BAoFDXp9XKN6X4iTqpD89VZodBudPwtVuxDqRG4mgp656/yiXxpRmNEHRs5WnpFM1iM6TKkZaJ//ESBGcxtDhouQEn05ORXxuP9TH0NRK6tPtB7czUDOGNTKu1qrwvHXlxEanNitiCju41TpM4zIoTJujLOebr6IN1+HWVs0/1r75fmRwZo6wtBznoppqfJbqMKtfsoPQ+w4V1dBhmJezOsBlF092G7c6v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.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wNu/NzULMBdhg/xNJgz0eOy7RY2rJkKob5yjJTFESQpW3LZMpiTXx6Pz9DcJcNBrO1zGhAJdk+W2jgJRIut0TuGKlCcxiroNe8/iSTGZs08tyKPZCX0SRsOR8KZA7EBM7IC7BDA8Ao9XpiInSw8bhAtRiqyu/9MFGC4wwZPf3zv3ADxrjr5TpiZaKe0w2xtnN5A5qiBdT6yzB9+1p8gHal8U55twvekA/+79xvSCEYqZgT8WJSyEkWKrsgHB/NnVLM8Eq9TU+85Y5mvX1Co8XQ9jKwx2pmB9cyVU0v9O/bZbtNfDhAuJ8b/c6dTO6rC2lNfCnESDRBsvVodMFn5nhiAL5m899M9d+0d9CYxok4b5bBh14wsKKcycWN3xEHU8aUHDSTDsxBunxiBUx2SjDqBhR8T3BQMdJU2+IOyRONPo+UCaExcUrNsPFRU4yqSuJEUhZVvk1v9mjMXvc186g1zAB51zaw7pt5veD1MWh1PZSUUMJNXD8gsNQFlrI3DxXlZ3o9SIxg243puhFVlpc9Kr/43lAuyV4G9pClq/IGJgMrjO2AnRZqjTgC6/7e+UXESS7KH5HvlL/oXNUTzF8EEUEqj+18PbrHrlAurLf4B7vFop1V/+fBvdCWF2bcFRB3gqf4tOQdjy0yAeZoWWCu82ZD2MBmTKR/qlpKvMbLgGSWNYEzqZw4whBboi6NY5Fw+y/3cj6WzzDH6PXEJXfUv7vH9WETUXg3Wyz+9TvqTu3K/Kx8hsyFfa4Ub9gdj21PvC4vxwSlFRXqwVlRjft5fd7sTDFgj5VKUruBMzGG+84RLTnKfLTnlExEYyomhEmlz/G2tKwADqj2XeBeh+pv8rKkChqM6xPAtixZFeNPG1dkvHTJ9/5zfZXMPzw4p0Hk7Y/6V2it0WxzyZGGc95WLROkFwHwrP86cX6cwMNZCnF4XHcVqwdYdO6UjqchSzDtuh4kwHq0V30ijmhm9sU3SZnFKhYkWrEoYPlDmfJWlTtPrLxRd2XTUHoKDRA0/86DT+xzSl6k9FXsFvth2O1RkZ5Qj9MjXEKESUEQVgMbLKCyk2h1XHPd7MX2FXmKiYcpj4KjX4uH+OGL6OpWLwu/n48PLiVogWBQmFnYbnChxH86RCpubMmrzqmv+ukr+Ig5jLIwn75taOvgNZqURGz/zAryzwIrnOcvxQ0BlUuWsxDTG769EBV50l66MWeNJiWClag02wwYVAa5Gib6B/Bj2fZ7119GeO848h1HjgVMuNyPf/oe9q0V31WW2S5lD3sfoxi0zvjNe3YHEV2MwS5/86ekHESnMR/AZ5/kUs9+MITdhjFiPGAW6z7JKxVXOw/N5Rg01zN1fZRvi8gfTFzlHDCcstrXhmSh5R9h4YyQNuNHg63RvFADduZ2g6iKTfo43ZpxxRhByXtzrGsbVDyHp0zPA5bsnBjnXLc0su8JnHL8N8w68i36wYjWUgCJc64sRkXPSbwXVbXAT+zusd3LdK2GjarN8XcukI80LDmlUbz/FBrfwusjuxjfQazrTK+5s38UMtDLkWGpZz4x27gzCpJkcYNJa77hNhFd/29pFVkv/0Z2WHSsSeNb/+BMkC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2eb85eaf-b6b5-4264-fcd0-08dd1df7983c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 17:32:20.6834 (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: 1WVESrAjKKLNpqi3heSzVIHNzE8q1vbmnMFXLugusfiBIpIwNS+NtgkBJbEqzjMyjz0FQnJaaEd4T8m9pL8m1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7756 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 --- change from v1 to v2 - Use *adapter = c->adapter - Use if (!i2c_check_functionality()) --- drivers/input/misc/mma8450.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 08412239b8e69..a1adb49fb5f33 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,17 @@ static void mma8450_close(struct input_dev *input) */ static int mma8450_probe(struct i2c_client *c) { + struct i2c_adapter *adapter = c->adapter; struct input_dev *input; - int err; + int err, client_id; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) + return dev_err_probe(&c->dev, -EINVAL, "I2C adapter can't support SMBUS BYTE"); + + 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)