2010-11-03 13:20:28

by Jiri Kosina

[permalink] [raw]
Subject: Re: Resend [PATCH 3/4] MacbookAir3,1 and 3,2 hid support

On Tue, 26 Oct 2010, gimli wrote:

> This patch adds support for the new MacBookAir3,1 and 3,2 to the hid
> driver.
>
> Updated names names acording Apples kext.
>
> Signed-off-by: Edgar (gimli) Hucek <[email protected]>

> - trans = apple_find_translation((hid->product < 0x21d ||
> + if(hid->product >= 0x023f && hid->product <= 0x0244 ) {
> + trans = apple_find_translation(macbookair_fn_keys, usage->code);
> + } else {
> + trans = apple_find_translation((hid->product < 0x21d ||
> hid->product >= 0x300) ?
> powerbook_fn_keys : apple_fn_keys,
> usage->code);

Could you please make this nicer? Having if and ternary operator both
there to chose the translation table looks really confusing.

Thanks,

--
Jiri Kosina
SUSE Labs, Novell Inc.


2010-11-03 13:50:42

by gimli

[permalink] [raw]
Subject: Re: Resend [PATCH 3/4] MacbookAir3,1 and 3,2 hid support

Does this look better ? I also use the USB id's for the if.


On Wed, 3 Nov 2010 09:20:25 -0400 (EDT), Jiri Kosina <[email protected]>
wrote:
> On Tue, 26 Oct 2010, gimli wrote:
>
>> This patch adds support for the new MacBookAir3,1 and 3,2 to the hid
>> driver.
>>
>> Updated names names acording Apples kext.
>>
>> Signed-off-by: Edgar (gimli) Hucek <[email protected]>
>
>> - trans = apple_find_translation((hid->product < 0x21d ||
>> + if(hid->product >= 0x023f && hid->product <= 0x0244 ) {
>> + trans =
>> apple_find_translation(macbookair_fn_keys, usage->code);
>> + } else {
>> + trans = apple_find_translation((hid->product <
>> 0x21d ||
>> hid->product >= 0x300) ?
>> powerbook_fn_keys :
apple_fn_keys,
>> usage->code);
>
> Could you please make this nicer? Having if and ternary operator both
> there to chose the translation table looks really confusing.
>
> Thanks,


Attachments:
hid_macbookair_1.patch (6.04 kB)

2010-11-03 13:56:24

by Jiri Kosina

[permalink] [raw]
Subject: Re: Resend [PATCH 3/4] MacbookAir3,1 and 3,2 hid support

On Wed, 3 Nov 2010, gimli wrote:

> Does this look better ?

What I would actually prefer would be something like


if ( ... )
table = macbookair_fn_keys;
else if ( ... )
table = powerbook_fn_keys;
else
table = apple_fn_keys;

apple_find_translation(table, usage->code);

> I also use the USB id's for the if.

Thanks,

--
Jiri Kosina
SUSE Labs, Novell Inc.

2010-11-03 14:25:37

by gimli

[permalink] [raw]
Subject: Re: Resend [PATCH 3/4] MacbookAir3,1 and 3,2 hid support

Next try.

On Wed, 3 Nov 2010 09:56:21 -0400 (EDT), Jiri Kosina <[email protected]>
wrote:
> On Wed, 3 Nov 2010, gimli wrote:
>
>> Does this look better ?
>
> What I would actually prefer would be something like
>
>
> if ( ... )
> table = macbookair_fn_keys;
> else if ( ... )
> table = powerbook_fn_keys;
> else
> table = apple_fn_keys;
>
> apple_find_translation(table, usage->code);
>
>> I also use the USB id's for the if.
>
> Thanks,


Attachments:
hid_macbookair_2.patch (6.17 kB)

2010-11-03 14:44:31

by Jiri Kosina

[permalink] [raw]
Subject: Re: Resend [PATCH 3/4] MacbookAir3,1 and 3,2 hid support

On Wed, 3 Nov 2010, gimli wrote:

>
> On Wed, 3 Nov 2010 09:56:21 -0400 (EDT), Jiri Kosina <[email protected]>
> wrote:
> > On Wed, 3 Nov 2010, gimli wrote:
> >
> >> Does this look better ?
> >
> > What I would actually prefer would be something like
> >
> >
> > if ( ... )
> > table = macbookair_fn_keys;
> > else if ( ... )
> > table = powerbook_fn_keys;
> > else
> > table = apple_fn_keys;
> >
> > apple_find_translation(table, usage->code);
> >
> >> I also use the USB id's for the if.
> Next try.

I have slightly modified the code to be more like what I proposed above,
and applied the patch. Thanks a lot,

--
Jiri Kosina
SUSE Labs, Novell Inc.