9
0
Fork 0

ARM: MXS: ocotp: Use dev_add_param_bool for parameter

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-04-06 14:07:56 +02:00
parent a40442cfa4
commit 2f24a5c33c
1 changed files with 4 additions and 30 deletions

View File

@ -44,6 +44,7 @@
struct ocotp_priv { struct ocotp_priv {
struct cdev cdev; struct cdev cdev;
void __iomem *base; void __iomem *base;
unsigned int write_enable;
}; };
static int mxs_ocotp_wait_busy(struct ocotp_priv *priv) static int mxs_ocotp_wait_busy(struct ocotp_priv *priv)
@ -103,18 +104,12 @@ static ssize_t mxs_ocotp_cdev_write(struct cdev *cdev, const void *buf, size_t c
{ {
struct ocotp_priv *priv = cdev->priv; struct ocotp_priv *priv = cdev->priv;
void __iomem *base = priv->base; void __iomem *base = priv->base;
const char *write_param;
unsigned int write_enabled = 0;
unsigned long old_hclk, aligned_offset; unsigned long old_hclk, aligned_offset;
int old_vddio, num_words, num_bytes, i, ret = 0; int old_vddio, num_words, num_bytes, i, ret = 0;
u8 *work_buf; u8 *work_buf;
u32 reg; u32 reg;
write_param = dev_get_param(cdev->dev, "permanent_write_enable"); if (!priv->write_enable)
if (write_param)
write_enabled = simple_strtoul(write_param, NULL, 0);
if (!write_param || !write_enabled)
return -EPERM; return -EPERM;
/* we can only work on u32, so calc some helpers */ /* we can only work on u32, so calc some helpers */
@ -179,21 +174,6 @@ static struct file_operations mxs_ocotp_ops = {
.lseek = dev_lseek_default, .lseek = dev_lseek_default,
}; };
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");
}
static int mxs_ocotp_probe(struct device_d *dev) static int mxs_ocotp_probe(struct device_d *dev)
{ {
int err; int err;
@ -212,14 +192,8 @@ static int mxs_ocotp_probe(struct device_d *dev)
if (IS_ENABLED(CONFIG_MXS_OCOTP_WRITABLE)) { if (IS_ENABLED(CONFIG_MXS_OCOTP_WRITABLE)) {
mxs_ocotp_ops.write = mxs_ocotp_cdev_write; mxs_ocotp_ops.write = mxs_ocotp_cdev_write;
dev_add_param_bool(dev, "permanent_write_enable",
err = dev_add_param(dev, "permanent_write_enable", NULL, NULL, &priv->write_enable, NULL);
mxs_ocotp_write_enable_set, NULL, 0);
if (err < 0)
return err;
err = dev_set_param(dev, "permanent_write_enable", "0");
if (err < 0)
return err;
} }
return 0; return 0;