All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: "Sebastian Reichel" <sre@kernel.org>,
	"Tony Lindgren" <tony@atomide.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jslaby@suse.com>,
	"Ville Tervo" <ville.tervo@iki.fi>,
	"Filip Matijević" <filip.matijevic.pz@gmail.com>,
	"Aaro Koskinen" <aaro.koskinen@iki.fi>,
	"Pavel Machek" <pavel@ucw.cz>,
	ivo.g.dimitrov.75@gmail.com, linux-bluetooth@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-omap@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 5/7] Bluetooth: hci_nokia: Introduce new driver
Date: Tue, 16 Aug 2016 09:52:17 +0200	[thread overview]
Message-ID: <20160816075217.GK30047@pali> (raw)
In-Reply-To: <0528B894-39CB-4D18-971E-3209EEEA2583@holtmann.org>

On Tuesday 16 August 2016 09:02:14 Marcel Holtmann wrote:
> > +static int nokia_setup_fw(struct hci_uart *hu)
> > +{
> > +	struct nokia_bt_dev *btdev = hu->priv;
> > +	const struct firmware *fw;
> > +	const u8 *fw_ptr;
> > +	size_t fw_size;
> > +	int err;
> > +
> > +	BT_DBG("hu %p", hu);
> > +
> > +	err = request_firmware(&fw, nokia_get_fw_name(btdev), hu->tty->dev);
> 
> So does this nokia_get_fw_name really needs to be a separate function? Or can this just be done right here in this function? I prefer it to be done where it is actually used. Unless you use that name in many places.
> 
> > +	if (err < 0) {
> > +		BT_ERR("%s: Failed to load Nokia firmware file (%d)",
> > +		       hu->hdev->name, err);
> > +		return err;
> > +	}
> > +
> > +	fw_ptr = fw->data;
> > +	fw_size = fw->size;
> > +
> > +	while (fw_size >= 4) {
> > +		u16 pkt_size = get_unaligned_le16(fw_ptr);
> > +		u8 pkt_type = fw_ptr[2];
> > +		const struct hci_command_hdr *cmd;
> > +		u16 opcode;
> > +		struct sk_buff *skb;
> > +
> > +		switch (pkt_type) {
> > +		case HCI_COMMAND_PKT:
> > +			cmd = (struct hci_command_hdr *)(fw_ptr + 3);
> > +			opcode = le16_to_cpu(cmd->opcode);
> > +
> > +			skb = __hci_cmd_sync(hu->hdev, opcode, cmd->plen,
> > +					     fw_ptr + 3 + HCI_COMMAND_HDR_SIZE,
> > +					     HCI_INIT_TIMEOUT);
> > +			if (IS_ERR(skb)) {
> > +				err = PTR_ERR(skb);
> > +				BT_ERR("%s: Firmware command %04x failed (%d)",
> > +				       hu->hdev->name, opcode, err);
> > +				goto done;
> > +			}
> > +			kfree_skb(skb);
> > +			break;
> > +		case HCI_NOKIA_RADIO_PKT:
> 
> Are you sure you can ignore the RADIO_PKT commands. They are used to set up the FM radio parts of the chip. They are standard HCI commands (in the case of Broadcom at least). At minimum it should be added a comment here that you are ignoring them on purpose.
> 
> > +		case HCI_NOKIA_NEG_PKT:
> > +		case HCI_NOKIA_ALIVE_PKT:
> 
> And here I would also a comment on why are we ignore these commands and driving this all by ourselves.
> 

Good question... In Pavel's version of bluetooth driver, which is
working on Nokia N900, is sent whole firmware at one __hci_cmd_sync
step. It does not skip any packets, plus he added this comment:

/* Note that this is timing-critical. If sending packets takes
 * too long, initialization will fail.
 */

So really, can we skip those packets? And is not this reason why
this bluetooth driver does not work on Nokia N900?

-- 
Pali Rohár
pali.rohar@gmail.com

  reply	other threads:[~2016-08-16  7:53 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-13  3:14 [RFC 0/7] Nokia N9xx bluetooth driver Sebastian Reichel
2016-08-13  3:14 ` [RFC 1/7] tty: serial: omap: add UPF_BOOT_AUTOCONF flag for DT init Sebastian Reichel
2016-08-14  8:49   ` Pavel Machek
2016-08-16  8:14     ` Sebastian Reichel
2016-08-16  8:14       ` Sebastian Reichel
2016-08-13  3:14 ` [RFC 2/7] tty: add support for "tty slave" devices Sebastian Reichel
2016-08-13 10:03   ` Greg Kroah-Hartman
2016-08-13 20:31     ` Sebastian Reichel
2016-08-14 11:36       ` Greg Kroah-Hartman
2016-08-14  8:48     ` Pavel Machek
2016-08-14 11:35       ` Greg Kroah-Hartman
2016-08-14 11:35         ` Greg Kroah-Hartman
2016-08-13  3:14 ` [RFC 3/7] dt: bindings: Add nokia-bluetooth Sebastian Reichel
2016-08-16 13:51   ` Rob Herring
2016-08-16 23:28     ` Sebastian Reichel
2016-08-17 13:11       ` Rob Herring
2016-08-17 13:11         ` Rob Herring
2016-08-17 15:54         ` Pavel Machek
2016-08-17 15:54           ` Pavel Machek
2016-08-13  3:14 ` [RFC 4/7] Bluetooth: hci_uart: Add support for word alignment Sebastian Reichel
2016-08-14  8:51   ` Pavel Machek
2016-08-14  8:51     ` Pavel Machek
2016-08-16  7:05   ` Marcel Holtmann
2016-08-16  7:51     ` Sebastian Reichel
2016-08-16  7:51       ` Sebastian Reichel
2016-08-13  3:14 ` [RFC 5/7] Bluetooth: hci_nokia: Introduce new driver Sebastian Reichel
2016-08-14 23:54   ` Paul Gortmaker
2016-08-14 23:54     ` Paul Gortmaker
2016-08-15  1:12     ` Sebastian Reichel
2016-08-15  1:12       ` Sebastian Reichel
2016-08-16  7:02   ` Marcel Holtmann
2016-08-16  7:52     ` Pali Rohár [this message]
2016-08-16  9:25       ` Sebastian Reichel
2016-08-16  9:09     ` Sebastian Reichel
2016-08-16  9:09       ` Sebastian Reichel
2016-08-16 10:23       ` Marcel Holtmann
2016-08-16 10:23         ` Marcel Holtmann
2016-08-16 20:05         ` Pavel Machek
2016-08-16 10:23       ` Marcel Holtmann
2016-08-16 10:23         ` Marcel Holtmann
2016-08-16  8:10   ` Marcel Holtmann
2016-08-16  8:10     ` Marcel Holtmann
2016-08-16  9:35     ` Sebastian Reichel
2016-08-13  3:14 ` [RFC 6/7] ARM: dts: OMAP3-N900: Add bluetooth Sebastian Reichel
2016-08-14  8:53   ` Pavel Machek
2016-08-13  3:14 ` [RFC 7/7] ARM: dts: OMAP3-N950: " Sebastian Reichel
2016-08-13  3:14   ` Sebastian Reichel
2016-08-14  8:53   ` Pavel Machek
2016-08-16  7:10 ` [RFC 0/7] Nokia N9xx bluetooth driver Marcel Holtmann
2016-08-16  7:10   ` Marcel Holtmann
2016-08-16 20:22   ` Rob Herring
2016-08-16 20:22     ` Rob Herring

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=20160816075217.GK30047@pali \
    --to=pali.rohar@gmail.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=devicetree@vger.kernel.org \
    --cc=filip.matijevic.pz@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=jslaby@suse.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    --cc=ville.tervo@iki.fi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.