Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp579725rdb; Mon, 15 Jan 2024 06:58:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IE20hnZEC2Mxp37XNQzMlclpBk3irlJkr0hrO0KMTtpI9Iie1wDP5WFBFwaV1s6AQqq87nb X-Received: by 2002:a05:6214:1253:b0:681:1322:5f with SMTP id r19-20020a056214125300b006811322005fmr7136085qvv.58.1705330696533; Mon, 15 Jan 2024 06:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330696; cv=none; d=google.com; s=arc-20160816; b=P80Ra379Mqk/I4X//ujR0GcqzCygH9EAzw7159mpk6DqVkuOkcYkj88I+W1ssxoG6O g7+T2myTRAmCbcB1VRIMGnlaRzeNf21Q0CAsAFq59u3XSS7puq75TOS+WCppxG/13AbG EgTvX2EBEQH5A2c60qw6rh6j1cHF6U3sRF2RaJrhnOAwuZ7R9o+okKfKNzIfsTb20WgO duabSyR3cAx3S8KplMHQsQhaHh0Jc5DgT0OgfUjDTgPITw34jt8rH7OAnAlh0zWkEpWm ZfZUd6MHYucboFl838D5vOf//Z91c2opRcrIfDEX1S/oWc63R/Fkft923f5brxlY4XQG dAuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=r4qaaG4IzmgUAqzp5BVDGbgAyK8rJWxpNKdkgUFkw7w=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=U+7aKhgoy5tlJ+IlTjJqRhQYl0sr5yLa8zr434UdbwhpzgpvQsIdoPDBmwA8uZfywE qHD8vygvH8+d/pHW0yhGLB07RYplTGF02b2naSfxDKMmWpe/aUNe7qYyjwjYmKkHL7kS JjB4M4n71R49qMJ1OC60fojN9tHNk74CoBirl/g4s0Kg2okh89ztp5Qrf3aqrP4NG5iK Zz8c/iZcetd/nTakY+gnFvuj9JicUYe9W/DhS3i1s5WjI21XcSvmgANf9Epi2dNP4n5q mjn5oa9kUzia5A5U/KIhtl0BawegychNiJRCiPJieWZ99nG8BL3ZEiYBG+GIlaR8QgWL Bo6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26148-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r16-20020a0ce290000000b0067f6a7d8042si8125395qvl.316.2024.01.15.06.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:58:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26148-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4F5CA1C21B62 for ; Mon, 15 Jan 2024 14:58:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB8B7175BC; Mon, 15 Jan 2024 14:58:08 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAB4617586; Mon, 15 Jan 2024 14:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 41FB5101643; Mon, 15 Jan 2024 14:48:47 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v1 2/7] HID: playstation: DS4: Don't fail on MAC address request Date: Mon, 15 Jan 2024 23:45:33 +0900 Message-Id: <20240115144538.12018-3-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-1-max@enpas.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some third-party controllers can't report their MAC address. Since a unique ID is needed for ps_devices_list_add() and ps_device_register_battery(), let's use hdev->id for this when we don't have a MAC address. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 7f50e13601f0..0a3c442af305 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -1966,7 +1966,10 @@ static int dualshock4_get_mac_address(struct dualshock4 *ds4) DS4_FEATURE_REPORT_PAIRING_INFO_SIZE, false); if (ret) { hid_err(hdev, "Failed to retrieve DualShock4 pairing info: %d\n", ret); - goto err_free; + hid_err(hdev, "Generating fake MAC address for this device.\n"); + buf[1] = (hdev->id >> 0) & 0xff; + buf[2] = (hdev->id >> 8) & 0xff; + buf[3] = (hdev->id >> 16) & 0xff; } memcpy(ds4->base.mac_address, &buf[1], sizeof(ds4->base.mac_address)); @@ -1986,7 +1989,6 @@ static int dualshock4_get_mac_address(struct dualshock4 *ds4) return 0; } -err_free: kfree(buf); return ret; } @@ -2552,7 +2554,7 @@ static struct ps_device *dualshock4_create(struct hid_device *hdev) ret = dualshock4_get_mac_address(ds4); if (ret) { hid_err(hdev, "Failed to get MAC address from DualShock4\n"); - return ERR_PTR(ret); + hid_err(hdev, "Can't detect simultaneous USB/BT connections from this device.\n"); } snprintf(hdev->uniq, sizeof(hdev->uniq), "%pMR", ds4->base.mac_address); -- 2.39.2