From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26BBA436BFE for ; Mon, 3 Aug 2026 18:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782820; cv=none; b=LgfqYD4dN/7HrhUr5BdFi3te3/tPnAGKQYoYGJU6E3RatdchXJjbZLPolWOhziRtzs+p8GHOjFY/C1BjnD6a6tACRqf4EIA0HFiDyj+YqNWLvtO2PTxx/zg9h4lCv+jCeR1o8IVa02x3umUsEa+KZhhCDGm3QUhYjOFGfqd5jZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782820; c=relaxed/simple; bh=bkkjuJ7kHovlBy2GQl50Xio+Ck7Q4NkLDSybgRgkKTQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XKs5H+frkWkYpZXBses4QsAS+hTslCv5+ydHyRS0XmqqUILHhyyHCRdzGFtj5E+HaqWQcjWQOwD8hT5cOdkbqEaeX45anktoiVpZQ8bYmz6z6p3QzGZSTn+VLa49A+36G4iFHoufblde6OilUrVZKrqC1XO6iLi7vWcx6jNpPhE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SDn9GZH8; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SDn9GZH8" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2cace91f112so41622395ad.0 for ; Mon, 03 Aug 2026 11:46:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785782815; x=1786387615; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mMeooT+Pd2wEyftNL9TbUExuIFr34iBpC5GZzR8qYww=; b=SDn9GZH8AF7tWgGkUBLPSHgFgyD7EBkNNjHYiDdgT6pDLHMfHEbneYcHCPz6k4dlQi fOrgQtcb9AQwMmYHPIv5auX+7pJCg6wniuJxXEf1ho1DBnCq2cKqyIW8DAlcSA+sODt5 8/Lkp0GlG8+w/ggt6QhYML/LDmkT9eKDXZUx+i4lSPmnSy8pc/zzh2H0h618pOxGutda xD6eBWZxF2gbISWE13ANQiWY42Mas8WOiGbBqKVxRsbA3YnSZOM/1r77L3+K36Ho9inr lE3LcfWhcRh2EKc2gwPCK/uwYVO6B6Do4lTgHhzSnbWYfq6ksradlqlMkyCIf2di5Jof P7iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785782815; x=1786387615; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mMeooT+Pd2wEyftNL9TbUExuIFr34iBpC5GZzR8qYww=; b=YJoNXZRnqt7HSAQxLcHvPBhe7tMZk3KxN/5AA8tMChRLi1bnqaP+p00RpWEKAViaeF mmDcqUh5s1ecKX11nwvU/ykhKqvqZWquVHo1Hs+W6ZlFSH1qaU50UMtZnzI7tiE853fY lS6egZDpp6aoBKZP94XLZ7dgb2q2JrYF4hPjR+BYxyX0LI83n05LRZUWct2kCppWGqCt IV2skwrCiRj585Xe8u2CxBJvG0PkqZgxAyrqwPWbd63lvdh+o9YS6zSguVOcF76XoLof dtt0TbWdPscpcMvhimnS7gD1PtRLjVCc6hvicFvIB0AGE/fHtbsCbCy5pTwbHJnhoy2m mNQA== X-Forwarded-Encrypted: i=1; AHgh+RpFSxcpSLxRWrCZC4B+wjTB2quWGxKo31IgHIhxdeqXkQWNNPPvUKutiyJL+RlDaACh5psKBsQL2vp4du0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9sTV1jrdPNIAqQNzck8BJC2PNGOQDvridVPhMGX3cXvXxLtmP BNdql2sP+6YlfVteYM1Xk6gxah3XONVhLOhCmNDH0OxacpUC5oEw51tr X-Gm-Gg: AR+sD10GzBWMbBVmFeM44MkVedlIFa4jzUufmvDxonaFs1DzuG/3qIUTvBKQ4aJfT85 otG7VWEcBsdhyhBCPKDQdQxlppHSAxdtpDYbkocA5GlLtgavKc+BcFmZZ4Be9Asjd9UcsO08BS0 8WmWyBu9rrD7yHU9f5s6iFpz7ZCQ6l1IIElZUPofUjgh7EJCFTUuxKRP9Hf6KxNbvC+JDcb/1Rn TPjYlcCMsSDKXJbZuvamgYZ3Zrly2hDXCHznQviYpEp8kA5xagHzX8VJypEQtPqN4DxYql5K/hF qLT2MZ59Be8hA61b01jW+HOHPeQnhyV8FxV5+G9et5a/67o8M7aAZePW4k/o3NTy86cp2XTkLKW S1p1hrlZAw93Wr1EULjuUNuc+fut+SxznQpcO8RID4So0W1YL6gnczVcp1ZifpkKe4ok5GcwBpB a6/fDwZwZNmANg6Vl20mOQtKYqrBQlykqW8UB+bXtzOYfkkZq0VgiXioEhGvVm2zZaewsYm6bUb 8XWcm60IL06QHq4MlDv73VHLtIUIyu55vw+BO8uSANVdNKIQSjJXFYKpCnCs346 X-Received: by 2002:a05:6a20:a114:b0:3c0:9c19:65a3 with SMTP id adf61e73a8af0-3c92a98cd35mr11005065637.75.1785782815610; Mon, 03 Aug 2026 11:46:55 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:d109:cdba:8a20:74ad]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13fab24ec10sm33935472c88.6.2026.08.03.11.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 11:46:55 -0700 (PDT) From: Dmitry Torokhov Date: Mon, 03 Aug 2026 11:46:40 -0700 Subject: [PATCH 15/21] HID: thrustmaster: move FF initialization to .input_configured() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260803-hid-ff-input-configured-v1-15-1dc9bbacd88c@gmail.com> References: <20260803-hid-ff-input-configured-v1-0-1dc9bbacd88c@gmail.com> In-Reply-To: <20260803-hid-ff-input-configured-v1-0-1dc9bbacd88c@gmail.com> To: Jiri Kosina , Benjamin Tissoires , Jonathan Corbet , Shuah Khan , Julia Lawall , Nicolas Palix , =?utf-8?q?Filipe_La=C3=ADns?= , Bastien Nocera Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, cocci@inria.fr X-Mailer: b4 0.16-dev-b242f The driver currently initializes force-feedback in its probe() function after calling hid_hw_start(). This is racy as the input device is already registered and visible to userspace at that point. Move the FF initialization to the .input_configured() callback to ensure the device is fully prepared before registration. Assisted-by: Gemini:gemini-3.1-pro Signed-off-by: Dmitry Torokhov --- drivers/hid/hid-tmff.c | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c index 423f395d01ac..0ed152e0dba9 100644 --- a/drivers/hid/hid-tmff.c +++ b/drivers/hid/hid-tmff.c @@ -115,22 +115,25 @@ static int tmff_play(struct input_dev *dev, void *data, return 0; } -static int tmff_init(struct hid_device *hid, const signed short *ff_bits) +static int tm_input_configured(struct hid_device *hid, struct hid_input *hidinput) { struct tmff_device *tmff; struct hid_report *report; struct list_head *report_list; - struct hid_input *hidinput; - struct input_dev *input_dev; + struct input_dev *input_dev = hidinput->input; + const struct hid_device_id *id; + const signed short *ff_bits; int error; int i; - if (list_empty(&hid->inputs)) { - hid_err(hid, "no inputs found\n"); + if (!list_is_first(&hidinput->list, &hid->inputs)) + return 0; + + id = hid_match_device(hid, hid->driver); + if (!id) return -ENODEV; - } - hidinput = list_entry(hid->inputs.next, struct hid_input, list); - input_dev = hidinput->input; + + ff_bits = (void *)id->driver_data; tmff = kzalloc_obj(struct tmff_device); if (!tmff) @@ -204,35 +207,13 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) return error; } #else -static inline int tmff_init(struct hid_device *hid, const signed short *ff_bits) +static inline int tm_input_configured(struct hid_device *hid, + struct hid_input *hidinput) { return 0; } #endif -static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id) -{ - int ret; - - ret = hid_parse(hdev); - if (ret) { - hid_err(hdev, "parse failed\n"); - goto err; - } - - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); - if (ret) { - hid_err(hdev, "hw start failed\n"); - goto err; - } - - tmff_init(hdev, (void *)id->driver_data); - - return 0; -err: - return ret; -} - static const struct hid_device_id tm_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300), .driver_data = (unsigned long)ff_rumble }, @@ -261,7 +242,7 @@ MODULE_DEVICE_TABLE(hid, tm_devices); static struct hid_driver tm_driver = { .name = "thrustmaster", .id_table = tm_devices, - .probe = tm_probe, + .input_configured = tm_input_configured, }; module_hid_driver(tm_driver); -- 2.55.0.629.g250fe7f194-goog