Re: [RFC/PATCH 1/2] usb: gadget: u_char: introduce chardev abstraction layer

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

 



Felipe Balbi <felipe.balbi@...> writes:
> +	/* prevent multiple opens for now */
> +	if (gc->opened)
> +		return -EBUSY;
> +	spin_lock_irq(&gc->lock);
> +	if (gc->opened) {
> +		spin_unlock_irq(&gc->lock);
> +		return -EBUSY;
> +	}
> +	gc->opened = 1;
> +	spin_unlock_irq(&gc->lock);

How about test_and_set_bit or xchg?

+	if (xchg(&gc->opened, 1))
+		return -EBUSY;

> +	if (!gc->opened)
> +		goto gc_release_exit;
[...]
> +	spin_lock_irq(&gc->lock);
> +	gc->opened = 0;
> +	spin_unlock_irq(&gc->lock);

And same here.

+	if (!xchg(&gc->opened, 0))
+		goto gc_release_exit;

> +/**
> + * gchar_cleanup - remove the USB to character devicer and devices

Typo: "devicer"


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux