[PATCH 8/8] arm: mxs: add write support for ocotp
Sascha Hauer
s.hauer at pengutronix.de
Thu Jun 14 06:10:16 EDT 2012
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 |
More information about the barebox
mailing list