mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Michal Simek <michal.simek@xilinx.com>
Cc: linux-kernel@vger.kernel.org, monstr@monstr.eu,
	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>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Jason Cooper <jason@lakedaemon.net>,
	Yves Vandervennet <rocket.yvanderv@gmail.com>,
	Kyle Teske <kyle.teske@ni.com>,
	Josh Cartwright <joshc@eso.teric.us>,
	Rob Landley <rob@landley.net>,
	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>,
	David Brown <davidb@codeaurora.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Nicolas Pitre <nico@linaro.org>,
	Mark Langsdorf <mark.langsdorf@calxeda.com>,
	Felipe Balbi <balbi@ti.com>,
	linux-doc@vger.kernel.org
Subject: Re: [RFC PATCH v2] fpga: Introduce new fpga subsystem
Date: Wed, 02 Oct 2013 09:06:36 -0700	[thread overview]
Message-ID: <1380729996.2081.59.camel@joe-AO722> (raw)
In-Reply-To: <fe4f34387011339efe9f5868a7eec9d549462d8f.1380727889.git.michal.simek@xilinx.com>

On Wed, 2013-10-02 at 17:35 +0200, Michal Simek wrote:
> This new fpga subsystem core should unify all fpga drivers/managers 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
> interface for these drivers.

Does this interface support partial reprogramming/configuration
for FPGAs that can do that?

trivial notes:

There are a _lot_ of dev_dbg statements.

I hope some of these would be removed one day,
especially the function tracing style ones, because
there's already a generic kernel mechanism for that.

Maybe perf/trace support could be added eventually.

> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
[]
> +/**
> + * fpga_mgr_status_write - Write fpga manager status
> + * @dev: Pointer to the device structure
> + * @attr: Pointer to the device attribute structure
> + * @buf: Pointer to the buffer location
> + * @count: Number of characters in @buf
> + *
> + * Returns the number of bytes copied to @buf, a negative error number otherwise
> + */
> +static ssize_t fpga_mgr_status_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 (test_and_set_bit_lock(FPGA_MGR_DEV_BUSY, &mgr->flags))
> +		return -EBUSY;
> +
> +	ret = strcmp(buf, "write_init");
> +	if (!ret) {
> +		ret = fpga_mgr_write_init(mgr);
> +		goto out;
> +	}
> +
> +	ret = strcmp(buf, "write_complete");
> +	if (!ret) {
> +		ret = fpga_mgr_write_complete(mgr);
> +		goto out;
> +	}
> +
> +	ret = strcmp(buf, "read_init");
> +	if (!ret) {
> +		ret = fpga_mgr_read_init(mgr);
> +		goto out;
> +	}
> +
> +	ret = strcmp(buf, "read_complete");
> +	if (!ret) {
> +		ret = fpga_mgr_read_complete(mgr);
> +		goto out;
> +	}
> +
> +	ret = -EINVAL;
> +out:
> +	clear_bit_unlock(FPGA_MGR_DEV_BUSY, &mgr->flags);
> +
> +	return ret ? : count;
> +}

I think this style is awkward and this would be
better written as:

	if (!strcmp(buf, "write_init"))
		ret = fpga_mgr_write_init(mgr);
	else if (!strcmp(buf, "write_complete"))
		ret = fpga_mgr_write_complete(mgr);
	else if (!strcmp(buf, "read_init"))
		ret = fpga_mgr_read_init(mgr);
	else if (!strcmp(buf, "read_complete"))
		ret = fpga_mgr_read_complete(mgr);
	else
		ret = -EINVAL;

	clear_bit_unlock(FPGA_MGR_DEV_BUSY, &mgr->flags);

	if (ret)
		return ret;

	return count;
}

Maybe use (strcmp(...) == 0) if you prefer that.
Both styles are commonly used in linux.

