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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux