Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2377923lqp; Sun, 24 Mar 2024 16:42:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1q2SFYCGTW2IlhHVv0doJiDU6ll8KPYqySyCrX+5+AlKvT1dM7aqsYgG/jdC5jQqkTR0/BNJx5A+qu9KLe8Aon95+0CQz+BVOcmvgqw== X-Google-Smtp-Source: AGHT+IEmFft3WD57exAukSl7TS9ymXRNnUaKBxFRMujLxC7xeBP2shrqLF05d1M5HktaDvvPQ/sJ X-Received: by 2002:a50:a69e:0:b0:56b:b278:d57b with SMTP id e30-20020a50a69e000000b0056bb278d57bmr3476858edc.16.1711323771416; Sun, 24 Mar 2024 16:42:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711323771; cv=pass; d=google.com; s=arc-20160816; b=pOi2p85d3aKW+JZttBMDE99eyc6pheNYp3yFtKWuK0tz8Qj+jYdSyoUPh8yvv7PLPN qmnptpp6tmH8AvCI0vgJt6tXMo93FVoITZaRmKrHldJIaJfbXHY57P4FmntqGoNzJCLI dgaReyf1lk5/PsVCHMvBkMap16cZLunhE0o00IVIWYD/1wZtq2+O8fmOcvqQ8KZ4j93N IQlq02LfyCPF6SFMI3AXH/JXBSBuUS8J21hcpyzTAHVQgm/mqV9zWYjBi3UW3JclCW9Z ruNFsp2JID0KKV1OEblQU6jrqktHBkxpCY6b0h7P2SOT5hCmezsl1eQjXLO5lCbY6BtS 6gmw== ARC-Message-Signature: i=2; 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:dkim-signature; bh=vdQmvP4AOCClfIDWk+tIrT1TXK8nA9gifpy+AugT+cY=; fh=m5blFiIWqx+vNsWXJJ4dkUhOL1Qvg4gBXI/KNuwcMEQ=; b=nkFW4X5qAaeMxjuzbdPDi1lceLgKh8v3Jo7mrd9N0swSzWhY3/OnUQcJ/LK8RTKoG6 S3nWUQ8J1GxKhE0qh22OlLxk1Imojfgp063d77ZX93DwqE5NqUErsd2FKHSwlhsexn/Y hGMknKPTO0iPuukfl+vEeL0MA+UDitO6cBpLR3x052S/atLGWY+ZMfMcXKzBpyvqb9em ij0vBWq+0xfLxEcPqw3EJp7+gtSYd/7x7KjFralc+FJq+StFTlvjNRYgQxuhTpNHdlmr G1kOihIFhuiui0liW5yefHRPavNV93ePVgxMQX47D0PZJ8gfy+GddCfL8Ul8PTOSRRIb Knlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bU+70fyM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113201-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113201-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r8-20020a056402234800b0056869ae4414si2064403eda.55.2024.03.24.16.42.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:42:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113201-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bU+70fyM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113201-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113201-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2242D1F218CA for ; Sun, 24 Mar 2024 23:42:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 103BB13119B; Sun, 24 Mar 2024 22:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bU+70fyM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 095A617BB21; Sun, 24 Mar 2024 22:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320004; cv=none; b=PFcj9sGeUDEMERO0u3B6TPY6+vJghX0yAAR6c8BDaCc872+h59wz+Krgj1mzaXn/DWoO6FxYwrtxtz1UddZt50WenyEewAR05c9MPfsL2QGxYbi3G3WKqx9qkWXjjOioOctIwhDYtq8kdW+4/5H4+fQ6TH+zAdJZmpLc2n+QQKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320004; c=relaxed/simple; bh=PUibFJzq8s1O50wIgMpnQ+UAHV1ejtQduBLCizncLr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pf+9ZSKZlpAboC/wtHg0XxNJxPYrTNJCLanif/wOx6eebhGwLKNxra1UgXaiEzADFr68TcKHI4/Y1X5+qgwA4FX/aiKH879hdnmUl1BaeJERNHO/JW7MGzjkpIw1jidza9ANEoiN+8vZx9F4rr1kDFV5eXbZyMvKKuweQuYZO8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bU+70fyM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4661DC433C7; Sun, 24 Mar 2024 22:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320003; bh=PUibFJzq8s1O50wIgMpnQ+UAHV1ejtQduBLCizncLr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bU+70fyMb7FJmPaXE6GMZv4dZGZmOGadIqtaFYll6EoaynJSePQbOJJYgblOOVJin YCN6i57W8SXJh9oBjQeEIwxZN58xBqwIh6y/oWaS30/YVLMBPo+JGQWfhd6oSs+Qkn kEYU7gFQCY0+j2pOUevssARahnDyxeRWkyd1Ysup7a3hHPCTH+rFdtKPAXwLC+TPbU AsKYzMIa+lo4AHrJPUc3xNs89KsVsdKwnMRRPFJ9XHu4y/Idocbcymbp37cSIoNntY /jLCJ+wwiSZyNd3lz9Q+meSd1uvnt6idsGbWBY2rw7qGcupOFsbpscB8bXTfvwXyKZ /UEOYMEwcubBA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrey Skvortsov , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.8 310/715] Bluetooth: hci_h5: Add ability to allocate memory for private data Date: Sun, 24 Mar 2024 18:28:09 -0400 Message-ID: <20240324223455.1342824-311-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Andrey Skvortsov [ Upstream commit 7a6d793e9ca8bc0c1d2f0aa0a02ec380d1124c74 ] In some cases uart-base drivers may need to use priv data. For example, to store information needed for devcoredump. Fixes: 044014ce85a1 ("Bluetooth: btrtl: Add Realtek devcoredump support") Signed-off-by: Andrey Skvortsov Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/hci_h5.c | 4 +++- drivers/bluetooth/hci_serdev.c | 9 +++++---- drivers/bluetooth/hci_uart.h | 12 +++++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index 71e748a9477e4..b66136348bd64 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -113,6 +113,7 @@ struct h5_vnd { int (*suspend)(struct h5 *h5); int (*resume)(struct h5 *h5); const struct acpi_gpio_mapping *acpi_gpio_map; + int sizeof_priv; }; struct h5_device_data { @@ -863,7 +864,8 @@ static int h5_serdev_probe(struct serdev_device *serdev) if (IS_ERR(h5->device_wake_gpio)) return PTR_ERR(h5->device_wake_gpio); - return hci_uart_register_device(&h5->serdev_hu, &h5p); + return hci_uart_register_device_priv(&h5->serdev_hu, &h5p, + h5->vnd->sizeof_priv); } static void h5_serdev_remove(struct serdev_device *serdev) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 39c8b567da3c0..214fff876eae5 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -300,8 +300,9 @@ static const struct serdev_device_ops hci_serdev_client_ops = { .write_wakeup = hci_uart_write_wakeup, }; -int hci_uart_register_device(struct hci_uart *hu, - const struct hci_uart_proto *p) +int hci_uart_register_device_priv(struct hci_uart *hu, + const struct hci_uart_proto *p, + int sizeof_priv) { int err; struct hci_dev *hdev; @@ -325,7 +326,7 @@ int hci_uart_register_device(struct hci_uart *hu, set_bit(HCI_UART_PROTO_READY, &hu->flags); /* Initialize and register HCI device */ - hdev = hci_alloc_dev(); + hdev = hci_alloc_dev_priv(sizeof_priv); if (!hdev) { BT_ERR("Can't allocate HCI device"); err = -ENOMEM; @@ -394,7 +395,7 @@ int hci_uart_register_device(struct hci_uart *hu, percpu_free_rwsem(&hu->proto_lock); return err; } -EXPORT_SYMBOL_GPL(hci_uart_register_device); +EXPORT_SYMBOL_GPL(hci_uart_register_device_priv); void hci_uart_unregister_device(struct hci_uart *hu) { diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index fb4a2d0d8cc80..68c8c7e95d64d 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -97,7 +97,17 @@ struct hci_uart { int hci_uart_register_proto(const struct hci_uart_proto *p); int hci_uart_unregister_proto(const struct hci_uart_proto *p); -int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p); + +int hci_uart_register_device_priv(struct hci_uart *hu, + const struct hci_uart_proto *p, + int sizeof_priv); + +static inline int hci_uart_register_device(struct hci_uart *hu, + const struct hci_uart_proto *p) +{ + return hci_uart_register_device_priv(hu, p, 0); +} + void hci_uart_unregister_device(struct hci_uart *hu); int hci_uart_tx_wakeup(struct hci_uart *hu); -- 2.43.0