[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.02.1412181447160.25208@linuxheads99>
Date: Thu, 18 Dec 2014 14:50:09 -0600
From: atull <atull@...nsource.altera.com>
To: Grant Likely <grant.likely@...aro.org>
CC: Pavel Machek <pavel@...x.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jason Gunthorpe <jgunthorpe@...idianresearch.com>,
"H. Peter Anvin" <hpa@...or.com>,
"Michal Simek" <monstr@...str.eu>,
Michal Simek <michal.simek@...inx.com>,
"Randy Dunlap" <rdunlap@...radead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
Pantelis Antoniou <pantelis.antoniou@...sulko.com>,
Rob Herring <robh+dt@...nel.org>,
"Ira Snyder" <iws@...o.caltech.edu>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
Mark Brown <broonie@...nel.org>, <philip@...ister.org>,
rubini <rubini@...dd.com>,
Steffen Trumtrar <s.trumtrar@...gutronix.de>,
Jason <jason@...edaemon.net>, <kyle.teske@...com>,
Nicolas Pitre <nico@...aro.org>,
"Balbi, Felipe" <balbi@...com>,
Mauro Carvalho Chehab <m.chehab@...sung.com>,
David Brown <davidb@...eaurora.org>,
Rob Landley <rob@...dley.net>,
David Miller <davem@...emloft.net>, <cesarb@...arb.net>,
"sameo@...ux.intel.com" <sameo@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"Linus Walleij" <linus.walleij@...aro.org>,
Alan Tull <delicious.quinoa@...il.com>,
<dinguyen@...nsource.altera.com>,
Yves Vandervennet <yvanderv@...nsource.altera.com>
Subject: Re: [PATCH v2 2/3] fpga manager: framework core
On Sat, 6 Dec 2014, Grant Likely wrote:
> >> +int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count)
> >> +{
> >> + int ret;
> >> +
> >> + if (test_and_set_bit_lock(FPGA_MGR_BUSY, &mgr->flags))
> >> + return -EBUSY;
> >> +
> >> + dev_info(mgr->dev, "writing buffer to %s\n", mgr->name);
> >> +
> >> + ret = __fpga_mgr_write(mgr, buf, count);
> >> + clear_bit_unlock(FPGA_MGR_BUSY, &mgr->flags);
> >> +
> >> + return ret;
> >> +}
> >> +EXPORT_SYMBOL_GPL(fpga_mgr_write);
> >
> > Is the EBUSY -- userspace please try again, but you don't know when to
> > try again -- right interface? I mean, normally kernel would wait, so
> > that userland does not have to poll?
>
> Custom locking schemes are just wrong. A mutex is the right thing to
> do here and then an -EBUSY isn't required.
>
I've changed it to a mutex in the next version.
> >
> >> +static ssize_t fpga_mgr_firmware_store(struct device *dev,
> >> + struct device_attribute *attr,
> >> + const char *buf, size_t count)
> >> +{
> >> + struct fpga_manager *mgr = dev_get_drvdata(dev);
> >> + unsigned int len;
> >> + char image_name[NAME_MAX];
>
> Hard coding a string length is a warning sign. That is the sort of
> thing that can memdup() or strdup() can handle.
>
OK, I'll fix it using kstrdup() in v6.
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists