linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Sean Wang <sean.wang@mediatek.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	Johan Hedberg <johan.hedberg@gmail.com>,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	robh+dt@kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 5/7] Bluetooth: Extend btuart driver for join more vendor devices
Date: Mon, 16 Jul 2018 14:59:58 +0200	[thread overview]
Message-ID: <6476BE78-3FE5-465F-8060-2215387323AA@holtmann.org> (raw)
In-Reply-To: <1531641134.3955.19.camel@mtkswgap22>

Hi Sean,

>>> Adding an independent btuart.h header allows these essential definitions
>>> can be reused in vendor driver. Also, struct btuart_vnd is extended with
>>> additional callbacks such as .init initializing vendor data, .shtudown,
>>> .recv and .send supporting SoC specific framing for that btuart can
>>> simply adapt to various Bluetooth uart-based devices.
>>> 
>>> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
>>> ---
>>> drivers/bluetooth/btuart.c | 73 ++++++++++++++++++++++++----------------------
>>> drivers/bluetooth/btuart.h | 30 +++++++++++++++++++
>>> 2 files changed, 68 insertions(+), 35 deletions(-)
>>> create mode 100644 drivers/bluetooth/btuart.h
>>> 
>>> diff --git a/drivers/bluetooth/btuart.c b/drivers/bluetooth/btuart.c
>>> index a900aac..65d0086 100644
>>> --- a/drivers/bluetooth/btuart.c
>>> +++ b/drivers/bluetooth/btuart.c
>>> @@ -33,35 +33,11 @@
>>> #include <net/bluetooth/hci_core.h>
>>> 
>>> #include "h4_recv.h"
>>> +#include "btuart.h"
>>> #include "btbcm.h"
>>> 
>>> #define VERSION "1.0"
>>> 
>>> -struct btuart_vnd {
>>> -	const struct h4_recv_pkt *recv_pkts;
>>> -	int recv_pkts_cnt;
>>> -	unsigned int manufacturer;
>>> -	int (*open)(struct hci_dev *hdev);
>>> -	int (*close)(struct hci_dev *hdev);
>>> -	int (*setup)(struct hci_dev *hdev);
>>> -};
>>> -
>>> -struct btuart_dev {
>>> -	struct hci_dev *hdev;
>>> -	struct serdev_device *serdev;
>>> -
>>> -	struct work_struct tx_work;
>>> -	unsigned long tx_state;
>>> -	struct sk_buff_head txq;
>>> -
>>> -	struct sk_buff *rx_skb;
>>> -
>>> -	const struct btuart_vnd *vnd;
>>> -};
>> 
>> I really like to avoid this since it is not clean. Frankly I prefer to keep the btuart.c driver for drivers that really just use H:4 as transport protocol. If the protocol is only H:4 alike and has extra headers, then it should be a separate driver.
>> 
> 
> thanks for letting me know your concern. I think I'm a little over in reusing these existing methods and break something generic and its beauty.
> 
> I'll make the driver be a separate one based on btuart in the next version.
> 
> 
>> The common H:4 handling is abstracted in h4_recv.h already anyway and we can add more pieces if needed. However I also wonder since you have extra framing that the complex H:4 state keeping might be not needed at all. So it could be simplified.
>> 
> 
> okay, I will get rid of h4_recv.h and consider to use more simplified logic to handle the extra framing and its payload.

only if it is already framed by your extra header, but I seem to recall that it will frame it. For example the bfusb.c old driver does frame H:4 as well and then no extra state keeping for H:4 is needed. Just pass the frames up into the core via hci_recv_frame (or hci_recv_diag for vendor diagnostic) and move on with it.

You can of course use h4_recv.h if you need to, but only do that if you are true H:4 stream and have no idea where a frame ends and starts.

Regards

Marcel


  reply	other threads:[~2018-07-16 13:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 15:56 [PATCH v5 0/7] add support for Bluetooth on MT7622 SoC sean.wang
2018-07-09 15:56 ` [PATCH v5 1/7] dt-bindings: net: bluetooth: Add mediatek-bluetooth sean.wang
2018-07-14 16:26   ` Marcel Holtmann
2018-07-15  5:10     ` Sean Wang
2018-07-09 15:56 ` [PATCH v5 2/7] serdev: add dev_pm_domain_attach|detach() sean.wang
2018-07-14 16:27   ` Marcel Holtmann
2018-07-15  8:56   ` Johan Hovold
2018-07-16  9:50     ` Greg Kroah-Hartman
2018-07-09 15:56 ` [PATCH v5 3/7] Bluetooth: Add new serdev based driver for UART attached controllers sean.wang
2018-07-09 15:57 ` [PATCH v5 4/7] Bluetooth: Add new quirk for non-persistent setup settings sean.wang
2018-07-14 16:34   ` Marcel Holtmann
2018-07-15  7:02     ` Sean Wang
2018-07-16 12:56       ` Marcel Holtmann
2018-07-16 16:05         ` Sean Wang
2018-07-18 12:14           ` Marcel Holtmann
2018-07-18 13:33             ` Sean Wang
2018-07-09 15:57 ` [PATCH v5 5/7] Bluetooth: Extend btuart driver for join more vendor devices sean.wang
2018-07-14 16:44   ` Marcel Holtmann
2018-07-15  7:52     ` Sean Wang
2018-07-16 12:59       ` Marcel Holtmann [this message]
2018-07-16 15:29         ` Sean Wang
2018-07-18 12:23           ` Marcel Holtmann
2018-07-18 14:26             ` Sean Wang
2018-07-09 15:57 ` [PATCH v5 6/7] Bluetooth: mediatek: Add protocol support for MediaTek serial devices sean.wang
2018-07-14 16:32   ` Marcel Holtmann
2018-07-15  5:53     ` Sean Wang
2018-07-09 15:57 ` [PATCH v5 7/7] MAINTAINERS: add an entry for MediaTek Bluetooth driver sean.wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6476BE78-3FE5-465F-8060-2215387323AA@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=devicetree@vger.kernel.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).