From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 07/21] netconsole: use dev_add_param_* helpers
Date: Sun, 7 Apr 2013 16:00:41 +0200 [thread overview]
Message-ID: <1365343255-26497-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1365343255-26497-1-git-send-email-s.hauer@pengutronix.de>
For shorter code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
net/netconsole.c | 50 ++++++--------------------------------------------
1 file changed, 6 insertions(+), 44 deletions(-)
diff --git a/net/netconsole.c b/net/netconsole.c
index 960de8d..9989194 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -43,7 +43,7 @@ struct nc_priv {
int busy;
struct net_connection *con;
- uint16_t port;
+ unsigned int port;
IPaddr_t ip;
};
@@ -123,49 +123,10 @@ static void nc_putc(struct console_device *cdev, char c)
priv->busy = 0;
}
-static int nc_port_set(struct device_d *dev, struct param_d *param,
- const char *val)
+static int nc_port_set(struct param_d *p, void *_priv)
{
- struct nc_priv *priv = g_priv;
- char portstr[16];
- int port;
-
- if (!val)
- dev_param_set_generic(dev, param, NULL);
-
- port = simple_strtoul(val, NULL, 10);
- if (port > 65535)
- return -EINVAL;
-
- priv->port = port;
nc_init();
- sprintf(portstr, "%d", port);
- dev_param_set_generic(dev, param, portstr);
-
- return 0;
-}
-
-static int nc_remoteip_set(struct device_d *dev, struct param_d *param,
- const char *val)
-{
- struct nc_priv *priv = g_priv;
- IPaddr_t ip;
- int ret;
-
- if (!val)
- dev_param_set_generic(dev, param, NULL);
-
- if (string_to_ip(val, &ip))
- return -EINVAL;
-
- priv->ip = ip;
- ret = nc_init();
- if (ret)
- return ret;
-
- dev_param_set_generic(dev, param, val);
-
return 0;
}
@@ -192,9 +153,10 @@ static int netconsole_init(void)
return ret;
}
- dev_add_param(&cdev->class_dev, "ip", nc_remoteip_set, NULL, 0);
- dev_add_param(&cdev->class_dev, "port", nc_port_set, NULL, 0);
- dev_set_param(&cdev->class_dev, "port", "6666");
+ priv->port = 6666;
+
+ dev_add_param_ip(&cdev->class_dev, "ip", NULL, NULL, &priv->ip, NULL);
+ dev_add_param_int(&cdev->class_dev, "port", nc_port_set, NULL, &priv->port, "%u", NULL);
pr_info("registered as %s%d\n", cdev->class_dev.name, cdev->class_dev.id);
--
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 ` Sascha Hauer [this message]
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 ` [PATCH 17/21] ARM: i.MX: iim: Use dev_add_param_bool for parameters Sascha Hauer
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-8-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