From: Sascha Hauer <s.hauer@pengutronix.de>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 8/8] arm: mxs: add write support for ocotp
Date: Thu, 14 Jun 2012 12:10:16 +0200 [thread overview]
Message-ID: <20120614101016.GP13302@pengutronix.de> (raw)
In-Reply-To: <1336463641-27219-9-git-send-email-w.sang@pengutronix.de>
On Tue, May 08, 2012 at 09:54:01AM +0200, Wolfram Sang wrote:
>
> +static ssize_t mxs_ocotp_cdev_write(struct cdev *cdev, const void *buf, size_t count,
> + ulong offset, ulong flags)
> +{
> + struct ocotp_priv *priv = cdev->priv;
> + void __iomem *base = priv->base;
> + const char *write_param;
> + unsigned int write_enabled = 0;
> + unsigned long old_hclk, aligned_offset;
> + int old_vddio, num_words, num_bytes, i, ret = 0;
> + u8 *work_buf;
> + u32 reg;
> +
> + write_param = dev_get_param(cdev->dev, "permanent_write_enable");
> + if (write_param)
> + write_enabled = simple_strtoul(write_param, NULL, 0);
> +
> + if (!write_param || !write_enabled)
> + return -EPERM;
Can't you save the write_enabled in ocotp_priv?
> +
> static struct file_operations mxs_ocotp_ops = {
> .read = mxs_ocotp_cdev_read,
> + .write = mxs_ocotp_cdev_write,
This should be compiled in only if CONFIG_MXS_OCOTP_WRITABLE is
enabled.
> .lseek = dev_lseek_default,
> };
>
> +#ifdef CONFIG_MXS_OCOTP_WRITABLE
> +static int mxs_ocotp_write_enable_set(struct device_d *dev, struct param_d *param,
> + const char *val)
> +{
> + unsigned long write_enable;
> +
> + if (!val)
> + return -EINVAL;
> +
> + write_enable = simple_strtoul(val, NULL, 0);
> + if (write_enable > 1)
> + return -EINVAL;
> +
> + return dev_param_set_generic(dev, param, write_enable ? "1" : "0");
> +}
> +#endif /* CONFIG_MXS_OCOTP_WRITABLE */
> +
> static int mxs_ocotp_probe(struct device_d *dev)
> {
> int err;
> @@ -113,6 +213,16 @@ static int mxs_ocotp_probe(struct device_d *dev)
> if (err < 0)
> return err;
>
> +#ifdef CONFIG_MXS_OCOTP_WRITABLE
Please replace this with if(IS_ENABLED(CONFIG_MXS_OCOTP_WRITABLE)),
then you don't need to #ifdef mxs_ocotp_write_enable_set. Additionally
we get better compile coverage.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-06-14 10:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-08 7:53 [PATCH 0/8] arm: mxs: add ocotp write support Wolfram Sang
2012-05-08 7:53 ` [PATCH 1/8] arm: mxs: make get_hclk result useable for upcoming set_hclk Wolfram Sang
2012-05-08 7:53 ` [PATCH 2/8] arm: mxs: add imx_set_hclk Wolfram Sang
2012-05-08 7:53 ` [PATCH 3/8] arm: mxs: refactor access to power domain Wolfram Sang
2012-05-08 7:53 ` [PATCH 4/8] arm: mxs: add POWER_BASE for MX28, too Wolfram Sang
2012-05-08 7:53 ` [PATCH 5/8] arm: mxs: add functions to get/set vddio Wolfram Sang
2012-06-14 10:07 ` Sascha Hauer
2012-05-08 7:53 ` [PATCH 6/8] arm: mxs: refactor timeout routine for ocotp Wolfram Sang
2012-05-08 7:54 ` [PATCH 7/8] arm: mxs: use consistent naming for #defines " Wolfram Sang
2012-05-08 7:54 ` [PATCH 8/8] arm: mxs: add write support " Wolfram Sang
2012-06-14 10:10 ` Sascha Hauer [this message]
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=20120614101016.GP13302@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=w.sang@pengutronix.de \
/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