Probably all of the "return ret ?: count;" uses
would be more easily understood on 3 lines.



  reply	other threads:[~2013-10-02 16:06 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 15:35 [RFC PATCH v2 0/1] FPGA subsystem core Michal Simek
2013-10-02 15:35 ` [RFC PATCH v2] fpga: Introduce new fpga subsystem Michal Simek
2013-10-02 16:06   ` Joe Perches [this message]
2013-10-04 16:15     ` Michal Simek
2013-10-04 16:26       ` Greg Kroah-Hartman
2013-10-02 17:46   ` Jason Gunthorpe
2013-10-04 16:28     ` Michal Simek
2013-10-04 17:05       ` Jason Gunthorpe
2013-10-04 18:50       ` Alan Tull
2013-10-02 19:00 ` [RFC PATCH v2 0/1] FPGA subsystem core H. Peter Anvin
2013-10-03  6:49   ` Pavel Machek
2013-10-04 13:57     ` Michal Simek
2013-10-04 14:16       ` Greg Kroah-Hartman
2013-10-04 14:21         ` H. Peter Anvin
2013-10-04 14:28           ` Michal Simek
2013-10-04 16:46             ` H. Peter Anvin
2013-10-04 17:44               ` Michal Simek
2013-10-04 18:12                 ` H. Peter Anvin
2013-10-04 23:33                   ` Greg Kroah-Hartman
2013-10-04 23:49                     ` Jason Gunthorpe
2013-10-05  4:00                       ` H. Peter Anvin
2013-10-05  5:10                         ` Jason Gunthorpe
2013-10-05  5:34                           ` H. Peter Anvin
2013-10-05  6:53                             ` Michal Simek
     [not found]                               ` <c59c68b8-2565-45c5-bfe9-574b76f3f9bc@email.android.com>
2013-10-07 13:11                                 ` Michal Simek
2013-10-07 14:55                                   ` H. Peter Anvin
2013-10-07 15:03                                     ` Michal Simek
2013-10-07 15:07                                       ` H. Peter Anvin
2013-10-08 13:00                                         ` Michal Simek
2013-10-08 16:49                                           ` Alan Tull
2013-10-08 21:42                                             ` Greg Kroah-Hartman
     [not found]                                               ` <CANk1AXS9fpypVVWgvvUCZjKXDvLPpB7=kCNucwFcktgBHmV37w@mail.gmail.com>
     [not found]                                                 ` <20131009014027.GA17066@kroah.com>
     [not found]                                                   ` <5254EC8A.8060609@monstr.eu>
     [not found]                                                     ` <20131009055332.GA4510@kroah.com>
     [not found]                                                       ` <52550638.2080301@monstr.eu>
     [not found]                                                         ` <52556585.3050603@zytor.com>
     [not found]                                                           ` <20131009192439.GC18611@kroah.com>
     [not found]                                                             ` <5255BE71.8010801@zytor.com>
2013-10-09 21:07                                                               ` Jason Gunthorpe
2013-10-09 22:21                                                                 ` H. Peter Anvin
2013-10-05 17:33                             ` Jason Gunthorpe
2013-10-05  6:56                       ` Michal Simek
2013-10-04 23:50                     ` H. Peter Anvin
2013-10-05  6:49                       ` Michal Simek
2013-10-08 17:00                     ` Alan Tull
2013-10-08 21:44                       ` Greg Kroah-Hartman
2013-10-08 23:47                         ` delicious quinoa
2013-10-09  1:41                           ` Greg Kroah-Hartman
2013-10-04 18:26                 ` Alan Tull
2013-10-03 21:46 ` Alan Tull
2013-10-04 15:27   ` Michal Simek
2013-10-04 18:30     ` Alan Tull

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=1380729996.2081.59.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=atull@altera.com \
    --cc=balbi@ti.com \
    --cc=cesarb@cesarb.net \
    --cc=davem@davemloft.net \
    --cc=davidb@codeaurora.org \
    --cc=dinguyen@altera.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jason@lakedaemon.net \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=joshc@eso.teric.us \
    --cc=kyle.teske@ni.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=mark.langsdorf@calxeda.com \
    --cc=michal.simek@xilinx.com \
    --cc=monstr@monstr.eu \
    --cc=nico@linaro.org \
    --cc=pavel@ucw.cz \
    --cc=philip@balister.org \
    --cc=rob@landley.net \
    --cc=rocket.yvanderv@gmail.com \
    --cc=rubini@gnudd.com \
    --cc=s.trumtrar@pengutronix.de \
    --cc=sameo@linux.intel.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

all inboxes | Powered by JetHome®