Skip to content
Snippets Groups Projects
Commit 69a368cf authored by John Crispin's avatar John Crispin
Browse files

ar71xx: simplify patch 613 and add missing error handling


Dynamic allocation of label can be simplified.
Also add error handling to deal with failed memory allocation.

Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>

SVN-Revision: 49244
parent 301d48b8
No related branches found
No related tags found
No related merge requests found
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
+static int ath79_request_ext_lna_gpio(unsigned chain, int gpio) +static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
+{ +{
+ char buf[32];
+ char *label; + char *label;
+ int err; + int err;
+ +
+ scnprintf(buf, sizeof(buf), "external LNA%u", chain); + label = kasprintf(GFP_KERNEL, "external LNA%u", chain);
+ label = kstrdup(buf, GFP_KERNEL); + if (!label)
+ return -ENOMEM;
+ +
+ err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label); + err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
+ if (err) { + if (err) {
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
+static int ath79_request_ext_lna_gpio(unsigned chain, int gpio) +static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
+{ +{
+ char buf[32];
+ char *label; + char *label;
+ int err; + int err;
+ +
+ scnprintf(buf, sizeof(buf), "external LNA%u", chain); + label = kasprintf(GFP_KERNEL, "external LNA%u", chain);
+ label = kstrdup(buf, GFP_KERNEL); + if (!label)
+ return -ENOMEM;
+ +
+ err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label); + err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
+ if (err) { + if (err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment