aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authormajianpeng <majianpeng@gmail.com>2012-07-27 10:07:59 -0400
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 10:07:59 -0400
commit1a66a08ae82b16eb40705ad112ff28873981af92 (patch)
treeafb3a927ce42b549df8083e66cca23cd865ab80a /drivers
parent70c48611024791ccf83aca6195b58a5db9325485 (diff)
dm: replace simple_strtoul
Replace obsolete simple_strtoul() with kstrtou8/kstrtouint. Signed-off-by: majianpeng <majianpeng@gmail.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-crypt.c5
-rw-r--r--drivers/md/dm-exception-store.c13
-rw-r--r--drivers/md/dm-stripe.c7
3 files changed, 7 insertions, 18 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 3f06df59fd82..e2b32401ecc7 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1241,7 +1241,6 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io)
1241static int crypt_decode_key(u8 *key, char *hex, unsigned int size) 1241static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
1242{ 1242{
1243 char buffer[3]; 1243 char buffer[3];
1244 char *endp;
1245 unsigned int i; 1244 unsigned int i;
1246 1245
1247 buffer[2] = '\0'; 1246 buffer[2] = '\0';
@@ -1250,9 +1249,7 @@ static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
1250 buffer[0] = *hex++; 1249 buffer[0] = *hex++;
1251 buffer[1] = *hex++; 1250 buffer[1] = *hex++;
1252 1251
1253 key[i] = (u8)simple_strtoul(buffer, &endp, 16); 1252 if (kstrtou8(buffer, 16, &key[i]))
1254
1255 if (endp != &buffer[2])
1256 return -EINVAL; 1253 return -EINVAL;
1257 } 1254 }
1258 1255
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index aa70f7d43a1a..ebaa4f803eec 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -142,24 +142,19 @@ EXPORT_SYMBOL(dm_exception_store_type_unregister);
142static int set_chunk_size(struct dm_exception_store *store, 142static int set_chunk_size(struct dm_exception_store *store,
143 const char *chunk_size_arg, char **error) 143 const char *chunk_size_arg, char **error)
144{ 144{
145 unsigned long chunk_size_ulong; 145 unsigned chunk_size;
146 char *value;
147 146
148 chunk_size_ulong = simple_strtoul(chunk_size_arg, &value, 10); 147 if (kstrtouint(chunk_size_arg, 10, &chunk_size)) {
149 if (*chunk_size_arg == '\0' || *value != '\0' ||
150 chunk_size_ulong > UINT_MAX) {
151 *error = "Invalid chunk size"; 148 *error = "Invalid chunk size";
152 return -EINVAL; 149 return -EINVAL;
153 } 150 }
154 151
155 if (!chunk_size_ulong) { 152 if (!chunk_size) {
156 store->chunk_size = store->chunk_mask = store->chunk_shift = 0; 153 store->chunk_size = store->chunk_mask = store->chunk_shift = 0;
157 return 0; 154 return 0;
158 } 155 }
159 156
160 return dm_exception_store_set_chunk_size(store, 157 return dm_exception_store_set_chunk_size(store, chunk_size, error);
161 (unsigned) chunk_size_ulong,
162 error);
163} 158}
164 159
165int dm_exception_store_set_chunk_size(struct dm_exception_store *store, 160int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 35c94ff24ad5..183db5d3e48e 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -99,7 +99,6 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
99 sector_t width; 99 sector_t width;
100 uint32_t stripes; 100 uint32_t stripes;
101 uint32_t chunk_size; 101 uint32_t chunk_size;
102 char *end;
103 int r; 102 int r;
104 unsigned int i; 103 unsigned int i;
105 104
@@ -108,14 +107,12 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
108 return -EINVAL; 107 return -EINVAL;
109 } 108 }
110 109
111 stripes = simple_strtoul(argv[0], &end, 10); 110 if (kstrtouint(argv[0], 10, &stripes) || !stripes) {
112 if (!stripes || *end) {
113 ti->error = "Invalid stripe count"; 111 ti->error = "Invalid stripe count";
114 return -EINVAL; 112 return -EINVAL;
115 } 113 }
116 114
117 chunk_size = simple_strtoul(argv[1], &end, 10); 115 if (kstrtouint(argv[1], 10, &chunk_size)) {
118 if (*end) {
119 ti->error = "Invalid chunk_size"; 116 ti->error = "Invalid chunk_size";
120 return -EINVAL; 117 return -EINVAL;
121 } 118 }