Message ID | 55d7a712-5862-4d51-9ec8-7479dce15f78@vigem.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp140461wrn; Tue, 13 Dec 2022 06:09:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4KjMCofG3vGuBALBbRclIMTtofNM7kX54xbN8GewiaYACU9FzVl1LAMb7y3WUiJr7IeXR4 X-Received: by 2002:a05:6a20:9f4a:b0:9d:efbf:6618 with SMTP id ml10-20020a056a209f4a00b0009defbf6618mr26327221pzb.38.1670940563379; Tue, 13 Dec 2022 06:09:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670940563; cv=pass; d=google.com; s=arc-20160816; b=Vmp11dh0LR+FdMhSS7r5/irCtMGHb2aCHJ5G+VUgdQW9NW/Q8X5VmPYU5SvHp4hii9 VgkVuzlUmIGTLWt5muofvo30nl34J15ckE/FIjDCti3z3zE1I4TswOv4yXqMTX3q0HDR 9CJvNkbvLcda95tE6kX+ph6TgPa8V9BsJ/vuIFlgLDmxI1GBDrCIOqG7f0G49Sko3NBU /AfknGfVnF59Yv3qgyUUwZiQ5Mh0Hd/ddhlDZq0gWBY7ureimt2clw0QxG1FsoA6iLGq Rc7CZZMMhXNaeNLHqiGW67fSqncu38EgdfchaTn1KHZNzorAyTmFdJK3R96zzWVkzMuk p6uQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=+GtkjTxN5cDQ4ou9RHv6Ceh1CDyQGaQ4mGN7Q76yGpY=; b=vOF9eSvAM9NFkSHcPixe5uoNoCFTlmWWhqPyl7ZhRl5XW56rWIlDd86i/Olxtj+q6L Ebbc9vW+r1QxDkJUfK7R3j65pD1v7JjgBtuqYDLfoetkCgY8DX4+NgZhDOYUWsMzvX1n gEmVWa7aMW9a01wGxRdDLpShs4bvmmCoGJaA1npjcX1955YU+IU3wi7zFPmeSQ3ai9Yg SWI7aMc2cUVBpvErenXHzO3Hvr18MfVhHiJp/5Pbnb9wy8QnmhFLQhdc1zonyTirF7mt dSFobPTCePqQoetY30ersuEyaxdf14dQXnplyyEXDq0W7H/BNnE//Z9hGk0wEg9OfgVi qQHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vigem.de header.s=selector2 header.b=ka3VDLt8; arc=pass (i=1 spf=pass spfdomain=vigem.de dkim=pass dkdomain=vigem.de dmarc=pass fromdomain=vigem.de); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n27-20020aa7985b000000b005631dab9f69si11968342pfq.301.2022.12.13.06.09.07; Tue, 13 Dec 2022 06:09:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@vigem.de header.s=selector2 header.b=ka3VDLt8; arc=pass (i=1 spf=pass spfdomain=vigem.de dkim=pass dkdomain=vigem.de dmarc=pass fromdomain=vigem.de); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235786AbiLMOFJ (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Tue, 13 Dec 2022 09:05:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbiLMOFE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Dec 2022 09:05:04 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61CE0634B; Tue, 13 Dec 2022 06:05:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MAaH39G3xuqnUOEVy0sqMD1fDjtb97Oie70HUzhN7d5nnMO+63u2OsSm7A07haVW91QhE7e6JQoUIdUcw0kiMcLCogl30XQ+/rdIpIfijBaZ4q5EHVMcTFPQAF6MMyD686eTAZh9hZewtLJU23ARJTIsxMfDgJtixjGgqMOJ2xOR9Dve5c/k5GQ6vJfXHsLAlJvJ12G9WO9BJTuNd6eWDiGrw/l6zRNBla0VzZJdYvSAyv1K4AzRLu/3WI7tSLfNAPzbnGIlLfyrZbWLlYZcTHcJw4VK8R8SiW3uuSnJSKfc3hWnkrk1QFXqZXanKShL3SRPnIrv8HaBP2d2irUyaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=+GtkjTxN5cDQ4ou9RHv6Ceh1CDyQGaQ4mGN7Q76yGpY=; b=nJLsjNAj13SqoF9kjXgWAg9WpagtQTiV0OHYrF75bxDzuQ0TAuSjY5xiO7ENYlnnQUbwfM+UbUZINoffVbVM86at+81iJV9nrom6fSBOKVjR+rdl7TDKDNpNaJjvrUkccZjbyFidByBX2DYDW/+BT7uN6NIEbrGxIpG3Gb6TJsdLaTNu1NbSaNwC1J5fNd/Wp6i5xm6bAc8CRxOPP/7MtqtwY4DNy1YaVAymyIAuHofUpYVSN2r7nnCGjfLYPPCxd9a1KQdyDB4N8doBrviaZS0ZQTgSrrXBz/wZfxUm6Htw3s29Ggwf655asaV2U8HgQi2m6d0FiJuI0NBJNRYbjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vigem.de; dmarc=pass action=none header.from=vigem.de; dkim=pass header.d=vigem.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vigem.de; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+GtkjTxN5cDQ4ou9RHv6Ceh1CDyQGaQ4mGN7Q76yGpY=; b=ka3VDLt8c8YUgCOAPNv2e/7+NlJNE7DyONZmC/AgTGXNQWO3LFtK0PVyOGKalyKecRCyxgtdJSSkcPvSujpvreHd1kkuGew9rQF/uomVnZXQadRcUvgU7xLE1EYcV9PH0BC0DhDxHvlSO0cLQCZZWkNJiWOqW1Fmn2dsBAI4GuE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vigem.de; Received: from DU0P190MB1930.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3bd::20) by DB9P190MB1843.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:37e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Tue, 13 Dec 2022 14:04:59 +0000 Received: from DU0P190MB1930.EURP190.PROD.OUTLOOK.COM ([fe80::ece:ddee:45dd:492]) by DU0P190MB1930.EURP190.PROD.OUTLOOK.COM ([fe80::ece:ddee:45dd:492%4]) with mapi id 15.20.5880.019; Tue, 13 Dec 2022 14:04:59 +0000 Date: Tue, 13 Dec 2022 15:04:57 +0100 (CET) From: =?utf-8?q?Sven_Z=C3=BChlsdorf?= <sven.zuehlsdorf@vigem.de> To: Rishi Gupta <gupt21@gmail.com> cc: Randy Dunlap <rdunlap@infradead.org>, Benjamin Tissoires <benjamin.tissoires@redhat.com>, Enrik Berkhan <Enrik.Berkhan@inka.de>, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: mcp2221: fix probing of the I2C bus added by hid_mcp2221 Message-ID: <55d7a712-5862-4d51-9ec8-7479dce15f78@vigem.de> Content-Type: multipart/mixed; boundary="8323329-164564908-1670940298=:103531" X-ClientProxiedBy: FR3P281CA0192.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::16) To DU0P190MB1930.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3bd::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0P190MB1930:EE_|DB9P190MB1843:EE_ X-MS-Office365-Filtering-Correlation-Id: 5096fa8b-e5f6-44ed-c2f2-08dadd130518 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Evbv/K0QaO6a10HYMXGEHq3rvacSWDRoPc4PhgnCFjXUmMACkWml8Hl57NNxLm0cSnrzefTAliVD8RC+WCcl2SD0gCQsxSYMQvSO1cCHXj5sOcN50Ti1qMObXJO7BSdTjtA7L2l30kpefTKJlS9jAz60jD/IebJUbuXxygzW2jwlVtEppNXdvCp4ZiNLkqDeBrUTRi7qGENCT+rfIw5DeHW3HIDPUCPVy5cMErs1DkRrsU0fNcCQp0OSssuXPMm36k6SNoFZmjrsarPwbFK3/U3+4OLWN6KVdo89OI3UoFRvzgutGCrfUBO8D+F2bmKRcVXP97gbm2YbZJhLF9kD4EQTgyhj8xE9kiXdFUAquUyFs9K7z3mABeDL53UrDGpxu/UXssYr4HxBK+tDprTlXVRouiVw6Ug0vUDl+C6N34vtqVYG4SeTcMJx946vSvvjddu13ddH5vO7D+MyvfJS1zVZE6GPA1Mb0Bfb+DdJFVz2gE8SmQehRx5l5z9XomvldrcKwsayCKa6A6Cw60c5DYvwQ5IRbamgI/t7/AAR7M9gKpX/cADYdpFO0Dsuov/+t/vZpFnuB0Smwp3J96rxHfILjgWDltzXjjp+/TSRrok7E1zUrZgFIH/YCGhn1R+eoB8C1XQPMcONwwoFrwCAa20pgqKCNI8CEB3gJILQo3HUx4zO0NfTdkF8fJJ1NwVZmBoJYJNNBlBAbNuNKveYB9+vD2fHGA3bZ5GJuIJ7538= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0P190MB1930.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(366004)(346002)(39840400004)(396003)(451199015)(38350700002)(31686004)(5660300002)(33964004)(6506007)(26005)(86362001)(31696002)(2906002)(41300700001)(36756003)(52116002)(8936002)(66556008)(8676002)(66946007)(316002)(66476007)(4326008)(38100700002)(478600001)(186003)(83380400001)(6486002)(53546011)(66574015)(6512007)(54906003)(6916009)(2616005)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RTP/gynmWUAXZZzKZ4u1dM/Miizk?= =?utf-8?q?dZe+ZWD5vH4IUATE2j82LtSy5WcgvQ1Zs0Y51WlucnbMiwrYtbJXClFHRIeyDhZlP?= =?utf-8?q?zOO8BD//moEKTtJUG8UCnTJG2K6xv6ovhbtJueDFBiFXlSzEOSEbXAqmIgEqzqg4y?= =?utf-8?q?aXf4U0BAG+sbbrCjOKjFz+xFbRjDUlP3LrtrjiKi1cyyaOsIYFlp85LPBos9N40/I?= =?utf-8?q?lUuf+Xn6eNMg6n1tQB75ywY1JXtVmsrXZZNeTgO3Q6nX/bLHZGhPn7J7gtV3EEBaX?= =?utf-8?q?Kl/ou6aRV0Bo0rGuT+6xWTLAuxlIwasICglWS4rl6yly2ZmpTNJPiBvtJGkoiNRgw?= =?utf-8?q?XFWLvTvsrKhSo4qaj4kLYgDcsMninqr6uHXCgBnMuNA9SEFsZ+kS0Xj2xTrogYx17?= =?utf-8?q?9xM9Vu0zi04ns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LnLrv4M5Ctcpzdz98H9o+H3uSN6hAoDqiqFgKtkNAEJzs4hdm6VS?= =?utf-8?q?IN9bMLUfKalGXpTJAyC62eWgi+hzQbXh7lajd/nurNR6rQl6wWVNodHMw9fbEgn3o?= =?utf-8?q?WTjMsSAFjEYayT96yWRcDsTCjiEtuJC4UcFnWWoF+MhkCYMuUTg0ZvDJijnyiuhls?= =?utf-8?q?he9BgMFsEWNwgqhvHUHLPufiyD5QCmg8ejs3Sjy3j+OlCY/tgr6xi5efKyftt5Ws3?= =?utf-8?q?fBFJ/1y+AD6g8pHIHL43OUY+MN5tA4VCUA=3D=3D?= X-OriginatorOrg: vigem.de X-MS-Exchange-CrossTenant-Network-Message-Id: 5096fa8b-e5f6-44ed-c2f2-08dadd130518 X-MS-Exchange-CrossTenant-AuthSource: DU0P190MB1930.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2022 14:04:58.9253 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: dc3cc44e-876e-4b98-9250-42df44be4933 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RqAflhm7f/9ynpncF9nSUAJfbyL6l3FJWUcPcbNCsqG0qxOE3rGaAAaEKyNGomE0gBHnHcWyBeJ/b1WdiZK8CODiuuQ+TYGJ7RSIQr2MXC8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1843 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752108172101343018?= X-GMAIL-MSGID: =?utf-8?q?1752108172101343018?= |
Series |
HID: mcp2221: fix probing of the I2C bus added by hid_mcp2221
|
|
Commit Message
Sven Zühlsdorf
Dec. 13, 2022, 2:04 p.m. UTC
From: Karl Georg Esser <kgesser@vigem.de> Date: Fri, 9 Dec 2022 16:17:59 +0100 Subject: [PATCH] HID: mcp2221: fix probing of the I2C bus added by hid_mcp2221 As soon as the I2C driver part will be enabled in mcp2221_probe(), the first HID reports might be exchanged with the chip due to other drivers probing for their devices on the just added I2C bus. HID I/O has to be enabled explicitly during mcp2221_probe() to receive response reports. In addition, the I2C bus' adapdata has to be set before any use of the bus, otherwise mcp_{i2c,smbus}_xfer will attempt to dereference a NULL pointer. Fixes: 67a95c21463d ("HID: mcp2221: add usb to i2c-smbus host bridge") Signed-off-by: Karl Georg Esser <kgesser@vigem.de> Signed-off-by: Sven Zühlsdorf <sven.zuehlsdorf@vigem.de> --- drivers/hid/hid-mcp2221.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index 5886543b17f3..35b7d6939b38 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -324,6 +324,9 @@ static int mcp_i2c_xfer(struct i2c_adapter *adapter, int ret; struct mcp2221 *mcp = i2c_get_adapdata(adapter); + if(!mcp) + return -ECONNREFUSED; + hid_hw_power(mcp->hdev, PM_HINT_FULLON); mutex_lock(&mcp->lock); @@ -433,6 +436,9 @@ static int mcp_smbus_xfer(struct i2c_adapter *adapter, u16 addr, int ret; struct mcp2221 *mcp = i2c_get_adapdata(adapter); + if(!mcp) + return -ECONNREFUSED; + hid_hw_power(mcp->hdev, PM_HINT_FULLON); mutex_lock(&mcp->lock); @@ -1148,12 +1154,14 @@ static int mcp2221_probe(struct hid_device *hdev, "MCP2221 usb-i2c bridge on hidraw%d", ((struct hidraw *)hdev->hidraw)->minor); + i2c_set_adapdata(&mcp->adapter, mcp); + hid_device_io_start(hdev); + ret = devm_i2c_add_adapter(&hdev->dev, &mcp->adapter); if (ret) { hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret); return ret; } - i2c_set_adapdata(&mcp->adapter, mcp); #if IS_REACHABLE(CONFIG_GPIOLIB) /* Setup GPIO chip */