[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180228163116.GA19292@bombadil.infradead.org>
Date: Wed, 28 Feb 2018 08:31:16 -0800
From: Matthew Wilcox <willy@...radead.org>
To: Kai Heng Feng <kai.heng.feng@...onical.com>
Cc: gregkh@...uxfoundation.org, oneukum@...e.com, corbet@....net,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-usb@...r.kernel.org
Subject: Re: [PATCH v4] usb: core: Add "quirks" parameter for usbcore
On Thu, Mar 01, 2018 at 12:01:40AM +0800, Kai Heng Feng wrote:
> > Also, you won't need to use a linked list for this; you can just allocate
> > an array of quirks.
>
> I use linked list because the total quirks number is known after the entire
> string gets parsed.
> Do you suggest that I should just alloc a predefined number (like 16) quirk
> entries, instead of doing it dynamically?
I'd just do:
unsigned int nr = 1;
for (i = 0; i < len; i++)
if (str[i] == ',')
nr++;
kcalloc(nr, sizeof(struct), GFP_KERNEL);
Powered by blists - more mailing lists