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 Sat, Mar 28, 2020 at 07:56:17PM -0700, Matthew Wilcox wrote:
> 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);

Oops. NUM_MINORS - 1. Or #define MAX_MINOR 255 since you only seem to use
NUM_MINORS in this one place.

> ...
> ida_free(&minors, MINOR(ocxlpmem->dev.devt));
> ...
> and you can drop the dynamic initialisation. And the mutex.

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