From: Chen Gang S <gang.chen@sunrus.com.cn>
To: David Laight <David.Laight@ACULAB.COM>,
Marcel Holtmann <marcel@holtmann.org>,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: "Gustavo F. Padovan" <gustavo@padovan.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"linux-bluetooth@vger.kernel.org"
<linux-bluetooth@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] net: bluetooth: hci_sock: Use 'const void *' instead of 'void *' for 2nd parameter of hci_test_bit()
Date: Thu, 05 Feb 2015 20:20:52 +0800 [thread overview]
Message-ID: <54D36024.5030904@sunrus.com.cn> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CADC42B@AcuExch.aculab.com>
On 2/5/15 18:14, David Laight wrote:
> From: Chen Gang S [mailto:gang.chen@sunrus.com.cn]
>> On 2/5/15 05:09, Marcel Holtmann wrote:
>>> Hi Sergei,
>>>
>>>>>> -static inline int hci_test_bit(int nr, void *addr)
>>>>>> +static inline int hci_test_bit(int nr, const void *addr)
>>>>>> {
>>>>>> return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31));
>>>>>> }
>>>>
>>>>> Is there a 'standard' function lurking that will do the above.
>>>>> On x86 the cpus 'bit test' instruction will handle bit numbers
>>>>> greater than the word size - so it can be a single instruction.
>>>>
>>>> Of course, there's test_bit().
>>>
>>> we did leave hci_test_bit in the code since there are some userspace facing
>>> API that we can not change. Remember that the origin of this code is
>>> from 2.4.6 kernel.
>>>
>>> So we can only change this if you can ensure not to break the userspace API.
>>> So might want to write unit tests to ensure working HCI filter before even
>>> considering touching this.
>>>
>>
>> For me, we have to remain hci_test_bit(), it is for "__u32 *" (which we
>> can not change). The common test_bit() is for "unsigned long *", in this
>> case, I guess it may cause issue under 64-bit environments.
>
> Except that half the time you are passing a 'long *' and you haven't
> explained why this isn't broken on 64bit architectures.
>
Maybe we are misunderstanding with each other (excuse me for my pool
English). What I want to say is:
- hci_test_bit() is OK (current implementation can not cause issue for
64-bit machine).
- But if we use test_bit(), I guess it will cause issue for 64-bit
machine.
> Note that on LE systems the size of the accesses used to access a dense
> bit array don't matter. This is not true of BE systems.
>
Yes, what you said above sounds reasonable to me, too.
Thanks.
--
Chen Gang
Open, share, and attitude like air, water, and life which God blessed
prev parent reply other threads:[~2015-02-05 12:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-02 21:14 [PATCH v2] net: bluetooth: hci_sock: Use 'const void *' instead of 'void *' for 2nd parameter of hci_test_bit() Chen Gang S
[not found] ` <54CFE8BE.5030700-/B7AUNIrSHOPt1CcHtbs0g@public.gmane.org>
2015-02-02 21:20 ` Joe Perches
[not found] ` <1422912017.30476.28.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2015-02-03 2:32 ` Chen Gang S
2015-02-03 2:59 ` Chen Gang S
[not found] ` <54D03996.1070503-/B7AUNIrSHOPt1CcHtbs0g@public.gmane.org>
2015-02-04 12:13 ` David Laight
2015-02-04 11:59 ` David Laight
2015-02-04 20:13 ` Sergei Shtylyov
[not found] ` <54D27D68.7040501-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2015-02-04 21:09 ` Marcel Holtmann
2015-02-04 21:47 ` Chen Gang S
2015-02-05 10:14 ` David Laight
2015-02-05 12:20 ` Chen Gang S [this message]
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=54D36024.5030904@sunrus.com.cn \
--to=gang.chen@sunrus.com.cn \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.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).