From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 12CC143801C for ; Mon, 3 Aug 2026 18:46:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782804; cv=none; b=IY1ztoi4NT454I43EO+TrjGeiwqzJxGxLVeK/2htfKUeOaFiHcTqYURIu0yLdHbLs5G9c7jNI2OgJSbFosKyZaf0HbGeBZtM6yolCFctUMdBEYpPoyze/VPHeVQC/6+pQ7rUw2JEFT4bCH4DFAdt5YQ4qoTGFG0obCtZ9eWhZjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782804; c=relaxed/simple; bh=zxac0YZ+UVGUyIsLRlzYrg6jB0A4yFDf8Ymaifq3hLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aW9gV0m7zEBHexmbW0wNn+sanfkJGB0Ojvr0K5aZS0Lxkx9ucxiZ3THGMHbwg332A9xObv1LjJEm9i7wiE1+tU5jmKdMnFMBDBqz//8yzEf3/ofGDYHUDH2cjSYIqo0wwa24w18ar2qY+yCWQulJ2tugF+SH2Z/2yIQYxdE3DpQ= 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=faOe3ROc; arc=none smtp.client-ip=209.85.210.177 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="faOe3ROc" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-8487b7b3fc8so4363471b3a.3 for ; Mon, 03 Aug 2026 11:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785782800; x=1786387600; 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=Yfk1wrUGljf1bo39RPlNvsXr+Q+XQylnHMnMfOANzM4=; b=faOe3ROc7KpPbqp6++9+I9YT4D834TCPYeXkF2qMJu7G0GNgk2reJ4xtMyYQ4YLD28 mR7x4g9mSp6YAxNcIZkd3jdjGyiPQQ2LXV1czD4y1dsINbD8NObkangPAQ5V4D2m5RnZ pgY4FWpWS6ltNtiGznl0ONEi9Ou9618Z1OdScMIdmauCJs5EoNGe66JR1rnNXRInr/g8 7xy5cTTy9jdwXs1dfy+473mA6vjmM0amjrckj1fzYK+0XcNFNNSaTOx3NUUl/2PR5A/S pbxUVauJCHQpTJXVNGpU8FhMi54QR4nwTUn7zAbtW7Ww3Jc6AurgyCswLEdgbImYfCKU 7x0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785782800; x=1786387600; 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=Yfk1wrUGljf1bo39RPlNvsXr+Q+XQylnHMnMfOANzM4=; b=JmJyuvKa8ry2FwZGFLX+23pDuiJ8BPf216fT0ji7RYbEO4NBI1QuXn30vhCkScVKlD XK2HWRIN+x3oYEtoFBtUZ7p4I3jNfV2KsZ8wunNyqBZhkXoIGvCcJYM74Zwqk8MBUq/p bpkSZAVGk1iRBDjZYpApFKsQVkmmzs2vr9JpW2AnKTlGS8kXIdPB2q/mEMyaPaxfrBWN 8OHi2ma4VskVvsMfjymuZd2dEHch+UWufYF4S3rEXhfD1+kmXcycjsL5TJ9L02rMY9K6 8ClF1nYMCLcoovsuSkH1lCiDUyV5bV6LcEUrsdDWBrdT6ps4DV3orauaECM6GxEu/mUB h56g== X-Forwarded-Encrypted: i=1; AHgh+Ro2Hrryw6/epGWzmeqHxm6FKi/Iry9Eil7a4ImRkYC/4Cf7RGn9CJtdsjZyo4+mZi6StEZQ3RqrRkAUwck=@vger.kernel.org X-Gm-Message-State: AOJu0YxXNpSqbAhUOZlvYuODOTLc0HL58oPl3aLuYbkTnS2vDUt3COPf yzHAvZynx7gdTb+ye2ip/10qKwgk+afSo+XMVE+l4WTVE17Hp3sMeEGy X-Gm-Gg: AR+sD10vJdPgAb+YCmibnwCVTqqp1mLde9Ndgss+frre/gAQJA/fow4RGtWfASfczVO vUHYWbGkDHaPdyawMS2EN24lzgc/9jU4xvMFa1fyMsYvg0/luJhOVS1iWBAh63Sl2XWpvn3qr4U 51VrgHvfmeQui+EUwU++9TRIB1gF6oA+b52ffpqnS3k4TZYXm6SrsB6yCKo+76xZu07tbia54BX NqB0T+VE9n8sVxQmty1IXVBq70lHOaJlmkJ3l9GVR5pX/+usTaRw9r+0ruXFX/HFjP/kK/dUAa2 pso12ATK/B9AHX+Me+nR8EgRybYJNeBtArMvqdCM9SdapUWGg+bII2UPqsV8T7DYS7cq5EqzFl4 0MFU7dzArhmsIBLY/rxH2+Ic86JSmzYPwe7iqXaIMzNHV30atvTMaV43vtyYLV22a0ibCLwrCQm 3tVZGzbixXVHLfOY9X9g17sypxYYPZSway1dKYlIyKDmL/epgyrgw5DS94dHyjyM0a9fL8i3b5Q Lw0+rD7rzeo/yt6ZeAs/s5eW4pzNqeeteisXYVh0/5uOlFOD20B X-Received: by 2002:a05:6a21:7a82:b0:3c3:652c:664e with SMTP id adf61e73a8af0-3c92a98f2camr11892049637.69.1785782799808; Mon, 03 Aug 2026 11:46:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 11:46:39 -0700 (PDT) From: Dmitry Torokhov Date: Mon, 03 Aug 2026 11:46:29 -0700 Subject: [PATCH 04/21] HID: betop: 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-4-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-betopff.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/hid/hid-betopff.c b/drivers/hid/hid-betopff.c index 8a7fe895926c..f802046a688a 100644 --- a/drivers/hid/hid-betopff.c +++ b/drivers/hid/hid-betopff.c @@ -52,31 +52,24 @@ static int hid_betopff_play(struct input_dev *dev, void *data, return 0; } -static int betopff_init(struct hid_device *hid) +static int betop_input_configured(struct hid_device *hid, struct hid_input *hidinput) { struct betopff_device *betopff; struct hid_report *report; - struct hid_input *hidinput; struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; - struct input_dev *dev; + struct input_dev *dev = hidinput->input; int error; int i, j; - if (list_empty(&hid->inputs)) { - hid_err(hid, "no inputs found\n"); - return -ENODEV; - } + if (!list_is_first(&hidinput->list, &hid->inputs)) + return 0; - hidinput = list_first_entry(&hid->inputs, struct hid_input, list); - dev = hidinput->input; - - if (list_empty(report_list)) { + report = list_first_entry_or_null(report_list, struct hid_report, list); + if (!report) { hid_err(hid, "no output reports found\n"); return -ENODEV; } - - report = list_first_entry(report_list, struct hid_report, list); /* * Actually there are 4 fields for 4 Bytes as below: * ----------------------------------------- @@ -104,6 +97,7 @@ static int betopff_init(struct hid_device *hid) if (!betopff) return -ENOMEM; + betopff->report = report; set_bit(FF_RUMBLE, dev->ffbit); error = input_ff_create_memless(dev, betopff, hid_betopff_play); @@ -112,7 +106,6 @@ static int betopff_init(struct hid_device *hid) return error; } - betopff->report = report; hid_hw_request(hid, betopff->report, HID_REQ_SET_REPORT); hid_info(hid, "Force feedback for betop devices by huangbo \n"); @@ -130,20 +123,15 @@ static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id) ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); - goto err; + return ret; } - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (ret) { hid_err(hdev, "hw start failed\n"); - goto err; + return ret; } - - betopff_init(hdev); - return 0; -err: - return ret; } static const struct hid_device_id betop_devices[] = { @@ -159,6 +147,7 @@ static struct hid_driver betop_driver = { .name = "betop", .id_table = betop_devices, .probe = betop_probe, + .input_configured = betop_input_configured, }; module_hid_driver(betop_driver); -- 2.55.0.629.g250fe7f194-goog