From: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
To: Srinivas Kandagatla
<srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: andrew-g2DYL2Zd6BY@public.gmane.org,
Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Joachim Eastwood
<manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Maxime Ripard
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 11/12] nvmem: mxs-ocotp: remove nvmem regmap dependency
Date: Thu, 28 Apr 2016 08:50:34 +0200 [thread overview]
Message-ID: <5721B2BA.4080100@i2se.com> (raw)
In-Reply-To: <1461526096-29584-12-git-send-email-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Hi Srinivas,
Am 24.04.2016 um 21:28 schrieb Srinivas Kandagatla:
> This patch moves to nvmem support in the driver to use callback
> instead of regmap.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> drivers/nvmem/mxs-ocotp.c | 79 +++++++++++++----------------------------------
> 1 file changed, 21 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/nvmem/mxs-ocotp.c b/drivers/nvmem/mxs-ocotp.c
> index 8ba19bb..3bf962c 100644
> --- a/drivers/nvmem/mxs-ocotp.c
> +++ b/drivers/nvmem/mxs-ocotp.c
the include of regmap.h should also be removed.
> @@ -66,11 +66,10 @@ static int mxs_ocotp_wait(struct mxs_ocotp *otp)
> return 0;
> }
>
> -static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size,
> - void *val, size_t val_size)
> +static int mxs_ocotp_read(void *context, unsigned int offset,
> + void *val, size_t bytes)
> {
> struct mxs_ocotp *otp = context;
> - unsigned int offset = *(u32 *)reg;
> u32 *buf = val;
> int ret;
>
> @@ -94,17 +93,16 @@ static int mxs_ocotp_read(void *context, const void *reg, size_t reg_size,
> if (ret)
> goto close_banks;
>
> - while (val_size) {
> + while (bytes) {
> if ((offset < OCOTP_DATA_OFFSET) || (offset % 16)) {
> /* fill up non-data register */
> - *buf = 0;
> + *buf++ = 0;
> } else {
> - *buf = readl(otp->base + offset);
> + *buf++ = readl(otp->base + offset);
> }
>
> - buf++;
> - val_size--;
> - offset += reg_size;
> + bytes -= 4;
> + offset += 4;
This change would also fix the buffer overflow but Stanislav's patch
should be applied before to get the fix in stable.
> }
>
> close_banks:
> @@ -117,57 +115,28 @@ disable_clk:
> return ret;
> }
>
> -static int mxs_ocotp_write(void *context, const void *data, size_t count)
> -{
> - /* We don't want to support writing */
> - return 0;
> -}
> -
> -static bool mxs_ocotp_writeable_reg(struct device *dev, unsigned int reg)
> -{
> - return false;
> -}
> -
> static struct nvmem_config ocotp_config = {
> .name = "mxs-ocotp",
> + .stride = 16,
> + .word_size = 4,
> .owner = THIS_MODULE,
.reg_read = mxs_ocotp_read,
> };
>
> -static const struct regmap_range imx23_ranges[] = {
> - regmap_reg_range(OCOTP_DATA_OFFSET, 0x210),
> -};
> -
> -static const struct regmap_access_table imx23_access = {
> - .yes_ranges = imx23_ranges,
> - .n_yes_ranges = ARRAY_SIZE(imx23_ranges),
> -};
> -
> -static const struct regmap_range imx28_ranges[] = {
> - regmap_reg_range(OCOTP_DATA_OFFSET, 0x290),
> -};
> -
> -static const struct regmap_access_table imx28_access = {
> - .yes_ranges = imx28_ranges,
> - .n_yes_ranges = ARRAY_SIZE(imx28_ranges),
> +struct imx_data {
struct mxs_data
These chips are named imx2x but the platform is mxs. Please don't ask why.
> + int max_reg;
Since nvmem_config uses "size" instead of "max_reg" we better use "size"
here, too. This avoids confusion and potential issues see below.
> };
>
> -static struct regmap_bus mxs_ocotp_bus = {
> - .read = mxs_ocotp_read,
> - .write = mxs_ocotp_write, /* make regmap_init() happy */
> - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
> - .val_format_endian_default = REGMAP_ENDIAN_NATIVE,
> +static const struct imx_data imx23_data = {
static const struct mxs_data imx23_data
> + .max_reg = 0x210,
.size = 0x220,
> };
>
> -static struct regmap_config mxs_ocotp_config = {
> - .reg_bits = 32,
> - .val_bits = 32,
> - .reg_stride = 16,
> - .writeable_reg = mxs_ocotp_writeable_reg,
> +static const struct imx_data imx28_data = {
static const struct mxs_data imx28_data
> + .max_reg = 0x290,
.size = 0x2a0,
> };
>
> static const struct of_device_id mxs_ocotp_match[] = {
> - { .compatible = "fsl,imx23-ocotp", .data = &imx23_access },
> - { .compatible = "fsl,imx28-ocotp", .data = &imx28_access },
> + { .compatible = "fsl,imx23-ocotp", .data = &imx23_data },
> + { .compatible = "fsl,imx28-ocotp", .data = &imx23_data },
.compatible = "fsl,imx28-ocotp", .data = &imx28_data
> { /* sentinel */},
> };
> MODULE_DEVICE_TABLE(of, mxs_ocotp_match);
> @@ -175,6 +144,7 @@ MODULE_DEVICE_TABLE(of, mxs_ocotp_match);
> static int mxs_ocotp_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> + struct imx_data *data;
const struct mxs_data *data
> struct mxs_ocotp *otp;
> struct resource *res;
> const struct of_device_id *match;
> @@ -205,17 +175,10 @@ static int mxs_ocotp_probe(struct platform_device *pdev)
> return ret;
> }
>
> - access = match->data;
> - mxs_ocotp_config.rd_table = access;
> - mxs_ocotp_config.max_register = access->yes_ranges[0].range_max;
> -
> - regmap = devm_regmap_init(dev, &mxs_ocotp_bus, otp, &mxs_ocotp_config);
> - if (IS_ERR(regmap)) {
> - dev_err(dev, "regmap init failed\n");
> - ret = PTR_ERR(regmap);
> - goto err_clk;
> - }
> + data = match->data;
>
> + ocotp_config.size = data->max_reg;
data->size
Regards
Stefan
> + ocotp_config.priv = otp;
> ocotp_config.dev = dev;
> otp->nvmem = nvmem_register(&ocotp_config);
> if (IS_ERR(otp->nvmem)) {
next prev parent reply other threads:[~2016-04-28 6:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-24 19:28 [PATCH 00/12] nvmem: remove regmap dependency Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 01/12] nvmem: core: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 02/12] eeprom: at24: remove nvmem " Srinivas Kandagatla
2016-05-02 7:32 ` Wolfram Sang
2016-05-04 1:32 ` Andrew Lunn
[not found] ` <1461526096-29584-1-git-send-email-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-24 19:28 ` [PATCH 03/12] eeprom: at25: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 04/12] nvmem: qfprom: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 05/12] nvmem: vif610-ocotp: " Srinivas Kandagatla
2016-04-27 5:36 ` maitysanchayan
2016-04-24 19:28 ` [PATCH 06/12] nvmem: sunxi-sid: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 07/12] nvmem: rockchip-efuse: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 08/12] nvmem: mtk-efuse: " Srinivas Kandagatla
2016-04-27 6:30 ` andrew-ct chen
2016-05-01 21:01 ` Greg Kroah-Hartman
2016-04-24 19:28 ` [PATCH 09/12] nvmem: imx-ocotp: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 10/12] nvmem: lpc18xx-eeprom: " Srinivas Kandagatla
2016-04-24 19:28 ` [PATCH 11/12] nvmem: mxs-ocotp: " Srinivas Kandagatla
[not found] ` <1461526096-29584-12-git-send-email-srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-28 6:50 ` Stefan Wahren [this message]
2016-04-24 19:28 ` [PATCH 12/12] nvmem: 93xx46: " 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=5721B2BA.4080100@i2se.com \
--to=stefan.wahren-es4nqchxeme@public.gmane.org \
--cc=andrew-g2DYL2Zd6BY@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=wens-jdAy2FN1RRM@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
/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).