From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 9C2D043934B for ; Mon, 3 Aug 2026 18:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782806; cv=none; b=V9EJ6GxLnHNhPufgILdQKL9t31ChFlyYs8PcmB5ZGwDQa5uDAmtlFUFoI0OBbmevW1QjXP4JPFrgW1mNhJdMAK5v5N9abfu6ybGPMBsWJlAAxQ6qjmd1bIx0vx9gx3wk5dLydeqJMXvxssz3gQooIyJp5D8xKrL1RazUVWKFjIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782806; c=relaxed/simple; bh=FLBZ6TUpfMBXlB7N0BVa7vU2Xr9/kJojTsuqYcBwngA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GTCjEI/s6njbgg1PqQVg5vMBHw5cGj4rc8fuJScFhK7oEY/evpNHHMA+WOf3m+8lxH74GYbsCeSj+lTtnzmUdl0n2zsdfaOePc2zjwH41qtXW74qCCSj+bgH7aD93X5u7IqnZPC8LR0ckWpRdhRAMkCO36iYVELI3K/mIT4UwU4= 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=F3S2ayFk; arc=none smtp.client-ip=209.85.216.42 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="F3S2ayFk" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-384930ca5e2so3158730a91.3 for ; Mon, 03 Aug 2026 11:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785782801; x=1786387601; 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=nlCI4/gle3R9IwS53kvCY4cjueCVDjt1k2gYqGOMeAY=; b=F3S2ayFkYSrOLutKodBQQBz/tdE97usQ4NB3iYYl4PQZYo5Y+nDiQ0+L+817rYK0nU wE3wR5/ZDSo5gGf9LejuS9Z9Trhj7tdGjy9R9bdk1C1+11VjLFG/gDMFxL8/APK7YY2J ILFyBm1yWJo6aFpJcWqBcsqIRa7Gp6Ib+QmmA/k0oprEnSnrMHLivcTjyMCA4lfxwxCq WALBLSc9N0Iu1vZiHwqm4pFLhOCiFKMFmhrA8TNkDZCpFvGO4nyRpuJG5uzHxrwOUGuC AL6QwdT37KpmHn3VAiumWLm23NhVn4/6b28paj7dnFfzEs2BsNKNW3SiOJQXbeXhrb6m Y7ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785782801; x=1786387601; 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=nlCI4/gle3R9IwS53kvCY4cjueCVDjt1k2gYqGOMeAY=; b=J77EDUUK/VAFpE7awlNaTfoJSUK9VV+qOeyyZ8tR37sCAjChBNk/Z1NQ5aGeo8ct0X fuc80t1/sWLFYirkqZvFaeaNnDMvo4k4hD8HzNRQLQNx3VbiY6eVmH/WtEbOoN7FCnXR XHnJY4NL/ev3NoWa6u1MIwYDopKYxEu8p16uXA+hN++jsewuj+VEb0Myq/d+99uKJPFy ZLgQPLVzzzT1MivjeAykuA4m7vFCebshl6TJeh+SKpVG1ZWFKK1SajLkb8cHMdfGjjdt bk/Sclas6tmMAZG3zKDQsp3KiIjVcZZHPBRMGZ/0hcQ7d7pFC929GPSwL3X+bptfDOcW trGg== X-Forwarded-Encrypted: i=1; AHgh+RprEOc+7oT4ul+gB70WQ6477foX56c5lmtXLYWU++24bICB75FmjpsfWgT/1fNC3UNdQqCrvlCwVciyAyg=@vger.kernel.org X-Gm-Message-State: AOJu0YwBt8X0TnvwQn+eYHlTbe05GwyLthbOdNzcyLwo0WtPsPW2AWhR twmKbIp1ye6z9MBO4sZarrVCOI5FtB8XbGgLphBxHlvxgwSDTEqHKSVB X-Gm-Gg: AR+sD11/V89GA83+/xw6o89qx6w6P9xV2Ll4PHCT3jeYd3XxGTQmAnlmMeP30mDzzXs gkBdX2KDGYhs9o/2Vd++/t1geglO0QSMgMckKj0XiMk/FYxk9UfHpC9P6j8SdcgaK6xpWYmvUth +SjqAXX+bD9XSnC4RfTgnhJaWV6Fm+qzd6M50FlPF1jiwTaPZPLo+BHNCzeIjhPGy6bliMvBctN 8KeZSxwxTnbDY6tMTCTVA9lxjQ9JQHkTrw00PVRwkK4CONZEQoJHGdjNdomOuwe2EG4txxWo9Z/ /NmRZ4AAgwt3eAcJ5AfAf6Nt79N1dLSgqX1hB3awRCpkUCwgLHIZnKkb+CG0BXODf9r/l0M0MlN kLGiNAb/7bcMu+1ogu3bko0FPZQUu/yPM6ag4g4GvDepXt/D7osMyACBZSB8w4oUXIjylmj1oi6 BXSTpCR25gpKE/st3TRHHgjyQPB/yClhZE3E3BU24NxWhIieYESPxSM5t24ndqVqNmoI7Bm5vHB Dwyok7kltrY853vRoPSh5cshqBjMnB6Y4da3ucC3weLR153vzQjmQq0PHOid0s= X-Received: by 2002:a17:90b:2649:b0:387:e0db:3d8d with SMTP id 98e67ed59e1d1-38fbc552923mr10107203a91.40.1785782801117; Mon, 03 Aug 2026 11:46:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 11:46:40 -0700 (PDT) From: Dmitry Torokhov Date: Mon, 03 Aug 2026 11:46:30 -0700 Subject: [PATCH 05/21] HID: bigben: 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-5-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() with HID_CONNECT_DEFAULT. 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-bigbenff.c | 89 ++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c index 9f05465358d9..3c87317ccc6b 100644 --- a/drivers/hid/hid-bigbenff.c +++ b/drivers/hid/hid-bigbenff.c @@ -366,58 +366,29 @@ static void bigben_remove(struct hid_device *hid) hid_hw_stop(hid); } -static int bigben_probe(struct hid_device *hid, - const struct hid_device_id *id) +static int bigben_input_configured(struct hid_device *hid, struct hid_input *hidinput) { - struct bigben_device *bigben; - struct hid_input *hidinput; + struct bigben_device *bigben = hid_get_drvdata(hid); + struct input_dev *input_dev = hidinput->input; struct led_classdev *led; char *name; size_t name_sz; int n, error; - bigben = devm_kzalloc(&hid->dev, sizeof(*bigben), GFP_KERNEL); - if (!bigben) - return -ENOMEM; - hid_set_drvdata(hid, bigben); - bigben->hid = hid; - bigben->removed = false; - - error = hid_parse(hid); - if (error) { - hid_err(hid, "parse failed\n"); - return error; - } - - error = hid_hw_start(hid, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); - if (error) { - hid_err(hid, "hw start failed\n"); - return error; - } + if (!list_is_first(&hidinput->list, &hid->inputs)) + return 0; bigben->report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 8); if (!bigben->report) { hid_err(hid, "no output report found\n"); - error = -ENODEV; - goto error_hw_stop; - } - - if (list_empty(&hid->inputs)) { - hid_err(hid, "no inputs found\n"); - error = -ENODEV; - goto error_hw_stop; + return -ENODEV; } - hidinput = list_first_entry(&hid->inputs, struct hid_input, list); - set_bit(FF_RUMBLE, hidinput->input->ffbit); - - INIT_WORK(&bigben->worker, bigben_worker); - spin_lock_init(&bigben->lock); + set_bit(FF_RUMBLE, input_dev->ffbit); - error = input_ff_create_memless(hidinput->input, NULL, - hid_bigben_play_effect); + error = input_ff_create_memless(input_dev, NULL, hid_bigben_play_effect); if (error) - goto error_hw_stop; + return error; name_sz = strlen(dev_name(&hid->dev)) + strlen(":red:bigben#") + 1; @@ -427,10 +398,9 @@ static int bigben_probe(struct hid_device *hid, sizeof(struct led_classdev) + name_sz, GFP_KERNEL ); - if (!led) { - error = -ENOMEM; - goto error_hw_stop; - } + if (!led) + return -ENOMEM; + name = (void *)(&led[1]); snprintf(name, name_sz, "%s:red:bigben%d", @@ -444,7 +414,7 @@ static int bigben_probe(struct hid_device *hid, bigben->leds[n] = led; error = devm_led_classdev_register(&hid->dev, led); if (error) - goto error_hw_stop; + return error; } /* initial state: LED1 is on, no rumble effect */ @@ -458,10 +428,36 @@ static int bigben_probe(struct hid_device *hid, hid_info(hid, "LED and force feedback support for BigBen gamepad\n"); return 0; +} -error_hw_stop: - hid_hw_stop(hid); - return error; +static int bigben_probe(struct hid_device *hid, const struct hid_device_id *id) +{ + struct bigben_device *bigben; + int error; + + bigben = devm_kzalloc(&hid->dev, sizeof(*bigben), GFP_KERNEL); + if (!bigben) + return -ENOMEM; + + hid_set_drvdata(hid, bigben); + bigben->hid = hid; + bigben->removed = false; + INIT_WORK(&bigben->worker, bigben_worker); + spin_lock_init(&bigben->lock); + + error = hid_parse(hid); + if (error) { + hid_err(hid, "parse failed\n"); + return error; + } + + error = hid_hw_start(hid, HID_CONNECT_DEFAULT); + if (error) { + hid_err(hid, "hw start failed\n"); + return error; + } + + return 0; } static const __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc, @@ -487,6 +483,7 @@ static struct hid_driver bigben_driver = { .probe = bigben_probe, .report_fixup = bigben_report_fixup, .remove = bigben_remove, + .input_configured = bigben_input_configured, }; module_hid_driver(bigben_driver); -- 2.55.0.629.g250fe7f194-goog