mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Simon Horman <simon.horman@netronome.com>
Cc: "Ben Dooks (Codethink)" <ben.dooks@codethink.co.uk>,
	linux-kernel@lists.codethink.co.uk,
	Johan Hedberg <johan.hedberg@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RFC: Bluetooth: missed cpu_to_le16 conversion in hci_init4_req
Date: Wed, 16 Oct 2019 20:42:48 +0200	[thread overview]
Message-ID: <BFA3CB11-5FD8-4BD8-9DDA-62707AB84626@holtmann.org> (raw)
In-Reply-To: <20191016122022.kz4xzx4hzmtuoh5l@netronome.com>

Hi Simon,

>> It looks like in hci_init4_req() the request is being
>> initialised from cpu-endian data but the packet is specified
>> to be little-endian. This causes an warning from sparse due
>> to __le16 to u16 conversion.
>> 
>> Fix this by using cpu_to_le16() on the two fields in the packet.
>> 
>> net/bluetooth/hci_core.c:845:27: warning: incorrect type in assignment (different base types)
>> net/bluetooth/hci_core.c:845:27:    expected restricted __le16 [usertype] tx_len
>> net/bluetooth/hci_core.c:845:27:    got unsigned short [usertype] le_max_tx_len
>> net/bluetooth/hci_core.c:846:28: warning: incorrect type in assignment (different base types)
>> net/bluetooth/hci_core.c:846:28:    expected restricted __le16 [usertype] tx_time
>> net/bluetooth/hci_core.c:846:28:    got unsigned short [usertype] le_max_tx_time
>> 
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>> Cc: Marcel Holtmann <marcel@holtmann.org>
>> Cc: Johan Hedberg <johan.hedberg@gmail.com>
>> Cc: "David S. Miller" <davem@davemloft.net>
>> Cc: linux-bluetooth@vger.kernel.org
>> Cc: netdev@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>> net/bluetooth/hci_core.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 04bc79359a17..b2559d4bed81 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -842,8 +842,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt)
>> 	if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) {
>> 		struct hci_cp_le_write_def_data_len cp;
>> 
>> -		cp.tx_len = hdev->le_max_tx_len;
>> -		cp.tx_time = hdev->le_max_tx_time;
>> +		cp.tx_len = cpu_to_le16(hdev->le_max_tx_len);
>> +		cp.tx_time = cpu_to_le16(hdev->le_max_tx_time);
> 
> I would suggest that the naming of the le_ fields of struct hci_dev
> implies that the values stored in those fields should be little endian
> (but those that are more than bone byte wide are not).

the le_ stands for Low Energy and not for Little Endian.

Regards

Marcel


  reply	other threads:[~2019-10-16 18:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 11:39 Ben Dooks (Codethink)
2019-10-16 12:20 ` Simon Horman
2019-10-16 18:42   ` Marcel Holtmann [this message]
2019-10-17 12:43     ` Simon Horman
2019-10-16 18:41 ` Marcel Holtmann

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=BFA3CB11-5FD8-4BD8-9DDA-62707AB84626@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@netronome.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

all inboxes | Powered by JetHome®