Re: [PATCH 01/10] usb-serial: URB write locking macros.

From: Luiz Fernando Capitulino
Date: Tue Dec 06 2005 - 07:37:00 EST



Hi Arjan,

On Tue, 06 Dec 2005 13:24:03 +0100
Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:

| On Tue, 2005-12-06 at 09:57 -0200, Luiz Fernando Capitulino wrote:
| > Introduces URB write locking macros.
|
| ugh.. WHY ?

Because is easier to read/understand:

if (usb_serial_write_urb_lock(port)) {
dbg("%s - already writing", __FUNCTION__);
return 0;
}

than:

if (!atomic_add_unless(&port->write_urb_busy, 1, 1)) {
dbg("%s - already writing", __FUNCTION__);
return 0;
}

IMHO.

Of course I'm only ilustrating the 'lock' scenario, but you will have other
atomic functions spread in the driver.

Looks better to have some macros to make clear what you're doing.

--
Luiz Fernando N. Capitulino
-
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/