linux-mips
[Top] [All Lists]

Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver

To: Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH v5 8/8] Loongson: YeeLoong: add hotkey driver
From: Wu Zhangjin <wuzhangjin@gmail.com>
Date: Mon, 30 Nov 2009 13:18:15 +0800
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>, linux-mips@linux-mips.org, zhangfx@lemote.com, yanh@lemote.com, huhb@lemote.com, linux-input@vger.kernel.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:reply-to:to:cc :in-reply-to:references:content-type:organization:date:message-id :mime-version:x-mailer:content-transfer-encoding; bh=MxPtv0zZOnbIkmtXl+h8vFRxkgZssuc52Jr0DWR3avk=; b=S4n5t2+WOr7SzNXfFCRIwAK9sxocD5YZ5xM5LY9gnObvYyiD+m7gtCu/OImSxXXqIG Z1UttfjC8KjRmgZ3IWodZbucZvlm0KA7EDw1sCZ/RR3Lul//kDQLuOyNWKJqZzCSWeDi iPt9KcHg+XA9mSk6oLqyFNZZqhv+VwvhC0tJY=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:reply-to:to:cc:in-reply-to:references:content-type :organization:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=ZO2QtsH2fw28m7uQxKhubABTzhwzcluI9kFIE/JyMg/3t2i8U27tNKyTCRkEL+8TZ4 jTw+FfUUe9GtiGVB419lsIgAc7dtaxZOOgJ6NqugPRXuD3Dq5IppfnRYUxy3MdrrDyRJ dG3ytK5BuOW7DDo+1Ci3mydDa9Z+vsCm25kKE=
In-reply-to: <739db9c7b5bab429d0df5a7c68f301aa12f1402d.1259414649.git.wuzhangjin@gmail.com>
Organization: DSLab, Lanzhou University, China
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.1259414649.git.wuzhangjin@gmail.com> <739db9c7b5bab429d0df5a7c68f301aa12f1402d.1259414649.git.wuzhangjin@gmail.com>
Reply-to: wuzhangjin@gmail.com
Sender: linux-mips-bounce@linux-mips.org
On Sat, 2009-11-28 at 21:44 +0800, Wu Zhangjin wrote:
[...]
> +
> +static int camera_handler(int status)
> +{
> +     int value;
> +     static int camera_status;
> +
> +     status = !!status;
> +     camera_status = ec_read(REG_CAMERA_STATUS);
> +     if (status != camera_status) {
> +             value = ec_read(REG_CAMERA_CONTROL);
> +             ec_write(REG_CAMERA_CONTROL, value | (1 << 1));
> +     }
> +     return ec_read(REG_CAMERA_STATUS);
> +}

The above stuff is very awful, the camera event work as a switch, so
this is enough:

static int camera_handler(int status)
{
        int value;

        value = ec_read(REG_CAMERA_CONTROL);
        ec_write(REG_CAMERA_CONTROL, value | (1 << 1));

        return status;
}

[...]
> +/*
> + * SCI(system control interrupt) main interrupt routine
> + *
> + * We will do the query and get event number together so the interrupt 
> routine
> + * should be longer than 120us now at least 3ms elpase for it.
> + */
> +static irqreturn_t sci_irq_handler(int irq, void *dev_id)
> +{
> +     int ret;
> +
> +     if (SCI_IRQ_NUM != irq)
> +             return IRQ_NONE;
> +
> +     /* Query the event number */
> +     ret = ec_query_event_num();
> +     if (ret < 0)
> +             return IRQ_NONE;
> +
> +     event = ec_get_event_num();
> +     if (event < 0)
> +             return IRQ_NONE;
> +
> +     if ((event != 0x00) && (event != 0xff)) {

It's better to use somethig else:

if (event >= EVENT_START && event <= EVENT_END) {
....

Best Regards,
        Wu Zhangjin


<Prev in Thread] Current Thread [Next in Thread>