Re: [PATCH 04/10] Bluetooth: hci_uart: add serdev driver support library
From: Pavel Machek <hidden>
Date: 2017-03-17 15:26:08
Also in:
linux-bluetooth, linux-serial, lkml
Hi!
From: Rob Herring <robh@kernel.org> This adds library functions for serdev based BT drivers. This is largely copied from hci_ldisc.c and modified to use serdev calls. There's a little bit of duplication, but I avoided intermixing this as the ldisc code should eventually go away. Signed-off-by: Rob Herring <robh@kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Gustavo Padovan <redacted> Cc: Johan Hedberg <redacted> Cc: linux-bluetooth@vger.kernel.org Tested-By: Sebastian Reichel <sre@kernel.org>
Trivial comments below.
quoted hunk ↗ jump to hunk
@@ -0,0 +1,370 @@ +/* + * + * Bluetooth HCI serdev driver lib
Just one empty line.
+ * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */
I don't think we put the address in there any more.
+static void hci_uart_write_work(struct work_struct *work)
+{
+ struct hci_uart *hu = container_of(work, struct hci_uart, write_work);
+ struct serdev_device *serdev = hu->serdev;
+ struct hci_dev *hdev = hu->hdev;
+ struct sk_buff *skb;
+
+ /* REVISIT: should we cope with bad skbs or ->write() returning
+ * and error value ?
+ */"an error value"? Comment style?
+restart:
+ clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
+
+ while ((skb = hci_uart_dequeue(hu))) {
+ int len;
+
+ len = serdev_device_write_buf(serdev, skb->data, skb->len);
+ hdev->stat.byte_tx += len;
+
+ skb_pull(skb, len);
+ if (skb->len) {
+ hu->tx_skb = skb;
+ break;
+ }
+
+ hci_uart_tx_complete(hu, hci_skb_pkt_type(skb));
+ kfree_skb(skb);
+ }
+
+ if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state))
+ goto restart;
do {} while () instead of goto?
+/* ------- Interface to HCI layer ------ */ +/* Initialize device */
Comment style?
+ if (hu->proto->set_baudrate && speed) {
+ err = hu->proto->set_baudrate(hu, speed);
+ if (!err)
+ serdev_device_set_baudrate(hu->serdev, speed);
+ }Complain about the error here?
+ if (skb->len != sizeof(*ver)) {
+ BT_ERR("%s: Event length mismatch for version information",
+ hdev->name);
+ goto done;
+ }
+
+done:Get rid of goto and label?
+/* hci_uart_write_wakeup() + * + * Callback for transmit wakeup. Called when low level + * device driver can accept more send data. + * + * Arguments: tty pointer to associated tty instance data + * Return Value: None + */
Kerneldoc? :-)
+static void hci_uart_write_wakeup(struct serdev_device *serdev)
+{
+ struct hci_uart *hu = serdev_device_get_drvdata(serdev);
+
+ BT_DBG("");
+
+ if (!hu)
+ return;
+
+ if (serdev != hu->serdev)
+ return;WARN_ON on both of these? That should not be normal condition...
+ /* Only when vendor specific setup callback is provided, consider + * the manufacturer information valid. This avoids filling in the + * value for Ericsson when nothing is specified. + */
Is this comment still up-to-date? Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Attachments
- signature.asc [application/pgp-signature] 181 bytes