From: Alexey Dobriyan <adobriyan@gmail.com>
To: axboe@kernel.dk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] block: convert to kstrto*()
Date: Sun, 17 May 2015 15:27:13 +0300 [thread overview]
Message-ID: <20150517122713.GA2537@p183.telecom.by> (raw)
Convert block/ code away from deprecated simple_strto*() interfaces.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
block/blk-integrity.c | 14 ++++++++++----
block/blk-timeout.c | 25 ++++++++++++-------------
block/cfq-iosched.c | 15 ++++-----------
block/deadline-iosched.c | 15 ++++-----------
4 files changed, 30 insertions(+), 39 deletions(-)
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -288,9 +288,12 @@ static ssize_t integrity_tag_size_show(struct blk_integrity *bi, char *page)
static ssize_t integrity_verify_store(struct blk_integrity *bi,
const char *page, size_t count)
{
- char *p = (char *) page;
- unsigned long val = simple_strtoul(p, &p, 10);
+ unsigned long val;
+ int rv;
+ rv = kstrtoul(page, 10, &val);
+ if (rv < 0)
+ return rv;
if (val)
bi->flags |= BLK_INTEGRITY_VERIFY;
else
@@ -307,9 +310,12 @@ static ssize_t integrity_verify_show(struct blk_integrity *bi, char *page)
static ssize_t integrity_generate_store(struct blk_integrity *bi,
const char *page, size_t count)
{
- char *p = (char *) page;
- unsigned long val = simple_strtoul(p, &p, 10);
+ unsigned long val;
+ int rv;
+ rv = kstrtoul(page, 10, &val);
+ if (rv < 0)
+ return rv;
if (val)
bi->flags |= BLK_INTEGRITY_GENERATE;
else
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -50,20 +50,19 @@ ssize_t part_timeout_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct gendisk *disk = dev_to_disk(dev);
+ struct request_queue *q = disk->queue;
int val;
-
- if (count) {
- struct request_queue *q = disk->queue;
- char *p = (char *) buf;
-
- val = simple_strtoul(p, &p, 10);
- spin_lock_irq(q->queue_lock);
- if (val)
- queue_flag_set(QUEUE_FLAG_FAIL_IO, q);
- else
- queue_flag_clear(QUEUE_FLAG_FAIL_IO, q);
- spin_unlock_irq(q->queue_lock);
- }
+ int rv;
+
+ rv = kstrtoint(buf, 10, &val);
+ if (rv < 0)
+ return rv;
+ spin_lock_irq(q->queue_lock);
+ if (val)
+ queue_flag_set(QUEUE_FLAG_FAIL_IO, q);
+ else
+ queue_flag_clear(QUEUE_FLAG_FAIL_IO, q);
+ spin_unlock_irq(q->queue_lock);
return count;
}
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -4486,15 +4486,6 @@ cfq_var_show(unsigned int var, char *page)
return sprintf(page, "%u\n", var);
}
-static ssize_t
-cfq_var_store(unsigned int *var, const char *page, size_t count)
-{
- char *p = (char *) page;
-
- *var = simple_strtoul(p, &p, 10);
- return count;
-}
-
#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
static ssize_t __FUNC(struct elevator_queue *e, char *page) \
{ \
@@ -4523,7 +4514,9 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
{ \
struct cfq_data *cfqd = e->elevator_data; \
unsigned int __data; \
- int ret = cfq_var_store(&__data, (page), count); \
+ int ret = kstrtouint(page, 10, &__data); \
+ if (ret < 0) \
+ return ret; \
if (__data < (MIN)) \
__data = (MIN); \
else if (__data > (MAX)) \
@@ -4532,7 +4525,7 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
*(__PTR) = msecs_to_jiffies(__data); \
else \
*(__PTR) = __data; \
- return ret; \
+ return count; \
}
STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1,
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -379,15 +379,6 @@ deadline_var_show(int var, char *page)
return sprintf(page, "%d\n", var);
}
-static ssize_t
-deadline_var_store(int *var, const char *page, size_t count)
-{
- char *p = (char *) page;
-
- *var = simple_strtol(p, &p, 10);
- return count;
-}
-
#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
static ssize_t __FUNC(struct elevator_queue *e, char *page) \
{ \
@@ -409,7 +400,9 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
{ \
struct deadline_data *dd = e->elevator_data; \
int __data; \
- int ret = deadline_var_store(&__data, (page), count); \
+ int ret = kstrtoint(page, 10, &__data); \
+ if (ret < 0) \
+ return ret; \
if (__data < (MIN)) \
__data = (MIN); \
else if (__data > (MAX)) \
@@ -418,7 +411,7 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
*(__PTR) = msecs_to_jiffies(__data); \
else \
*(__PTR) = __data; \
- return ret; \
+ return count; \
}
STORE_FUNCTION(deadline_read_expire_store, &dd->fifo_expire[READ], 0, INT_MAX, 1);
STORE_FUNCTION(deadline_write_expire_store, &dd->fifo_expire[WRITE], 0, INT_MAX, 1);
reply other threads:[~2015-05-17 12:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20150517122713.GA2537@p183.telecom.by \
--to=adobriyan@gmail.com \
--cc=axboe@kernel.dk \
--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).