Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752899AbbBEMNj (ORCPT ); Thu, 5 Feb 2015 07:13:39 -0500 Received: from out114-136.biz.mail.alibaba.com ([205.204.114.136]:41470 "EHLO out21.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751539AbbBEMNh (ORCPT ); Thu, 5 Feb 2015 07:13:37 -0500 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07429914|-1;FP=0|0|0|0|0|-1|-1|-1;HT=r46d02008;MF=gang.chen@sunrus.com.cn;PH=DS;RN=9;RT=9;SR=0; Message-ID: <54D36024.5030904@sunrus.com.cn> Date: Thu, 05 Feb 2015 20:20:52 +0800 From: Chen Gang S User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: David Laight , Marcel Holtmann , Sergei Shtylyov CC: "Gustavo F. Padovan" , Johan Hedberg , "David S. Miller" , "linux-bluetooth@vger.kernel.org" , "netdev@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() References: <54CFE8BE.5030700@sunrus.com.cn> <063D6719AE5E284EB5DD2968C1650D6D1CADA5E1@AcuExch.aculab.com> <54D27D68.7040501@cogentembedded.com> <0AB99BEA-C379-439C-AD80-5F2122AE37E5@holtmann.org> <54D29379.8050104@sunrus.com.cn> <063D6719AE5E284EB5DD2968C1650D6D1CADC42B@AcuExch.aculab.com> In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CADC42B@AcuExch.aculab.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2167 Lines: 61 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/