From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan <adobriyan@gmail.com>
Subject: [PATCH 29/45] kstrtox: convert drivers/mfd/
Date: Sun, 5 Dec 2010 19:49:26 +0200 [thread overview]
Message-ID: <1291571382-2719-29-git-send-email-adobriyan@gmail.com> (raw)
In-Reply-To: <1291571382-2719-1-git-send-email-adobriyan@gmail.com>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/mfd/ab3100-core.c | 16 +++----------
drivers/mfd/ab3550-core.c | 48 +++++++++++++++--------------------------
drivers/mfd/ab8500-debugfs.c | 41 +++++++++++++----------------------
3 files changed, 37 insertions(+), 68 deletions(-)
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 4193af5..5b1c8ac 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -497,7 +497,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
char buf[32];
ssize_t buf_size;
int regp;
- unsigned long user_reg;
+ u8 reg;
int err;
int i = 0;
@@ -520,22 +520,19 @@ static ssize_t ab3100_get_set_reg(struct file *file,
/*
* Advance pointer to end of string then terminate
* the register string. This is needed to satisfy
- * the strict_strtoul() function.
+ * the kstrtou8() function.
*/
while ((i < buf_size) && (buf[i] != ' '))
i++;
buf[i] = '\0';
- err = strict_strtoul(&buf[regp], 16, &user_reg);
+ err = kstrtou8(&buf[regp], 16, ®);
if (err)
return err;
- if (user_reg > 0xff)
- return -EINVAL;
/* Either we read or we write a register here */
if (!priv->mode) {
/* Reading */
- u8 reg = (u8) user_reg;
u8 regvalue;
ab3100_get_register_interruptible(ab3100, reg, ®value);
@@ -545,8 +542,6 @@ static ssize_t ab3100_get_set_reg(struct file *file,
reg, regvalue);
} else {
int valp;
- unsigned long user_value;
- u8 reg = (u8) user_reg;
u8 value;
u8 regvalue;
@@ -563,13 +558,10 @@ static ssize_t ab3100_get_set_reg(struct file *file,
i++;
buf[i] = '\0';
- err = strict_strtoul(&buf[valp], 16, &user_value);
+ err = kstrtou8(&buf[valp], 16, &value);
if (err)
return err;
- if (user_reg > 0xff)
- return -EINVAL;
- value = (u8) user_value;
ab3100_set_register_interruptible(ab3100, reg, value);
ab3100_get_register_interruptible(ab3100, reg, ®value);
diff --git a/drivers/mfd/ab3550-core.c b/drivers/mfd/ab3550-core.c
index 8a98739..7e471d9 100644
--- a/drivers/mfd/ab3550-core.c
+++ b/drivers/mfd/ab3550-core.c
@@ -73,8 +73,8 @@ struct ab3550 {
u8 startup_events[AB3550_NUM_EVENT_REG];
bool startup_events_read;
#ifdef CONFIG_DEBUG_FS
- unsigned int debug_bank;
- unsigned int debug_address;
+ u8 debug_bank;
+ u8 debug_address;
#endif
};
@@ -865,7 +865,7 @@ static int ab3550_bank_print(struct seq_file *s, void *p)
{
struct ab3550 *ab = s->private;
- seq_printf(s, "%d\n", ab->debug_bank);
+ seq_printf(s, "%hhu\n", ab->debug_bank);
return 0;
}
@@ -881,7 +881,7 @@ static ssize_t ab3550_bank_write(struct file *file,
struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
char buf[32];
int buf_size;
- unsigned long user_bank;
+ u8 user_bank;
int err;
/* Get userspace string and assure termination */
@@ -890,7 +890,7 @@ static ssize_t ab3550_bank_write(struct file *file,
return -EFAULT;
buf[buf_size] = 0;
- err = strict_strtoul(buf, 0, &user_bank);
+ err = kstrtou8(buf, 0, &user_bank);
if (err)
return -EINVAL;
@@ -925,7 +925,6 @@ static ssize_t ab3550_address_write(struct file *file,
struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
char buf[32];
int buf_size;
- unsigned long user_address;
int err;
/* Get userspace string and assure termination */
@@ -934,15 +933,9 @@ static ssize_t ab3550_address_write(struct file *file,
return -EFAULT;
buf[buf_size] = 0;
- err = strict_strtoul(buf, 0, &user_address);
- if (err)
- return -EINVAL;
- if (user_address > 0xff) {
- dev_err(&ab->i2c_client[0]->dev,
- "debugfs error input > 0xff\n");
- return -EINVAL;
- }
- ab->debug_address = user_address;
+ err = kstrtou8(buf, 0, &ab->debug_address);
+ if (err < 0)
+ return err;
return buf_size;
}
@@ -952,8 +945,8 @@ static int ab3550_val_print(struct seq_file *s, void *p)
int err;
u8 regvalue;
- err = get_register_interruptible(ab, (u8)ab->debug_bank,
- (u8)ab->debug_address, ®value);
+ err = get_register_interruptible(ab, ab->debug_bank,
+ ab->debug_address, ®value);
if (err)
return -EINVAL;
seq_printf(s, "0x%02X\n", regvalue);
@@ -973,7 +966,7 @@ static ssize_t ab3550_val_write(struct file *file,
struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
char buf[32];
int buf_size;
- unsigned long user_val;
+ u8 user_val;
int err;
u8 regvalue;
@@ -983,22 +976,17 @@ static ssize_t ab3550_val_write(struct file *file,
return -EFAULT;
buf[buf_size] = 0;
- err = strict_strtoul(buf, 0, &user_val);
- if (err)
- return -EINVAL;
- if (user_val > 0xff) {
- dev_err(&ab->i2c_client[0]->dev,
- "debugfs error input > 0xff\n");
- return -EINVAL;
- }
+ err = kstrtou8(buf, 0, &user_val);
+ if (err < 0)
+ return err;
err = mask_and_set_register_interruptible(
- ab, (u8)ab->debug_bank,
- (u8)ab->debug_address, 0xFF, (u8)user_val);
+ ab, ab->debug_bank,
+ ab->debug_address, 0xFF, user_val);
if (err)
return -EINVAL;
- get_register_interruptible(ab, (u8)ab->debug_bank,
- (u8)ab->debug_address, ®value);
+ get_register_interruptible(ab, ab->debug_bank,
+ ab->debug_address, ®value);
if (err)
return -EINVAL;
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 8d1e05a..2a4c317 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -14,8 +14,8 @@
#include <linux/mfd/abx500.h>
#include <linux/mfd/ab8500.h>
-static u32 debug_bank;
-static u32 debug_address;
+static u8 debug_bank;
+static u8 debug_address;
/**
* struct ab8500_reg_range
@@ -357,7 +357,7 @@ static int ab8500_registers_print(struct seq_file *s, void *p)
{
struct device *dev = s->private;
unsigned int i;
- u32 bank = debug_bank;
+ u8 bank = debug_bank;
seq_printf(s, AB8500_NAME_STRING " register values:\n");
@@ -372,7 +372,7 @@ static int ab8500_registers_print(struct seq_file *s, void *p)
int err;
err = abx500_get_register_interruptible(dev,
- (u8)bank, (u8)reg, &value);
+ bank, (u8)reg, &value);
if (err < 0) {
dev_err(dev, "ab->read fail %d\n", err);
return err;
@@ -406,7 +406,7 @@ static const struct file_operations ab8500_registers_fops = {
static int ab8500_bank_print(struct seq_file *s, void *p)
{
- return seq_printf(s, "%d\n", debug_bank);
+ return seq_printf(s, "%u\n", debug_bank);
}
static int ab8500_bank_open(struct inode *inode, struct file *file)
@@ -421,7 +421,7 @@ static ssize_t ab8500_bank_write(struct file *file,
struct device *dev = ((struct seq_file *)(file->private_data))->private;
char buf[32];
int buf_size;
- unsigned long user_bank;
+ u8 user_bank;
int err;
/* Get userspace string and assure termination */
@@ -430,9 +430,9 @@ static ssize_t ab8500_bank_write(struct file *file,
return -EFAULT;
buf[buf_size] = 0;
- err = strict_strtoul(buf, 0, &user_bank);
+ err = kstrtou8(buf, 0, &user_bank);
if (err)
- return -EINVAL;
+ return err;
if (user_bank >= AB8500_NUM_BANKS) {
dev_err(dev, "debugfs error input > number of banks\n");
@@ -458,10 +458,8 @@ static ssize_t ab8500_address_write(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
char buf[32];
int buf_size;
- unsigned long user_address;
int err;
/* Get userspace string and assure termination */
@@ -470,14 +468,9 @@ static ssize_t ab8500_address_write(struct file *file,
return -EFAULT;
buf[buf_size] = 0;
- err = strict_strtoul(buf, 0, &user_address);
+ err = kstrtou8(buf, 0, &debug_address);
if (err)
- return -EINVAL;
- if (user_address > 0xff) {
- dev_err(dev, "debugfs error input > 0xff\n");
- return -EINVAL;
- }
- debug_address = user_address;
+ return err;
return buf_size;
}
@@ -488,7 +481,7 @@ static int ab8500_val_print(struct seq_file *s, void *p)
u8 regvalue;
ret = abx500_get_register_interruptible(dev,
- (u8)debug_bank, (u8)debug_address, ®value);
+ debug_bank, debug_address, ®value);
if (ret < 0) {
dev_err(dev, "abx500_get_reg fail %d, %d\n",
ret, __LINE__);
@@ -511,7 +504,7 @@ static ssize_t ab8500_val_write(struct file *file,
struct device *dev = ((struct seq_file *)(file->private_data))->private;
char buf[32];
int buf_size;
- unsigned long user_val;
+ u8 user_val;
int err;
/* Get userspace string and assure termination */
@@ -520,15 +513,11 @@ static ssize_t ab8500_val_write(struct file *file,
return -EFAULT;
buf[buf_size] = 0;
- err = strict_strtoul(buf, 0, &user_val);
+ err = kstrtou8(buf, 0, &user_val);
if (err)
- return -EINVAL;
- if (user_val > 0xff) {
- dev_err(dev, "debugfs error input > 0xff\n");
- return -EINVAL;
- }
+ return err;
err = abx500_set_register_interruptible(dev,
- (u8)debug_bank, debug_address, (u8)user_val);
+ debug_bank, debug_address, user_val);
if (err < 0) {
printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
return -EINVAL;
--
1.7.2.2
next prev parent reply other threads:[~2010-12-05 17:51 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-05 17:48 [PATCH 01/45] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
2010-12-05 17:48 ` [PATCH 02/45] kstrtox: convert arch/x86/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 03/45] kstrtox: convert arch/arm/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 04/45] kstrtox: convert kernel/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 05/45] kstrtox: kernel/trace/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 06/45] kstrtox: convert mm/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 07/45] kstrtox: convert fs/fuse/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 08/45] kstrtox: convert fs/nfs/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 09/45] kstrtox: convert fs/proc/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 10/45] kstrtox: convert security/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 11/45] kstrtox: convert block/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 12/45] kstrtox: convert drivers/acpi/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 13/45] kstrtox: convert drivers/ata/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 14/45] kstrtox: convert drivers/base/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 15/45] kstrtox: convert drivers/block/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 16/45] kstrtox: convert drivers/bluetooth/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 17/45] kstrtox: convert drivers/clocksource/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 18/45] kstrtox: convert drivers/edac/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 19/45] kstrtox: convert drivers/gpio/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 20/45] kstrtox: convert drivers/gpu/drm/nouveau/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 21/45] kstrtox: convert drivers/hid/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 22/45] kstrtox: convert drivers/hwmon/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 23/45] kstrtox: convert drivers/ide/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 24/45] kstrtox: convert drivers/infiniband/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 25/45] kstrtox: convert drivers/input/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 26/45] kstrtox: convert drivers/isdn/ Alexey Dobriyan
2010-12-06 0:10 ` Tilman Schmidt
2010-12-06 20:10 ` Alexey Dobriyan
2010-12-07 10:06 ` Tilman Schmidt
2010-12-05 17:49 ` [PATCH 27/45] kstrtox: convert drivers/leds/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 28/45] kstrtox: convert drivers/md/ Alexey Dobriyan
2010-12-05 17:49 ` Alexey Dobriyan [this message]
2010-12-05 17:49 ` [PATCH 30/45] kstrtox: convert drivers/misc/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 31/45] kstrtox: convert drivers/mmc/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 32/45] kstrtox: convert drivers/net/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 33/45] kstrtox: convert drivers/net/wireless/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 34/45] kstrtox: convert drivers/pci/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 35/45] kstrtox: convert drivers/platform/x86/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 36/45] kstrtox: convert drivers/power/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 37/45] kstrtox: convert drivers/regulator/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 38/45] kstrtox: convert drivers/rtc/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 39/45] kstrtox: convert drivers/scsi/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 40/45] kstrtox: convert drivers/ssb/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 41/45] kstrtox: convert drivers/usb/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 42/45] kstrtox: convert drivers/video/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 43/45] kstrtox: convert drivers/w1/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 44/45] kstrtox: convert sound/ Alexey Dobriyan
2010-12-05 17:49 ` [PATCH 45/45] kstrtox: convert net/ Alexey Dobriyan
2010-12-06 0:25 ` [PATCH 01/45] kstrtox: converting strings to integers done (hopefully) right Jesper Juhl
2010-12-06 15:16 ` Alexey Dobriyan
2010-12-07 9:04 ` Arnd Bergmann
2010-12-07 9:32 ` Alexey Dobriyan
2010-12-07 9:45 ` Arnd Bergmann
2010-12-08 8:51 ` Alexey Dobriyan
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=1291571382-2719-29-git-send-email-adobriyan@gmail.com \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).