lkml.org 
[lkml]   [2020]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v4 10/25] nvdimm: Add driver for OpenCAPI Persistent Memory
    On Fri, Mar 27, 2020 at 06:11:47PM +1100, Alastair D'Silva wrote:
    > +static struct mutex minors_idr_lock;
    > +static struct idr minors_idr;
    ...
    > + mutex_lock(&minors_idr_lock);
    > + minor = idr_alloc(&minors_idr, ocxlpmem, 0, NUM_MINORS, GFP_KERNEL);
    > + mutex_unlock(&minors_idr_lock);
    ...
    > + mutex_lock(&minors_idr_lock);
    > + idr_remove(&minors_idr, MINOR(ocxlpmem->dev.devt));
    > + mutex_unlock(&minors_idr_lock);
    ...
    > + mutex_init(&minors_idr_lock);
    > + idr_init(&minors_idr);

    Unless you look up ocxlpmem by minor number later in the patch series (and
    most of the series didn't make it to my mailbox), this can just be an ida.

    static DEFINE_IDA(minors);
    ...
    minor = ida_alloc_max(&minors, NUM_MINORS, GFP_KERNEL);
    ...
    ida_free(&minors, MINOR(ocxlpmem->dev.devt));
    ...
    and you can drop the dynamic initialisation. And the mutex.

    \
     
     \ /
      Last update: 2020-03-29 04:58    [W:4.119 / U:0.296 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site