[PATCH v2 5/9] staging: kpc2000: use atomic_t to assign card numbers.

Greg KH gregkh at linuxfoundation.org
Fri May 17 07:13:18 UTC 2019

On Thu, May 16, 2019 at 10:14:56PM +0000, Matt Sickler wrote:
> >-----Original Message-----
> >From: devel <driverdev-devel-bounces at linuxdriverproject.org> On Behalf Of
> >Previously the next card number was assigned from a static int local variable,
> >which was read and later incremented.  This was not thread- safe, so now we
> >use an atomic_t and atomic_fetch_add instead.
> Switching to atomic_fetch_add is definitely an improvement over what that code
> was doing prior, but is that the proper solution?  How do other parts of the
> kernel handle giving devices unique ID numbers?

You use an "ida" structure.  That's the correct solution here, don't
mess with an atomic variable, that's not needed.


greg k-h

More information about the devel mailing list