* [PATCH v1] input: make use of the input_set_capability helper
@ 2015-01-07 7:31 Olliver Schinagl
2015-01-07 7:57 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Olliver Schinagl @ 2015-01-07 7:31 UTC (permalink / raw)
To: Dmitry Torokhov, Wolfram Sang, Paul Gortmaker, Jingoo Han,
David S. Miller, Sam Ravnborg
Cc: Olliver Schinagl, linux-input, linux-kernel
From: Olliver Schinagl <oliver@schinagl.nl>
Almost all of the speaker drivers under input manipulate the ev bits
directly, which is not needed, as there is a helper available.
This patch makes use of the helper for the speaker drivers.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
---
drivers/input/misc/cm109.c | 4 ++--
drivers/input/misc/ixp4xx-beeper.c | 5 ++---
drivers/input/misc/m68kspkr.c | 5 ++---
drivers/input/misc/pcspkr.c | 5 ++---
drivers/input/misc/pwm-beeper.c | 5 +----
drivers/input/misc/sparcspkr.c | 6 ++----
6 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
index 9365535..8e41070 100644
--- a/drivers/input/misc/cm109.c
+++ b/drivers/input/misc/cm109.c
@@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
input_dev->keycodesize = sizeof(unsigned char);
input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
/* register available key events */
+ input_dev->evbit[0] = BIT_MASK(EV_KEY);
for (i = 0; i < KEYMAP_SIZE; i++) {
unsigned short k = keymap(i);
dev->keymap[i] = k;
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
index 1fe149f..befccd0 100644
--- a/drivers/input/misc/ixp4xx-beeper.c
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -105,11 +105,10 @@ static int ixp4xx_spkr_probe(struct platform_device *dev)
input_dev->id.product = 0x0001;
input_dev->id.version = 0x0100;
input_dev->dev.parent = &dev->dev;
-
- input_dev->evbit[0] = BIT_MASK(EV_SND);
- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
input_dev->event = ixp4xx_spkr_event;
+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
+
err = gpio_request(dev->id, "ixp4-beeper");
if (err)
goto err_free_device;
diff --git a/drivers/input/misc/m68kspkr.c b/drivers/input/misc/m68kspkr.c
index 312d636..721f1dc 100644
--- a/drivers/input/misc/m68kspkr.c
+++ b/drivers/input/misc/m68kspkr.c
@@ -64,11 +64,10 @@ static int m68kspkr_probe(struct platform_device *dev)
input_dev->id.product = 0x0001;
input_dev->id.version = 0x0100;
input_dev->dev.parent = &dev->dev;
-
- input_dev->evbit[0] = BIT_MASK(EV_SND);
- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
input_dev->event = m68kspkr_event;
+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
+
err = input_register_device(input_dev);
if (err) {
input_free_device(input_dev);
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index 72b1fc3..5374a01 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -78,11 +78,10 @@ static int pcspkr_probe(struct platform_device *dev)
pcspkr_dev->id.product = 0x0001;
pcspkr_dev->id.version = 0x0100;
pcspkr_dev->dev.parent = &dev->dev;
-
- pcspkr_dev->evbit[0] = BIT_MASK(EV_SND);
- pcspkr_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
pcspkr_dev->event = pcspkr_event;
+ input_set_capability(pcspr_dev, ENV_SND, SND_BELL | SND_TONE);
+
err = input_register_device(pcspkr_dev);
if (err) {
input_free_device(pcspkr_dev);
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index a28ee70..e8facbd 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -102,12 +102,9 @@ static int pwm_beeper_probe(struct platform_device *pdev)
beeper->input->id.vendor = 0x001f;
beeper->input->id.product = 0x0001;
beeper->input->id.version = 0x0100;
-
- beeper->input->evbit[0] = BIT(EV_SND);
- beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL);
-
beeper->input->event = pwm_beeper_event;
+ input_set_capability(beeper->input, EV_SND, SND_TONE | SND_BELL);
input_set_drvdata(beeper->input, beeper);
error = input_register_device(beeper->input);
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index 54116e5..7b55c97 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -156,12 +156,10 @@ static int sparcspkr_probe(struct device *dev)
input_dev->id.product = 0x0001;
input_dev->id.version = 0x0100;
input_dev->dev.parent = dev;
-
- input_dev->evbit[0] = BIT_MASK(EV_SND);
- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
-
input_dev->event = state->event;
+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
+
error = input_register_device(input_dev);
if (error) {
input_free_device(input_dev);
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1] input: make use of the input_set_capability helper
2015-01-07 7:31 [PATCH v1] input: make use of the input_set_capability helper Olliver Schinagl
@ 2015-01-07 7:57 ` Dmitry Torokhov
2015-01-07 8:19 ` Olliver Schinagl
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2015-01-07 7:57 UTC (permalink / raw)
To: Olliver Schinagl
Cc: Wolfram Sang, Paul Gortmaker, Jingoo Han, David S. Miller,
Sam Ravnborg, Olliver Schinagl, linux-input, linux-kernel
Hi Olliver,
On Wed, Jan 07, 2015 at 08:31:06AM +0100, Olliver Schinagl wrote:
> From: Olliver Schinagl <oliver@schinagl.nl>
>
> Almost all of the speaker drivers under input manipulate the ev bits
> directly, which is not needed, as there is a helper available.
>
> This patch makes use of the helper for the speaker drivers.
>
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> ---
> drivers/input/misc/cm109.c | 4 ++--
> drivers/input/misc/ixp4xx-beeper.c | 5 ++---
> drivers/input/misc/m68kspkr.c | 5 ++---
> drivers/input/misc/pcspkr.c | 5 ++---
> drivers/input/misc/pwm-beeper.c | 5 +----
> drivers/input/misc/sparcspkr.c | 6 ++----
> 6 files changed, 11 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
> index 9365535..8e41070 100644
> --- a/drivers/input/misc/cm109.c
> +++ b/drivers/input/misc/cm109.c
> @@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
> input_dev->keycodesize = sizeof(unsigned char);
> input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
>
> - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
> - input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
> + input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
No, input_set_capability() takes single event code, not bitmask. The
fact that it works for these 2 values of SND events is pure coincidence
(the old code wasn't much better though).
>
> /* register available key events */
> + input_dev->evbit[0] = BIT_MASK(EV_KEY);
Would prefer __set_bit(EV_KEY, input_dev->evbit); here instead.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] input: make use of the input_set_capability helper
2015-01-07 7:57 ` Dmitry Torokhov
@ 2015-01-07 8:19 ` Olliver Schinagl
2015-01-07 8:26 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Olliver Schinagl @ 2015-01-07 8:19 UTC (permalink / raw)
To: Dmitry Torokhov, Olliver Schinagl
Cc: Wolfram Sang, Paul Gortmaker, Jingoo Han, David S. Miller,
Sam Ravnborg, linux-input, linux-kernel
Hey Dmitry,
On 07-01-15 08:57, Dmitry Torokhov wrote:
> Hi Olliver,
>
> On Wed, Jan 07, 2015 at 08:31:06AM +0100, Olliver Schinagl wrote:
>> From: Olliver Schinagl <oliver@schinagl.nl>
>>
>> Almost all of the speaker drivers under input manipulate the ev bits
>> directly, which is not needed, as there is a helper available.
>>
>> This patch makes use of the helper for the speaker drivers.
>>
>> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
>> ---
>> drivers/input/misc/cm109.c | 4 ++--
>> drivers/input/misc/ixp4xx-beeper.c | 5 ++---
>> drivers/input/misc/m68kspkr.c | 5 ++---
>> drivers/input/misc/pcspkr.c | 5 ++---
>> drivers/input/misc/pwm-beeper.c | 5 +----
>> drivers/input/misc/sparcspkr.c | 6 ++----
>> 6 files changed, 11 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
>> index 9365535..8e41070 100644
>> --- a/drivers/input/misc/cm109.c
>> +++ b/drivers/input/misc/cm109.c
>> @@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
>> input_dev->keycodesize = sizeof(unsigned char);
>> input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
>>
>> - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
>> - input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
>> + input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
> No, input_set_capability() takes single event code, not bitmask. The
> fact that it works for these 2 values of SND events is pure coincidence
> (the old code wasn't much better though).
What do you suggest we should do then? Fix input_set_capability to take
bit masks? or multiline events?
I'm not sure why __set_bits() wouldn't work for bitmasks, could you
educate me?
>
>>
>> /* register available key events */
>> + input_dev->evbit[0] = BIT_MASK(EV_KEY);
> Would prefer __set_bit(EV_KEY, input_dev->evbit); here instead.
I only moved the EV_KEY bit from above to its appropiate place here. I
can change this one (and others) to use __set_bit() for now for v2?
Olliver
>
> Thanks.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] input: make use of the input_set_capability helper
2015-01-07 8:19 ` Olliver Schinagl
@ 2015-01-07 8:26 ` Dmitry Torokhov
2015-01-07 9:41 ` Olliver Schinagl
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2015-01-07 8:26 UTC (permalink / raw)
To: Olliver Schinagl
Cc: Olliver Schinagl, Wolfram Sang, Paul Gortmaker, Jingoo Han,
David S. Miller, Sam Ravnborg, linux-input, linux-kernel
On Wed, Jan 07, 2015 at 09:19:28AM +0100, Olliver Schinagl wrote:
> Hey Dmitry,
>
> On 07-01-15 08:57, Dmitry Torokhov wrote:
> >Hi Olliver,
> >
> >On Wed, Jan 07, 2015 at 08:31:06AM +0100, Olliver Schinagl wrote:
> >>From: Olliver Schinagl <oliver@schinagl.nl>
> >>
> >>Almost all of the speaker drivers under input manipulate the ev bits
> >>directly, which is not needed, as there is a helper available.
> >>
> >>This patch makes use of the helper for the speaker drivers.
> >>
> >>Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> >>---
> >> drivers/input/misc/cm109.c | 4 ++--
> >> drivers/input/misc/ixp4xx-beeper.c | 5 ++---
> >> drivers/input/misc/m68kspkr.c | 5 ++---
> >> drivers/input/misc/pcspkr.c | 5 ++---
> >> drivers/input/misc/pwm-beeper.c | 5 +----
> >> drivers/input/misc/sparcspkr.c | 6 ++----
> >> 6 files changed, 11 insertions(+), 19 deletions(-)
> >>
> >>diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
> >>index 9365535..8e41070 100644
> >>--- a/drivers/input/misc/cm109.c
> >>+++ b/drivers/input/misc/cm109.c
> >>@@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
> >> input_dev->keycodesize = sizeof(unsigned char);
> >> input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
> >>- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
> >>- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
> >>+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
> >No, input_set_capability() takes single event code, not bitmask. The
> >fact that it works for these 2 values of SND events is pure coincidence
> >(the old code wasn't much better though).
Ah, not, it does not work at all. Instead of setting bits 1 and 2 your
code sets bit 3 in dev->sndbit.
> What do you suggest we should do then? Fix input_set_capability to
> take bit masks? or multiline events?
> I'm not sure why __set_bits() wouldn't work for bitmasks, could you
> educate me?
Call it once per event:
input_set_capability(input_dev, EV_SND, SND_BELL);
input_set_capability(input_dev, EV_SND, SND_TONE);
> >
> >> /* register available key events */
> >>+ input_dev->evbit[0] = BIT_MASK(EV_KEY);
> >Would prefer __set_bit(EV_KEY, input_dev->evbit); here instead.
> I only moved the EV_KEY bit from above to its appropiate place here.
The original code was setting combination of bits; here we set single
one and __set_bit() is cleaner IMO.
> I can change this one (and others) to use __set_bit() for now for
> v2?
Yes, please.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] input: make use of the input_set_capability helper
2015-01-07 8:26 ` Dmitry Torokhov
@ 2015-01-07 9:41 ` Olliver Schinagl
2015-01-07 17:43 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Olliver Schinagl @ 2015-01-07 9:41 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Olliver Schinagl, Wolfram Sang, Paul Gortmaker, Jingoo Han,
David S. Miller, Sam Ravnborg, linux-input, linux-kernel
HEy Dmitry,
On 07-01-15 09:26, Dmitry Torokhov wrote:
> On Wed, Jan 07, 2015 at 09:19:28AM +0100, Olliver Schinagl wrote:
>> Hey Dmitry,
>>
>> On 07-01-15 08:57, Dmitry Torokhov wrote:
>>> Hi Olliver,
>>>
>>> On Wed, Jan 07, 2015 at 08:31:06AM +0100, Olliver Schinagl wrote:
>>>> From: Olliver Schinagl <oliver@schinagl.nl>
>>>>
>>>> Almost all of the speaker drivers under input manipulate the ev bits
>>>> directly, which is not needed, as there is a helper available.
>>>>
>>>> This patch makes use of the helper for the speaker drivers.
>>>>
>>>> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
>>>> ---
>>>> drivers/input/misc/cm109.c | 4 ++--
>>>> drivers/input/misc/ixp4xx-beeper.c | 5 ++---
>>>> drivers/input/misc/m68kspkr.c | 5 ++---
>>>> drivers/input/misc/pcspkr.c | 5 ++---
>>>> drivers/input/misc/pwm-beeper.c | 5 +----
>>>> drivers/input/misc/sparcspkr.c | 6 ++----
>>>> 6 files changed, 11 insertions(+), 19 deletions(-)
>>>>
>>>> diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
>>>> index 9365535..8e41070 100644
>>>> --- a/drivers/input/misc/cm109.c
>>>> +++ b/drivers/input/misc/cm109.c
>>>> @@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
>>>> input_dev->keycodesize = sizeof(unsigned char);
>>>> input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
>>>> - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
>>>> - input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
>>>> + input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
>>> No, input_set_capability() takes single event code, not bitmask. The
>>> fact that it works for these 2 values of SND events is pure coincidence
>>> (the old code wasn't much better though).
> Ah, not, it does not work at all. Instead of setting bits 1 and 2 your
> code sets bit 3 in dev->sndbit.
>
>> What do you suggest we should do then? Fix input_set_capability to
>> take bit masks? or multiline events?
>> I'm not sure why __set_bits() wouldn't work for bitmasks, could you
>> educate me?
> Call it once per event:
>
> input_set_capability(input_dev, EV_SND, SND_BELL);
> input_set_capability(input_dev, EV_SND, SND_TONE);
roger, done
>
>>>> /* register available key events */
>>>> + input_dev->evbit[0] = BIT_MASK(EV_KEY);
>>> Would prefer __set_bit(EV_KEY, input_dev->evbit); here instead.
>> I only moved the EV_KEY bit from above to its appropiate place here.
> The original code was setting combination of bits; here we set single
> one and __set_bit() is cleaner IMO.
The documentation contradicts this actually, it says to use set_bit()
first, but favors the direct writing as above as it is 'shorter in some
cases'.
Furthermore, I'm a little confused as what the purpose of
input_set_capability() is, if we use set_bits (or __set_bits) here. It
appears we use set_bits here because it is manipulating several entries
in the array (well atleast index 0) and set_input_capability() doesn't
handle arrays? But when I look at struct input_dev, all those entries
are arrays, including sndbit. So we only use set_input_capabilities when
manipulating index 0 when its the only one? Feels a little strange to
me, but probably is my lack of knowledge herin, so appologies for that.
Olliver
>
>> I can change this one (and others) to use __set_bit() for now for
>> v2?
> Yes, please.
>
> Thanks.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] input: make use of the input_set_capability helper
2015-01-07 9:41 ` Olliver Schinagl
@ 2015-01-07 17:43 ` Dmitry Torokhov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2015-01-07 17:43 UTC (permalink / raw)
To: Olliver Schinagl
Cc: Olliver Schinagl, Wolfram Sang, Paul Gortmaker, Jingoo Han,
David S. Miller, Sam Ravnborg, linux-input, linux-kernel
On Wed, Jan 07, 2015 at 10:41:24AM +0100, Olliver Schinagl wrote:
> HEy Dmitry,
>
> On 07-01-15 09:26, Dmitry Torokhov wrote:
> >On Wed, Jan 07, 2015 at 09:19:28AM +0100, Olliver Schinagl wrote:
> >>Hey Dmitry,
> >>
> >>On 07-01-15 08:57, Dmitry Torokhov wrote:
> >>>Hi Olliver,
> >>>
> >>>On Wed, Jan 07, 2015 at 08:31:06AM +0100, Olliver Schinagl wrote:
> >>>>From: Olliver Schinagl <oliver@schinagl.nl>
> >>>>
> >>>>Almost all of the speaker drivers under input manipulate the ev bits
> >>>>directly, which is not needed, as there is a helper available.
> >>>>
> >>>>This patch makes use of the helper for the speaker drivers.
> >>>>
> >>>>Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> >>>>---
> >>>> drivers/input/misc/cm109.c | 4 ++--
> >>>> drivers/input/misc/ixp4xx-beeper.c | 5 ++---
> >>>> drivers/input/misc/m68kspkr.c | 5 ++---
> >>>> drivers/input/misc/pcspkr.c | 5 ++---
> >>>> drivers/input/misc/pwm-beeper.c | 5 +----
> >>>> drivers/input/misc/sparcspkr.c | 6 ++----
> >>>> 6 files changed, 11 insertions(+), 19 deletions(-)
> >>>>
> >>>>diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c
> >>>>index 9365535..8e41070 100644
> >>>>--- a/drivers/input/misc/cm109.c
> >>>>+++ b/drivers/input/misc/cm109.c
> >>>>@@ -767,10 +767,10 @@ static int cm109_usb_probe(struct usb_interface *intf,
> >>>> input_dev->keycodesize = sizeof(unsigned char);
> >>>> input_dev->keycodemax = ARRAY_SIZE(dev->keymap);
> >>>>- input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_SND);
> >>>>- input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
> >>>>+ input_set_capability(input_dev, EV_SND, SND_BELL | SND_TONE);
> >>>No, input_set_capability() takes single event code, not bitmask. The
> >>>fact that it works for these 2 values of SND events is pure coincidence
> >>>(the old code wasn't much better though).
> >Ah, not, it does not work at all. Instead of setting bits 1 and 2 your
> >code sets bit 3 in dev->sndbit.
> >
> >>What do you suggest we should do then? Fix input_set_capability to
> >>take bit masks? or multiline events?
> >>I'm not sure why __set_bits() wouldn't work for bitmasks, could you
> >>educate me?
> >Call it once per event:
> >
> > input_set_capability(input_dev, EV_SND, SND_BELL);
> > input_set_capability(input_dev, EV_SND, SND_TONE);
> roger, done
> >
> >>>> /* register available key events */
> >>>>+ input_dev->evbit[0] = BIT_MASK(EV_KEY);
> >>>Would prefer __set_bit(EV_KEY, input_dev->evbit); here instead.
> >>I only moved the EV_KEY bit from above to its appropiate place here.
> >The original code was setting combination of bits; here we set single
> >one and __set_bit() is cleaner IMO.
> The documentation contradicts this actually, it says to use
> set_bit() first, but favors the direct writing as above as it is
> 'shorter in some cases'.
Right, sometimes, when you need to set 3-4 values on evbit (that is
pretty much guaranteed to fit into one long word) it is shoerted to
write
input->evbit[0] = BIT(EV_A) | BIT(EV_B) | BIT(EV_C);
it is shorted, but it is not that great as it relies on knowledge of
EV_* values. Now relying on that knowledge is pretty safe as they form
userspace ABI and will not be changed, only extended. But nowadays I
prefer using __set_bit() or input_set_capability() if possible.
>
> Furthermore, I'm a little confused as what the purpose of
> input_set_capability() is, if we use set_bits (or __set_bits) here.
> It appears we use set_bits here because it is manipulating several
> entries in the array (well atleast index 0) and
> set_input_capability() doesn't handle arrays? But when I look at
> struct input_dev, all those entries are arrays, including sndbit. So
> we only use set_input_capabilities when manipulating index 0 when
> its the only one? Feels a little strange to me, but probably is my
> lack of knowledge herin, so appologies for that.
__set_bit() sets arbitrary bit in memory started at given address. So to
set bit 65 (or bit 1 in the 3rd element of u32 array a) on you do:
__set_bit(65, a);
input_set_capability() is a wrapper that does set both evbit and
appropriate *bit for given event type and event code and caller does not
need to know all the details about bitmap names inside input device
structure.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-01-07 17:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-07 7:31 [PATCH v1] input: make use of the input_set_capability helper Olliver Schinagl
2015-01-07 7:57 ` Dmitry Torokhov
2015-01-07 8:19 ` Olliver Schinagl
2015-01-07 8:26 ` Dmitry Torokhov
2015-01-07 9:41 ` Olliver Schinagl
2015-01-07 17:43 ` Dmitry Torokhov
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.