linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>,
	Kumar Gala <galak@codeaurora.org>,
	Mark Brown <broonie@kernel.org>,
	s.hauer@pengutronix.de, linux-api@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, arnd@arndb.de,
	sboyd@codeaurora.org, pantelis.antoniou@konsulko.com,
	mporter@konsulko.com, stefan.wahren@i2se.com, wxt@rock-chips.com,
	Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: Re: [PATCH v7 2/9] nvmem: Add a simple NVMEM framework for consumers
Date: Fri, 10 Jul 2015 03:42:57 -0700	[thread overview]
Message-ID: <1436524977.24866.31.camel@perches.com> (raw)
In-Reply-To: <1436521495-10728-1-git-send-email-srinivas.kandagatla@linaro.org>

On Fri, 2015-07-10 at 10:44 +0100, Srinivas Kandagatla wrote:
> This patch adds just consumers part of the framework just to enable easy
> review.

Trivial notes:

> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> @@ -334,6 +335,7 @@ struct nvmem_device *nvmem_register(struct nvmem_config *config)
>  	if (config->cells)
>  		nvmem_add_cells(nvmem, config);
>  
> +

superfluous newline

> +static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id)
> +{
> +	struct nvmem_cell *cell = NULL;
> +	struct nvmem_device *nvmem;
> +
> +	nvmem = __nvmem_device_get(NULL, &cell, cell_id);
> +	if (IS_ERR(nvmem))
> +		return ERR_CAST(nvmem);
> +
> +

extra blank line here too

> +/**
> + * nvmem_cell_read() - Read a given nvmem cell
> + *
> + * @cell: nvmem cell to be read.
> + * @len: pointer to length of cell which will be populated on successful read.
> + *
> + * The return value will be an ERR_PTR() on error or a valid pointer
> + * to a char * bufffer.  The buffer should be freed by the consumer with a

One too many f's in buffer, it's returning a void *

> + * kfree().
> + */
> +void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
> +{
> +	struct nvmem_device *nvmem = cell->nvmem;
> +	u8 *buf;
[]
> +	return buf;
> +}
> +EXPORT_SYMBOL_GPL(nvmem_cell_read);

[]

> +/**
> + * nvmem_cell_write() - Write to a given nvmem cell
> + *
> + * @cell: nvmem cell to be written.
> + * @buf: Buffer to be written.
> + * @len: length of buffer to be written to nvmem cell.
> + *
> + * The return value will be an length of bytes written or non zero on failure.

less than zero or maybe negative on failure?

> + */
> +int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
> +{
> +	struct nvmem_device *nvmem = cell->nvmem;
> +	int rc;
> +	void *wbuf = buf;

This variable and assignment seems unnecessary as buf could be reused.

> +
> +	if (!nvmem || !nvmem->regmap || nvmem->read_only ||
> +	    (cell->bit_offset == 0 && len != cell->bytes))
> +		return -EINVAL;
> +
> +	if (cell->bit_offset || cell->nbits) {
> +		wbuf = nvmem_cell_prepare_write_buffer(cell, buf, len);
> +		if (IS_ERR(wbuf))
> +			return PTR_ERR(wbuf);
> +	}
> +
> +	rc = regmap_raw_write(nvmem->regmap, cell->offset, wbuf, cell->bytes);
> +
> +	/* free the tmp buffer */
> +	if (cell->bit_offset)
> +		kfree(wbuf);
> +
> +	if (IS_ERR_VALUE(rc))
> +		return rc;
> +
> +	return len;
> +}
> +EXPORT_SYMBOL_GPL(nvmem_cell_write);



  reply	other threads:[~2015-07-10 10:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10  9:43 [PATCH v7 0/9] Add simple NVMEM Framework via regmap Srinivas Kandagatla
2015-07-10  9:44 ` [PATCH v7 1/9] nvmem: Add a simple NVMEM framework for nvmem providers Srinivas Kandagatla
2015-07-10 10:29   ` Joe Perches
2015-07-10 10:39     ` Srinivas Kandagatla
2015-07-13 16:50   ` Philipp Zabel
2015-07-10  9:44 ` [PATCH v7 2/9] nvmem: Add a simple NVMEM framework for consumers Srinivas Kandagatla
2015-07-10 10:42   ` Joe Perches [this message]
2015-07-13 19:06   ` Stefan Wahren
2015-07-13 19:24     ` Srinivas Kandagatla
2015-07-10  9:45 ` [PATCH v7 3/9] nvmem: Add nvmem_device based consumer apis Srinivas Kandagatla
2015-07-10 10:49   ` Joe Perches
2015-07-14 22:06   ` Stephen Boyd
2015-07-15  8:21     ` Srinivas Kandagatla
2015-07-10  9:45 ` [PATCH v7 4/9] nvmem: Add bindings for simple nvmem framework Srinivas Kandagatla
2015-07-10 19:04   ` Rob Herring
2015-07-13 10:21     ` Srinivas Kandagatla
2015-07-10  9:45 ` [PATCH v7 5/9] Documentation: nvmem: add nvmem api level and how-to doc Srinivas Kandagatla
2015-07-14 21:32   ` Stephen Boyd
2015-07-14 22:00     ` Srinivas Kandagatla
2015-07-10  9:45 ` [PATCH v7 6/9] nvmem: qfprom: Add Qualcomm QFPROM support Srinivas Kandagatla
2015-07-14 21:18   ` Stephen Boyd
2015-07-14 22:02     ` Srinivas Kandagatla
2015-07-10  9:45 ` [PATCH v7 7/9] nvmem: qfprom: Add bindings for qfprom Srinivas Kandagatla
2015-07-10  9:45 ` [PATCH v7 8/9] nvmem: sunxi: Move the SID driver to the nvmem framework Srinivas Kandagatla
2015-07-10  9:46 ` [PATCH v7 9/9] nvmem: Add to MAINTAINERS for " Srinivas Kandagatla
2015-07-13 18:54 ` [PATCH v7 0/9] Add simple NVMEM Framework via regmap Stefan Wahren
2015-07-13 19:35   ` Srinivas Kandagatla
2015-07-13 20:11     ` Stefan Wahren
2015-07-13 21:39       ` Srinivas Kandagatla

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=1436524977.24866.31.camel@perches.com \
    --to=joe@perches.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mporter@konsulko.com \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stefan.wahren@i2se.com \
    --cc=wxt@rock-chips.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).