diff options
author | Dan Streetman <ddstreet@ieee.org> | 2015-11-06 19:29:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-06 20:50:42 -0500 |
commit | 69e18f4dbedfbf208452e9da9979c92da30d2442 (patch) | |
tree | a2052fea74be8c0180a6697b8d61c70920ed6095 /mm | |
parent | c99b42c3529e5e1bff00f68250dc869f7de3bd5f (diff) |
zpool: remove redundant zpool->type string, const-ify zpool_get_type
Make the return type of zpool_get_type const; the string belongs to the
zpool driver and should not be modified. Remove the redundant type field
in the struct zpool; it is private to zpool.c and isn't needed since
->driver->type can be used directly. Add comments indicating strings must
be null-terminated.
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Seth Jennings <sjennings@variantweb.net>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/zpool.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mm/zpool.c b/mm/zpool.c index 8f670d3e8706..13f524dcf215 100644 --- a/mm/zpool.c +++ b/mm/zpool.c | |||
@@ -18,8 +18,6 @@ | |||
18 | #include <linux/zpool.h> | 18 | #include <linux/zpool.h> |
19 | 19 | ||
20 | struct zpool { | 20 | struct zpool { |
21 | char *type; | ||
22 | |||
23 | struct zpool_driver *driver; | 21 | struct zpool_driver *driver; |
24 | void *pool; | 22 | void *pool; |
25 | const struct zpool_ops *ops; | 23 | const struct zpool_ops *ops; |
@@ -73,6 +71,7 @@ int zpool_unregister_driver(struct zpool_driver *driver) | |||
73 | } | 71 | } |
74 | EXPORT_SYMBOL(zpool_unregister_driver); | 72 | EXPORT_SYMBOL(zpool_unregister_driver); |
75 | 73 | ||
74 | /* this assumes @type is null-terminated. */ | ||
76 | static struct zpool_driver *zpool_get_driver(char *type) | 75 | static struct zpool_driver *zpool_get_driver(char *type) |
77 | { | 76 | { |
78 | struct zpool_driver *driver; | 77 | struct zpool_driver *driver; |
@@ -113,6 +112,8 @@ static void zpool_put_driver(struct zpool_driver *driver) | |||
113 | * not be loaded, and calling @zpool_create_pool() with the pool type will | 112 | * not be loaded, and calling @zpool_create_pool() with the pool type will |
114 | * fail. | 113 | * fail. |
115 | * | 114 | * |
115 | * The @type string must be null-terminated. | ||
116 | * | ||
116 | * Returns: true if @type pool is available, false if not | 117 | * Returns: true if @type pool is available, false if not |
117 | */ | 118 | */ |
118 | bool zpool_has_pool(char *type) | 119 | bool zpool_has_pool(char *type) |
@@ -145,6 +146,8 @@ EXPORT_SYMBOL(zpool_has_pool); | |||
145 | * | 146 | * |
146 | * Implementations must guarantee this to be thread-safe. | 147 | * Implementations must guarantee this to be thread-safe. |
147 | * | 148 | * |
149 | * The @type and @name strings must be null-terminated. | ||
150 | * | ||
148 | * Returns: New zpool on success, NULL on failure. | 151 | * Returns: New zpool on success, NULL on failure. |
149 | */ | 152 | */ |
150 | struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp, | 153 | struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp, |
@@ -174,7 +177,6 @@ struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp, | |||
174 | return NULL; | 177 | return NULL; |
175 | } | 178 | } |
176 | 179 | ||
177 | zpool->type = driver->type; | ||
178 | zpool->driver = driver; | 180 | zpool->driver = driver; |
179 | zpool->pool = driver->create(name, gfp, ops, zpool); | 181 | zpool->pool = driver->create(name, gfp, ops, zpool); |
180 | zpool->ops = ops; | 182 | zpool->ops = ops; |
@@ -208,7 +210,7 @@ struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp, | |||
208 | */ | 210 | */ |
209 | void zpool_destroy_pool(struct zpool *zpool) | 211 | void zpool_destroy_pool(struct zpool *zpool) |
210 | { | 212 | { |
211 | pr_debug("destroying pool type %s\n", zpool->type); | 213 | pr_debug("destroying pool type %s\n", zpool->driver->type); |
212 | 214 | ||
213 | spin_lock(&pools_lock); | 215 | spin_lock(&pools_lock); |
214 | list_del(&zpool->list); | 216 | list_del(&zpool->list); |
@@ -228,9 +230,9 @@ void zpool_destroy_pool(struct zpool *zpool) | |||
228 | * | 230 | * |
229 | * Returns: The type of zpool. | 231 | * Returns: The type of zpool. |
230 | */ | 232 | */ |
231 | char *zpool_get_type(struct zpool *zpool) | 233 | const char *zpool_get_type(struct zpool *zpool) |
232 | { | 234 | { |
233 | return zpool->type; | 235 | return zpool->driver->type; |
234 | } | 236 | } |
235 | 237 | ||
236 | /** | 238 | /** |