From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 17/21] ARM: i.MX: iim: Use dev_add_param_bool for parameters
Date: Sun, 7 Apr 2013 16:00:51 +0200 [thread overview]
Message-ID: <1365343255-26497-18-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1365343255-26497-1-git-send-email-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/iim.c | 65 +++++++++++--------------------------------------
1 file changed, 14 insertions(+), 51 deletions(-)
diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
index 69ddc4d..ce2bbaf 100644
--- a/arch/arm/mach-imx/iim.c
+++ b/arch/arm/mach-imx/iim.c
@@ -33,6 +33,9 @@
static unsigned long mac_addr_base;
+static int iim_write_enable;
+static int iim_sense_enable;
+
struct iim_priv {
struct cdev cdev;
void __iomem *base;
@@ -88,14 +91,9 @@ static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count,
{
ulong size, i;
struct iim_priv *priv = cdev->priv;
- const char *sense_param;
- unsigned long explicit_sense = 0;
-
- if ((sense_param = dev_get_param(cdev->dev, "explicit_sense_enable")))
- explicit_sense = simple_strtoul(sense_param, NULL, 0);
size = min((loff_t)count, priv->banksize - offset);
- if (explicit_sense) {
+ if (iim_sense_enable) {
for (i = 0; i < size; i++) {
int row_val;
@@ -113,7 +111,6 @@ static ssize_t imx_iim_cdev_read(struct cdev *cdev, void *buf, size_t count,
return size;
}
-#ifdef CONFIG_IMX_IIM_FUSE_BLOW
static int do_fuse_blow(void __iomem *reg_base, unsigned int bank,
unsigned int row, u8 value)
{
@@ -173,22 +170,16 @@ out:
writeb(0, reg_base + IIM_PREG_P);
return ret;
}
-#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t count,
loff_t offset, ulong flags)
{
ulong size, i;
struct iim_priv *priv = cdev->priv;
- const char *write_param;
- unsigned int blow_enable = 0;
-
- if ((write_param = dev_get_param(cdev->dev, "permanent_write_enable")))
- blow_enable = simple_strtoul(write_param, NULL, 0);
size = min((loff_t)count, priv->banksize - offset);
-#ifdef CONFIG_IMX_IIM_FUSE_BLOW
- if (blow_enable) {
+
+ if (IS_ENABLED(CONFIG_IMX_IIM_FUSE_BLOW) && iim_write_enable) {
for (i = 0; i < size; i++) {
int ret;
@@ -197,9 +188,7 @@ static ssize_t imx_iim_cdev_write(struct cdev *cdev, const void *buf, size_t cou
if (ret < 0)
return ret;
}
- } else
-#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
- {
+ } else {
for (i = 0; i < size; i++)
((u8 *)priv->bankbase)[(offset+i)*4] = ((u8 *)buf)[i];
}
@@ -213,21 +202,6 @@ static struct file_operations imx_iim_ops = {
.lseek = dev_lseek_default,
};
-static int imx_iim_blow_enable_set(struct device_d *dev, struct param_d *param,
- const char *val)
-{
- unsigned long blow_enable;
-
- if (val == NULL)
- return -EINVAL;
-
- blow_enable = simple_strtoul(val, NULL, 0);
- if (blow_enable > 1)
- return -EINVAL;
-
- return dev_param_set_generic(dev, param, blow_enable ? "1" : "0");
-}
-
static int imx_iim_add_bank(struct device_d *dev, void __iomem *base, int num)
{
struct iim_priv *priv;
@@ -254,7 +228,6 @@ static int imx_iim_add_bank(struct device_d *dev, void __iomem *base, int num)
static int imx_iim_probe(struct device_d *dev)
{
struct imx_iim_platform_data *pdata = dev->platform_data;
- int err;
int i;
void __iomem *base;
@@ -267,23 +240,13 @@ static int imx_iim_probe(struct device_d *dev)
imx_iim_add_bank(dev, base, i);
}
-#ifdef CONFIG_IMX_IIM_FUSE_BLOW
- err = dev_add_param(dev, "permanent_write_enable",
- imx_iim_blow_enable_set, NULL, 0);
- if (err < 0)
- return err;
- err = dev_set_param(dev, "permanent_write_enable", "0");
- if (err < 0)
- return err;
-#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
-
- err = dev_add_param(dev, "explicit_sense_enable",
- imx_iim_blow_enable_set, NULL, 0);
- if (err < 0)
- return err;
- err = dev_set_param(dev, "explicit_sense_enable", "1");
- if (err < 0)
- return err;
+
+ if (IS_ENABLED(CONFIG_IMX_IIM_FUSE_BLOW))
+ dev_add_param_bool(dev, "permanent_write_enable",
+ NULL, NULL, &iim_write_enable, NULL);
+
+ dev_add_param_bool(dev, "explicit_sense_enable",
+ NULL, NULL, &iim_sense_enable, NULL);
return 0;
}
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-04-07 14:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-07 14:00 [PATCH] Add device parameter convenience helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 01/21] param: Add dev member to struct param_d Sascha Hauer
2013-04-07 14:00 ` [PATCH 02/21] param: refactor __dev_add_param Sascha Hauer
2013-04-07 14:00 ` [PATCH 03/21] param: Add integer and boolean parameter helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 04/21] param: Add ip address convenience function Sascha Hauer
2013-04-07 14:00 ` [PATCH 05/21] net: ksz8864: Use dev_add_param_bool for enable parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 06/21] net: store ethernet device parameters in device Sascha Hauer
2013-04-07 14:00 ` [PATCH 07/21] netconsole: use dev_add_param_* helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 08/21] param: remove now unused dev_[gs]et_param_ip Sascha Hauer
2013-04-07 14:00 ` [PATCH 09/21] treewide: Use dev_add_param_int_ro where possible Sascha Hauer
2013-04-07 14:00 ` [PATCH 10/21] mci: Use dev_add_param_int for probe parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 11/21] ata: Use dev_add_param_bool " Sascha Hauer
2013-04-07 14:00 ` [PATCH 12/21] fb: Use dev_add_param_bool for enable parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 13/21] fb: imxfb: Use dev_add_param_int for alpha parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 14/21] fb: imx-ipu-fb: " Sascha Hauer
2013-04-07 14:00 ` [PATCH 15/21] param: pass param to dev_remove_param Sascha Hauer
2013-04-07 14:00 ` [PATCH 16/21] pwm: Use dev_add_param_int for pwm parameters Sascha Hauer
2013-04-07 14:00 ` Sascha Hauer [this message]
2013-04-07 14:00 ` [PATCH 18/21] console: Use dev_add_param_int for baudrate parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 19/21] mtd: Nand: Use dev_add_param_bool for erasebad parameter Sascha Hauer
2013-04-07 22:35 ` Alexander Aring
2013-04-08 8:11 ` Sascha Hauer
2013-04-08 10:15 ` Alexander Aring
2013-04-07 14:00 ` [PATCH 20/21] USB gadget at91: Use dev_add_param_bool for vbus parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 21/21] ARM: MXS: ocotp: Use dev_add_param_bool for parameter Sascha Hauer
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=1365343255-26497-18-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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