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 32FF1443AA2 for ; Mon, 3 Aug 2026 18:47:02 +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=1785782824; cv=none; b=MRgzia6OSpSWhCU/lXDpo6FT609bS/4bu4vPLO1DP4PHQnMb2Hik/PGFPP4hZ3OGio6+G9TToW7tPo0TrrBVfiqDlthCX38kHkRNkgpGaFnwHT/ke6NwiSOhjfsnIUM/ae8mG9ZD2x4hDLiIP9MCIcZlfvd23scuH8yP4if0n+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785782824; c=relaxed/simple; bh=sX1u2I9KlZuUAyIWLr1DKTH/D+67bak6JQXKiLEKJ0g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B08Hu6E8PBzwXiSzz5xOfX76DWXNXwg/0h2ZSVCqEqHA04o0UQvVIlxSsyMs7lg3KiItTKPFntc8pplGUzaVYE+obJ5RjchA7hty04p1s9+2lgfcSSebDj+1y+qbGmLEtcGfzXzUxTer+xa+AA6DH3g4lL05P9atlfzdQjPExis= 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=rnZMnVqa; 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="rnZMnVqa" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-384930ca5e2so3158972a91.3 for ; Mon, 03 Aug 2026 11:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785782821; x=1786387621; 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=MbT2WXShN1lekSN2/J4SPsyEo8OMF/+Z/0XrCjyCo/Q=; b=rnZMnVqaMPd+QWWs0GR0M62yJYxeAzwRxpZuaoIRHYGVqFKLQBbGyz2vkdmF25m3g8 V7JSpL9eX8jsLLVydLZ1+v5dKa+KOMJnNmm/0vHaQcyHtQs8EtkezaPPyDUNK1BNw3gN c2hrM9Iabeu0J/6Is56LjRXOfrL4o09kZKoK/PkuF6OUkycL3dfFO2oTfPxuFhmA0wSK BNmPPdzoptlVm5j8fuxXVarzqpwZLZ3dOiQpzGI1L1xjUJXcUixATT9Iyx/Ic5I6eodq h/ZRVrDAsPeKrRaJcCSTeqrAv6ZhhRRSl2stK2kV5vU59Nqg7A/iJ0IOde6H3Sg7DhII n9yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785782821; x=1786387621; 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=MbT2WXShN1lekSN2/J4SPsyEo8OMF/+Z/0XrCjyCo/Q=; b=JkPgQtphuIrS4pPcYV99wnGCMyhGWcgiNarRo+jR+3/tFU+jBamUL8h1LiePqm6OZN 0thr16G1BTp2alN7PB+Agym1r2IyEyCHneoYg9h0fdXlk9O6WBVF5Qg3Ov2776rWSkNy 3hRNK5cSLXGbU+WeP4irbYiZ5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ed59e1d1-38fbc4cb98amr10426103a91.20.1785782821239; Mon, 03 Aug 2026 11:47:01 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 11:46:59 -0700 (PDT) From: Dmitry Torokhov Date: Mon, 03 Aug 2026 11:46:43 -0700 Subject: [PATCH 18/21] HID: smartjoyplus: 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-18-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-sjoy.c | 83 +++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c index 963c45113204..193ab2a6146e 100644 --- a/drivers/hid/hid-sjoy.c +++ b/drivers/hid/hid-sjoy.c @@ -48,68 +48,56 @@ static int hid_sjoyff_play(struct input_dev *dev, void *data, return 0; } -static int sjoyff_init(struct hid_device *hid) +static int sjoy_input_configured(struct hid_device *hid, struct hid_input *hidinput) { struct sjoyff_device *sjoyff; struct hid_report *report; - struct hid_input *hidinput; struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; - struct list_head *report_ptr = report_list; - struct input_dev *dev; + struct input_dev *dev = hidinput->input; int error; - if (list_empty(report_list)) { + if (!list_is_first(&hidinput->list, &hid->inputs)) + return 0; + + report = list_first_entry_or_null(report_list, struct hid_report, list); + if (!report) { hid_err(hid, "no output reports found\n"); return -ENODEV; } + if (report->maxfield < 1) { + hid_err(hid, "no fields in the report\n"); + return -ENODEV; + } - list_for_each_entry(hidinput, &hid->inputs, list) { - report_ptr = report_ptr->next; - - if (report_ptr == report_list) { - hid_err(hid, "required output report is missing\n"); - return -ENODEV; - } - - report = list_entry(report_ptr, struct hid_report, list); - if (report->maxfield < 1) { - hid_err(hid, "no fields in the report\n"); - return -ENODEV; - } - - if (report->field[0]->report_count < 3) { - hid_err(hid, "not enough values in the field\n"); - return -ENODEV; - } - - sjoyff = kzalloc_obj(struct sjoyff_device); - if (!sjoyff) - return -ENOMEM; + if (report->field[0]->report_count < 3) { + hid_err(hid, "not enough values in the field\n"); + return -ENODEV; + } - dev = hidinput->input; + sjoyff = kzalloc_obj(struct sjoyff_device); + if (!sjoyff) + return -ENOMEM; - set_bit(FF_RUMBLE, dev->ffbit); + set_bit(FF_RUMBLE, dev->ffbit); - sjoyff->report = report; - sjoyff->report->field[0]->value[0] = 0x01; - sjoyff->report->field[0]->value[1] = 0x00; - sjoyff->report->field[0]->value[2] = 0x00; - hid_hw_request(hid, sjoyff->report, HID_REQ_SET_REPORT); + sjoyff->report = report; + sjoyff->report->field[0]->value[0] = 0x01; + sjoyff->report->field[0]->value[1] = 0x00; + sjoyff->report->field[0]->value[2] = 0x00; + hid_hw_request(hid, sjoyff->report, HID_REQ_SET_REPORT); - error = input_ff_create_memless(dev, sjoyff, hid_sjoyff_play); - if (error) { - kfree(sjoyff); - return error; - } + error = input_ff_create_memless(dev, sjoyff, hid_sjoyff_play); + if (error) { + kfree(sjoyff); + return error; } - hid_info(hid, "Force feedback for SmartJoy PLUS PS2/USB adapter\n"); - return 0; } #else -static inline int sjoyff_init(struct hid_device *hid) +static inline int sjoy_input_configured(struct hid_device *hid, + struct hid_input *hidinput) { return 0; } @@ -124,20 +112,16 @@ static int sjoy_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; } - sjoyff_init(hdev); - return 0; -err: - return ret; } static const struct hid_device_id sjoy_devices[] = { @@ -165,6 +149,7 @@ static struct hid_driver sjoy_driver = { .name = "smartjoyplus", .id_table = sjoy_devices, .probe = sjoy_probe, + .input_configured = sjoy_input_configured, }; module_hid_driver(sjoy_driver); -- 2.55.0.629.g250fe7f194-goog