From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8F8CCA9EC0 for ; Mon, 28 Oct 2019 19:09:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE9DA21721 for ; Mon, 28 Oct 2019 19:09:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729644AbfJ1TJi convert rfc822-to-8bit (ORCPT ); Mon, 28 Oct 2019 15:09:38 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:56190 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727664AbfJ1TJi (ORCPT ); Mon, 28 Oct 2019 15:09:38 -0400 Received: from marcel-macbook.fritz.box (p4FEFC197.dip0.t-ipconnect.de [79.239.193.151]) by mail.holtmann.org (Postfix) with ESMTPSA id 11589CECCF; Mon, 28 Oct 2019 20:18:38 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) Subject: Re: [PATCH 2/3] Bluetooth: hci_h5: Add DT support for rtl8723bs From: Marcel Holtmann In-Reply-To: <20191026204116.95119-3-bonstra@bonstra.fr.eu.org> Date: Mon, 28 Oct 2019 20:09:34 +0100 Cc: Johan Hedberg , Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20191026204116.95119-1-bonstra@bonstra.fr.eu.org> <20191026204116.95119-3-bonstra@bonstra.fr.eu.org> To: Hugo Grostabussiat X-Mailer: Apple Mail (2.3594.4.19) Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Hugo, > The hci_h5 already supports rtl8723bs devices discovered via ACPI. This > commit adds support for discovering via device tree for ACPI-less > platforms. > > Signed-off-by: Hugo Grostabussiat > --- > drivers/bluetooth/hci_h5.c | 40 +++++++++++++++++++++++++++++++++----- > 1 file changed, 35 insertions(+), 5 deletions(-) > > diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c > index dacf297baf59..49ac03b1a7e3 100644 > --- a/drivers/bluetooth/hci_h5.c > +++ b/drivers/bluetooth/hci_h5.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -782,7 +783,9 @@ static const struct hci_uart_proto h5p = { > > static int h5_serdev_probe(struct serdev_device *serdev) > { > - const struct acpi_device_id *match; > + const struct acpi_device_id *acpi_match; > + const struct of_device_id *of_match; > + const char *cfgname = NULL; > struct device *dev = &serdev->dev; > struct h5 *h5; > > @@ -797,16 +800,27 @@ static int h5_serdev_probe(struct serdev_device *serdev) > serdev_device_set_drvdata(serdev, h5); > > if (has_acpi_companion(dev)) { then move const struct acpi_device_id *match here in the local focus. > - match = acpi_match_device(dev->driver->acpi_match_table, dev); > - if (!match) > + acpi_match = acpi_match_device( > + dev->driver->acpi_match_table, dev); > + if (!acpi_match) > return -ENODEV; > > - h5->vnd = (const struct h5_vnd *)match->driver_data; > - h5->id = (char *)match->id; > + h5->vnd = (const struct h5_vnd *)acpi_match->driver_data; > + h5->id = (char *)acpi_match->id; > > if (h5->vnd->acpi_gpio_map) > devm_acpi_dev_add_driver_gpios(dev, > h5->vnd->acpi_gpio_map); > + } else if (dev->of_node) { And have struct of_device_id *match here. > + of_match = of_match_device(dev->driver->of_match_table, dev); > + if (!of_match) > + return -ENODEV; > + > + of_property_read_string(dev->of_node, > + "realtek,config-name", &cfgname); > + > + h5->vnd = (const struct h5_vnd *)of_match->data; > + h5->id = cfgname; So we can not just read a realtek specific variable here. This is still generic code for 3-Wire UART protocol and needs to be available to other vendors as well. > } > > h5->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); > @@ -996,6 +1010,19 @@ static const struct acpi_device_id h5_acpi_match[] = { > MODULE_DEVICE_TABLE(acpi, h5_acpi_match); > #endif > > +#ifdef CONFIG_OF > +static const struct of_device_id h5_of_match[] = { > +#ifdef CONFIG_BT_HCIUART_RTL > + { > + .compatible = "realtek,rtl8723bs-bt", > + .data = &rtl_vnd > + }, > +#endif > + { }, > +}; > +MODULE_DEVICE_TABLE(of, h5_of_match); > +#endif > + > static const struct dev_pm_ops h5_serdev_pm_ops = { > SET_SYSTEM_SLEEP_PM_OPS(h5_serdev_suspend, h5_serdev_resume) > }; > @@ -1006,6 +1033,9 @@ static struct serdev_device_driver h5_serdev_driver = { > .driver = { > .name = "hci_uart_h5", > .acpi_match_table = ACPI_PTR(h5_acpi_match), > +#ifdef CONFIG_OF > + .of_match_table = h5_of_match, > +#endif Use of_match_ptr here instead of the ifdef. > .pm = &h5_serdev_pm_ops, > }, > }; Regards Marcel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CF5CCA9EC0 for ; Mon, 28 Oct 2019 19:09:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27926214B2 for ; Mon, 28 Oct 2019 19:09:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EyMdHwqV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27926214B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=holtmann.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:References:Message-Id:Date: In-Reply-To:From:Subject:Mime-Version:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G+X03a4KaspwXUeFTUw4KsJzlasQEusiKtgGiApW+vo=; b=EyMdHwqVsVMTOf UXO/Mo+CxndePLX2qzNFxipAa4LVSi2PI2HD/TpfZft2tJXq7bfuA8ALh7tnXgXfXwbRKEvLY4zj/ hVlFH+TQ6z5UiIFsNCk1stChdUQYvM4WJYQnmGnRMyc90jmPrubkWL28QyQy+eeXHOpbC+beaZBln BpW0s5jfslfV0Srag0eRKaLwgxO9kfxWwwHvEa2Cpm7t1H6gjZdSYGYqA9khIlXiZOIQqwidhQWnl A0/bq4CbjTCyVOyWCRdIBQTv0bVJG6dMDH1Yp+e/mAsIxoQXiRhpZug1BFxgMyaiiJIF7qJcGQYSX Fv+FssBA52OG+RDsPmhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iPAOk-0001R9-Ge; Mon, 28 Oct 2019 19:09:50 +0000 Received: from coyote.holtmann.net ([212.227.132.17] helo=mail.holtmann.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iPAOf-0001Eg-9V for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2019 19:09:48 +0000 Received: from marcel-macbook.fritz.box (p4FEFC197.dip0.t-ipconnect.de [79.239.193.151]) by mail.holtmann.org (Postfix) with ESMTPSA id 11589CECCF; Mon, 28 Oct 2019 20:18:38 +0100 (CET) Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) Subject: Re: [PATCH 2/3] Bluetooth: hci_h5: Add DT support for rtl8723bs From: Marcel Holtmann In-Reply-To: <20191026204116.95119-3-bonstra@bonstra.fr.eu.org> Date: Mon, 28 Oct 2019 20:09:34 +0100 Message-Id: References: <20191026204116.95119-1-bonstra@bonstra.fr.eu.org> <20191026204116.95119-3-bonstra@bonstra.fr.eu.org> To: Hugo Grostabussiat X-Mailer: Apple Mail (2.3594.4.19) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191028_120945_484038_935182EF X-CRM114-Status: GOOD ( 17.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Johan Hedberg , Maxime Ripard , linux-bluetooth@vger.kernel.org, Chen-Yu Tsai , Rob Herring , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Hugo, > The hci_h5 already supports rtl8723bs devices discovered via ACPI. This > commit adds support for discovering via device tree for ACPI-less > platforms. > > Signed-off-by: Hugo Grostabussiat > --- > drivers/bluetooth/hci_h5.c | 40 +++++++++++++++++++++++++++++++++----- > 1 file changed, 35 insertions(+), 5 deletions(-) > > diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c > index dacf297baf59..49ac03b1a7e3 100644 > --- a/drivers/bluetooth/hci_h5.c > +++ b/drivers/bluetooth/hci_h5.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -782,7 +783,9 @@ static const struct hci_uart_proto h5p = { > > static int h5_serdev_probe(struct serdev_device *serdev) > { > - const struct acpi_device_id *match; > + const struct acpi_device_id *acpi_match; > + const struct of_device_id *of_match; > + const char *cfgname = NULL; > struct device *dev = &serdev->dev; > struct h5 *h5; > > @@ -797,16 +800,27 @@ static int h5_serdev_probe(struct serdev_device *serdev) > serdev_device_set_drvdata(serdev, h5); > > if (has_acpi_companion(dev)) { then move const struct acpi_device_id *match here in the local focus. > - match = acpi_match_device(dev->driver->acpi_match_table, dev); > - if (!match) > + acpi_match = acpi_match_device( > + dev->driver->acpi_match_table, dev); > + if (!acpi_match) > return -ENODEV; > > - h5->vnd = (const struct h5_vnd *)match->driver_data; > - h5->id = (char *)match->id; > + h5->vnd = (const struct h5_vnd *)acpi_match->driver_data; > + h5->id = (char *)acpi_match->id; > > if (h5->vnd->acpi_gpio_map) > devm_acpi_dev_add_driver_gpios(dev, > h5->vnd->acpi_gpio_map); > + } else if (dev->of_node) { And have struct of_device_id *match here. > + of_match = of_match_device(dev->driver->of_match_table, dev); > + if (!of_match) > + return -ENODEV; > + > + of_property_read_string(dev->of_node, > + "realtek,config-name", &cfgname); > + > + h5->vnd = (const struct h5_vnd *)of_match->data; > + h5->id = cfgname; So we can not just read a realtek specific variable here. This is still generic code for 3-Wire UART protocol and needs to be available to other vendors as well. > } > > h5->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); > @@ -996,6 +1010,19 @@ static const struct acpi_device_id h5_acpi_match[] = { > MODULE_DEVICE_TABLE(acpi, h5_acpi_match); > #endif > > +#ifdef CONFIG_OF > +static const struct of_device_id h5_of_match[] = { > +#ifdef CONFIG_BT_HCIUART_RTL > + { > + .compatible = "realtek,rtl8723bs-bt", > + .data = &rtl_vnd > + }, > +#endif > + { }, > +}; > +MODULE_DEVICE_TABLE(of, h5_of_match); > +#endif > + > static const struct dev_pm_ops h5_serdev_pm_ops = { > SET_SYSTEM_SLEEP_PM_OPS(h5_serdev_suspend, h5_serdev_resume) > }; > @@ -1006,6 +1033,9 @@ static struct serdev_device_driver h5_serdev_driver = { > .driver = { > .name = "hci_uart_h5", > .acpi_match_table = ACPI_PTR(h5_acpi_match), > +#ifdef CONFIG_OF > + .of_match_table = h5_of_match, > +#endif Use of_match_ptr here instead of the ifdef. > .pm = &h5_serdev_pm_ops, > }, > }; Regards Marcel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel