Re: [PATCH] Driver for IBM RSA service processor (1/2)

From: Francois Romieu
Date: Mon Feb 02 2004 - 17:09:01 EST


Max Asbock <masbock@xxxxxxxxxx> :
> diff -urN linux-2.6.1/drivers/misc/ibmasm/event.c linux-2.6.1-ibmasm/drivers/misc/ibmasm/event.c
> --- linux-2.6.1/drivers/misc/ibmasm/event.c 1969-12-31 16:00:00.000000000 -0800
> +++ linux-2.6.1-ibmasm/drivers/misc/ibmasm/event.c 2004-01-20 11:16:29.000000000 -0800
[...]
> +void ibmasm_receive_event(struct service_processor *sp, void *data, size_t data_size)
> +{
[...]
> + /* advance indices in the buffer */
> + buffer->next_index = ++(buffer->next_index) % IBMASM_NUM_EVENTS;

-> buffer->next_index = (buffer->next_index + 1) % IBMASM_NUM_EVENTS;

> diff -urN linux-2.6.1/drivers/misc/ibmasm/module.c linux-2.6.1-ibmasm/drivers/misc/ibmasm/module.c
> --- linux-2.6.1/drivers/misc/ibmasm/module.c 1969-12-31 16:00:00.000000000 -0800
> +++ linux-2.6.1-ibmasm/drivers/misc/ibmasm/module.c 2004-01-20 13:05:38.000000000 -0800
[...]
> +static int __init ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
> +{
> + int result = 0;

-> It can be set directly to -ENOMEM (and removed from several lines below).
It will be overriden later if everything succeeds.

> diff -urN linux-2.6.1/drivers/misc/ibmasm/remote.c linux-2.6.1-ibmasm/drivers/misc/ibmasm/remote.c
> --- linux-2.6.1/drivers/misc/ibmasm/remote.c 1969-12-31 16:00:00.000000000 -0800
> +++ linux-2.6.1-ibmasm/drivers/misc/ibmasm/remote.c 2004-01-14 16:42:01.000000000 -0800
[...]
> +void ibmasm_free_remote_queue(struct service_processor *sp)
> +{
> + if (sp->remote_queue.start)
> + kfree(sp->remote_queue.start);
> +}

-> kfree(NULL) does not hurt. The 'if' can be removed.

[...]
> +size_t ibmasm_events_available(struct remote_queue *q)
> +{
> + ssize_t diff = q->writer - q->reader;
> +
> + if (diff >= 0)
> + return diff;
> + else
> + return (q->end - q->reader);
> +}

-> return (diff >= 0) ? diff : q->end - q->reader;
Your choice.

--
Ueimor
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/