← Back to team overview

ac100 team mailing list archive

Re: [PATCH 1/2] Manage wake up Events

 

On Sun, Oct 23, 2011 at 16:18, Pierre-Hugues Husson <phhusson@xxxxxxxxx> wrote:
> Le dimanche 23 octobre 2011 13:01:38, Leon Romanovsky a écrit :
>> On Sun, Oct 23, 2011 at 04:13, Pierre-Hugues Husson <phhusson@xxxxxxxxx>
> wrote:
>> > +       {
>> > +               //Resume on home key press
>> > +               char cmd[]={ 0x05, 0x03, 0x01, 0x02};
>> > +               cmd[2]=!!wakeup_on_home_key;
>> > +               nvec_write_async(nvec, cmd, sizeof(cmd));
>> > +       }
>> > +}
>>
>> It is better to use the same coding style as was already in nvec
>> nvec_write_async(nvec, cmd, sizeof(cmd)); ===> nvec_write_async(nvec,
>> "\x05\x03\x01\x02", 4);
> So the code would look like:
> if(wakeup_on_home_key)
>        nvec_write_async(nvec, "\x05\x03\x01\x02", 4);
> else
>        nvec_write_async(nvec, "\x05\x03\x00\x02", 4);
> ?
> I find it less understandable (as in which field is of which use).
> But well, all nvec code is mostly about magic code, so why not.
To be honest, I'll be done it differently

I'll be place definitions at the top of the code, something like that:
#define NVEC_WAKE_ON_HOME_KEY_CMD                     "\x05\x03\x01\x02"
#define NVEC_WAKE_ON_HOME_KEY_CMD_SIZE            4
#define NVEC_NOT_WAKE_ON_HOME_KEY_CMD            "\x05\x03\x00\x02"
#define NVEC_NOT_WAKE_ON_HOME_KEY_CMD_SIZE  4

if(wakeup_on_home_key)
       nvec_write_async(nvec, NVEC_WAKE_ON_HOME_KEY_CMD,
NVEC_WAKE_ON_HOME_KEY_CMD_SIZE);
else
       nvec_write_async(nvec, NVEC_NOT_WAKE_ON_HOME_KEY_CMD,
NVEC_NOT_WAKE_ON_HOME_KEY_CMD_SIZE);

Sure, it is only proposal.

-- 
Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | leon@xxxxxxx


References