From: Michal Simek <monstr@monstr.eu>
To: Joe Perches <joe@perches.com>
Cc: Michal Simek <michal.simek@xilinx.com>,
linux-kernel@vger.kernel.org, Alan Tull <atull@altera.com>,
Pavel Machek <pavel@ucw.cz>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dinh Nguyen <dinguyen@altera.com>,
Philip Balister <philip@balister.org>,
Alessandro Rubini <rubini@gnudd.com>,
Mauro Carvalho Chehab <m.chehab@samsung.com>,
Andrew Morton <akpm@linux-foundation.org>,
Cesar Eduardo Barros <cesarb@cesarb.net>,
"David S. Miller" <davem@davemloft.net>,
Stephen Warren <swarren@nvidia.com>,
Arnd Bergmann <arnd@arndb.de>,
David Brown <davidb@codeaurora.org>,
Dom Cobley <popcornmix@gmail.com>
Subject: Re: [RFC PATCH] fpga: Introduce new fpga subsystem
Date: Thu, 19 Sep 2013 12:01:20 +0200 [thread overview]
Message-ID: <523ACB70.2020000@monstr.eu> (raw)
In-Reply-To: <1379520665.1787.40.camel@joe-AO722>
[-- Attachment #1: Type: text/plain, Size: 5777 bytes --]
Hi Joe,
On 09/18/2013 06:11 PM, Joe Perches wrote:
> On Wed, 2013-09-18 at 17:56 +0200, Michal Simek wrote:
>> This new subsystem should unify all fpga drivers which
>> do the same things. Load configuration data to fpga
>> or another programmable logic through common interface.
>> It doesn't matter if it is MMIO device, gpio bitbanging,
>> etc. connection. The point is to have the same
>> inteface for these drivers.
>
> Is this really a "driver".
> Perhaps it's more of a core kernel function
> and belongs in kernel.
This is not a driver just kernel subsystem and real drivers
will register itself in this subsystem.
>
>> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
>
> The error messages are a little shouty with all
> the unnecessary "!" uses.
>
> []
Fixed.
>
>> +/**
>> + * fpga_mgr_read - Read data from fpga
>> + * @mgr: Pointer to the fpga manager structure
>> + * @buf: Pointer to the buffer location
>> + * @count: Pointer to the number of copied bytes
>> + *
>> + * Function reads fpga bitstream and copy them to output buffer.
>> + *
>> + * Returns the number of bytes copied to @buf, a negative error number otherwise
>> + */
>> +static int fpga_mgr_read(struct fpga_manager *mgr, char *buf, ssize_t *count)
>> +{
>> + int ret;
>> +
>> + if (test_and_set_bit_lock(FPGA_MGR_DEV_BUSY, &mgr->flags))
>> + return -EBUSY;
>> +
>> + if (!mgr->mops || !mgr->mops->read) {
>> + dev_err(mgr->dev,
>> + "Controller doesn't support read operations!\n");
>> + return -EPERM;
>> + }
>> +
>> + if (mgr->mops->read_init) {
>> + ret = mgr->mops->read_init(mgr);
>> + if (ret) {
>> + dev_err(mgr->dev, "Failed in read-init!\n");
>> + return ret;
>> + }
>> + }
>> +
>> + if (mgr->mops->read) {
>> + ret = mgr->mops->read(mgr, buf, count);
>> + if (ret) {
>> + dev_err(mgr->dev, "Failed to read firmware!\n");
>> + return ret;
>> + }
>> + }
>> +
>> + if (mgr->mops->read_complete) {
>> + ret = mgr->mops->read_complete(mgr);
>> + if (ret) {
>> + dev_err(mgr->dev, "Failed in read-complete!\n");
>> + return ret;
>> + }
>> + }
>> +
>> + clear_bit_unlock(FPGA_MGR_DEV_BUSY, &mgr->flags);
>> +
>> + return 0;
>> +}
>> +
>> +/**
>> + * fpga_mgr_attr_read - Read data from fpga
>> + * @dev: Pointer to the device structure
>> + * @attr: Pointer to the device attribute structure
>> + * @buf: Pointer to the buffer location
>> + *
>> + * Function reads fpga bitstream and copy them to output buffer
>> + *
>> + * Returns the number of bytes copied to @buf, a negative error number otherwise
>> + */
>> +static ssize_t fpga_mgr_attr_read(struct device *dev,
>> + struct device_attribute *attr, char *buf)
>> +{
>> + struct fpga_manager *mgr = dev_get_drvdata(dev);
>> + ssize_t count;
>> + int ret;
>> +
>> + if (mgr && mgr->fpga_read)
>> + ret = mgr->fpga_read(mgr, buf, &count);
>> +
>> + return ret == 0 ? count : -EPERM;
>
> EPERM isn't the only error return from fpga_read.
Yeah I know. Will revisit all return codes.
>> +}
>> +
>> +/**
>> + * fpga_mgr_write - Write data to fpga
>> + * @mgr: Pointer to the fpga manager structure
>> + * @fw_name: Pointer to the buffer location with bistream firmware filename
>> + *
>> + * @buf contains firmware filename which is loading through firmware
>> + * interface and passed to the fpga driver.
>> + *
>> + * Returns string lenght added to @fw_name, a negative error number otherwise
>> + */
>> +static int fpga_mgr_write(struct fpga_manager *mgr, const char *fw_name)
>> +{
>> + int ret = 0;
>> + const struct firmware *fw;
>> +
>> + if (!fw_name || !strlen(fw_name)) {
>> + dev_err(mgr->dev, "Firmware name is not specified!\n");
>> + return -EINVAL;
>> + }
>> +
>> + if (!mgr->mops || !mgr->mops->write) {
>> + dev_err(mgr->dev,
>> + "Controller doesn't support write operations!\n");
>> + return -EPERM;
>
> I think you should revisit the return codes.
yap
>
>
>> +/**
>> + * fpga_mgr_attr_write - Write data to fpga
>> + * @dev: Pointer to the device structure
>> + * @attr: Pointer to the device attribute structure
>> + * @buf: Pointer to the buffer location with bistream firmware filename
>> + * @count: Number of characters in @buf
>> + *
>> + * @buf contains firmware filename which is loading through firmware
>> + * interface and passed to the fpga driver.
>> + *
>> + * Returns string lenght added to @buf, a negative error number otherwise
>> + */
>> +static ssize_t fpga_mgr_attr_write(struct device *dev,
>> + struct device_attribute *attr,
>> + const char *buf, size_t count)
>> +{
>> + struct fpga_manager *mgr = dev_get_drvdata(dev);
>> + int ret;
>> +
>> + if (mgr && mgr->fpga_write)
>> + ret = mgr->fpga_write(mgr, buf);
>> +
>> + return ret == 0 ? strlen(buf) : -EPERM;
>> +}
>
> Same -EPERM issue as read
yap
>
>> + mgr = devm_kzalloc(&pdev->dev, sizeof(*mgr), GFP_KERNEL);
>> + if (!mgr) {
>> + dev_err(&pdev->dev, "Failed to alloc mgr struct!\n");
>
> Unnecessary OOM message as there's a general dump_stack()
> already done on any OOM without GFP_NOWARN
>
>> diff --git a/include/linux/fpga.h b/include/linux/fpga.h
> []
>> +struct fpga_manager {
>> + char name[48];
>
> Maybe a #define instead of 48?
There is another comment to fix this by pointer which is sensible solution too.
Thanks for review,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2013-09-19 10:01 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-18 15:56 [RFC PATCH 0/1] FPGA subsystem core Michal Simek
2013-09-18 15:56 ` [RFC PATCH] fpga: Introduce new fpga subsystem Michal Simek
2013-09-18 16:11 ` Joe Perches
2013-09-19 10:01 ` Michal Simek [this message]
2013-09-19 16:26 ` Alan Tull
2013-09-18 19:02 ` Dinh Nguyen
2013-09-19 11:53 ` Michal Simek
2013-09-18 19:15 ` Jason Cooper
2013-09-18 20:32 ` Jason Gunthorpe
2013-09-18 21:17 ` Alan Tull
2013-09-19 10:08 ` Pavel Machek
2013-09-19 11:02 ` Michal Simek
2013-09-20 20:55 ` Alan Tull
2013-09-24 15:55 ` Alan Tull
2013-09-24 15:58 ` Michal Simek
2013-09-24 16:22 ` Alan Tull
2013-09-24 22:18 ` Greg Kroah-Hartman
2013-09-25 13:55 ` Yves Vandervennet
2013-09-25 14:51 ` Michal Simek
2013-09-25 18:50 ` Alan Tull
2013-09-24 22:54 ` H. Peter Anvin
2013-09-25 10:41 ` Michal Simek
2013-09-25 12:00 ` Pavel Machek
2013-09-25 14:27 ` Philip Balister
2013-09-25 14:43 ` Michal Simek
2013-09-25 19:21 ` Alan Tull
2013-09-19 10:55 ` Michal Simek
2013-09-19 11:17 ` Pavel Machek
2013-09-19 11:22 ` Michal Simek
2013-09-19 12:52 ` /sys rules " Pavel Machek
2013-09-19 14:06 ` Greg KH
2013-09-19 14:10 ` Michal Simek
2013-09-19 14:18 ` Greg KH
2013-09-19 15:14 ` Alan Tull
2013-09-19 14:20 ` Jason Cooper
2013-09-19 14:37 ` Greg KH
2013-09-19 22:48 ` Pavel Machek
[not found] ` <CADuitaA3PLaOgmqXzfMdMDaXg7G6bT-DufjcuhtWfvaoWRj__Q@mail.gmail.com>
2013-09-19 15:14 ` Michal Simek
2013-09-19 15:18 ` Yves Vandervennet
2013-09-19 17:28 ` Jason Gunthorpe
2013-09-23 13:10 ` Michal Simek
2013-09-23 17:10 ` Jason Gunthorpe
2013-09-25 10:48 ` Michal Simek
2013-09-23 13:02 ` Michal Simek
2013-09-19 10:03 ` Pavel Machek
2013-09-19 10:45 ` Michal Simek
2013-09-27 13:31 ` Michal Simek
2013-09-30 17:12 ` Jason Gunthorpe
2013-10-01 15:59 ` Michal Simek
2013-09-18 23:45 ` Ryan Mallon
2013-09-19 11:37 ` Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=523ACB70.2020000@monstr.eu \
--to=monstr@monstr.eu \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=atull@altera.com \
--cc=cesarb@cesarb.net \
--cc=davem@davemloft.net \
--cc=davidb@codeaurora.org \
--cc=dinguyen@altera.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=michal.simek@xilinx.com \
--cc=pavel@ucw.cz \
--cc=philip@balister.org \
--cc=popcornmix@gmail.com \
--cc=rubini@gnudd.com \
--cc=swarren@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).