diff options
| author | Jan Beulich <JBeulich@suse.com> | 2016-07-07 04:05:46 -0400 |
|---|---|---|
| committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2016-07-22 08:23:45 -0400 |
| commit | ff595325ed556fb4b83af5b9ffd5c427c18405d7 (patch) | |
| tree | 162b59688b4783ec48266ac153f4a2a9ed13eaa1 | |
| parent | 6694389af9be4d1eb8d3313788a902f0590fb8c2 (diff) | |
xen-blkfront: prefer xenbus_scanf() over xenbus_gather()
... for single items being collected: It is more typesafe (as the
compiler can check format string and to-be-written-to variable match)
and requires one less parameter to be passed.
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
| -rw-r--r-- | drivers/block/xen-blkfront.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2e6d1e9c3345..ca0536eb7037 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
| @@ -2208,10 +2208,9 @@ static void blkfront_setup_discard(struct blkfront_info *info) | |||
| 2208 | info->discard_granularity = discard_granularity; | 2208 | info->discard_granularity = discard_granularity; |
| 2209 | info->discard_alignment = discard_alignment; | 2209 | info->discard_alignment = discard_alignment; |
| 2210 | } | 2210 | } |
| 2211 | err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | 2211 | err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, |
| 2212 | "discard-secure", "%d", &discard_secure, | 2212 | "discard-secure", "%u", &discard_secure); |
| 2213 | NULL); | 2213 | if (err > 0) |
| 2214 | if (!err) | ||
| 2215 | info->feature_secdiscard = !!discard_secure; | 2214 | info->feature_secdiscard = !!discard_secure; |
| 2216 | } | 2215 | } |
| 2217 | 2216 | ||
| @@ -2310,9 +2309,8 @@ static void blkfront_gather_backend_features(struct blkfront_info *info) | |||
| 2310 | 2309 | ||
| 2311 | info->feature_flush = 0; | 2310 | info->feature_flush = 0; |
| 2312 | 2311 | ||
| 2313 | err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | 2312 | err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, |
| 2314 | "feature-barrier", "%d", &barrier, | 2313 | "feature-barrier", "%d", &barrier); |
| 2315 | NULL); | ||
| 2316 | 2314 | ||
| 2317 | /* | 2315 | /* |
| 2318 | * If there's no "feature-barrier" defined, then it means | 2316 | * If there's no "feature-barrier" defined, then it means |
| @@ -2321,38 +2319,35 @@ static void blkfront_gather_backend_features(struct blkfront_info *info) | |||
| 2321 | * | 2319 | * |
| 2322 | * If there are barriers, then we use flush. | 2320 | * If there are barriers, then we use flush. |
| 2323 | */ | 2321 | */ |
| 2324 | if (!err && barrier) | 2322 | if (err > 0 && barrier) |
| 2325 | info->feature_flush = REQ_FLUSH | REQ_FUA; | 2323 | info->feature_flush = REQ_FLUSH | REQ_FUA; |
| 2326 | /* | 2324 | /* |
| 2327 | * And if there is "feature-flush-cache" use that above | 2325 | * And if there is "feature-flush-cache" use that above |
| 2328 | * barriers. | 2326 | * barriers. |
| 2329 | */ | 2327 | */ |
| 2330 | err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | 2328 | err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, |
| 2331 | "feature-flush-cache", "%d", &flush, | 2329 | "feature-flush-cache", "%d", &flush); |
| 2332 | NULL); | ||
| 2333 | 2330 | ||
| 2334 | if (!err && flush) | 2331 | if (err > 0 && flush) |
| 2335 | info->feature_flush = REQ_FLUSH; | 2332 | info->feature_flush = REQ_FLUSH; |
| 2336 | 2333 | ||
| 2337 | err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | 2334 | err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, |
| 2338 | "feature-discard", "%d", &discard, | 2335 | "feature-discard", "%d", &discard); |
| 2339 | NULL); | ||
| 2340 | 2336 | ||
| 2341 | if (!err && discard) | 2337 | if (err > 0 && discard) |
| 2342 | blkfront_setup_discard(info); | 2338 | blkfront_setup_discard(info); |
| 2343 | 2339 | ||
| 2344 | err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | 2340 | err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, |
| 2345 | "feature-persistent", "%u", &persistent, | 2341 | "feature-persistent", "%d", &persistent); |
| 2346 | NULL); | 2342 | if (err <= 0) |
| 2347 | if (err) | ||
| 2348 | info->feature_persistent = 0; | 2343 | info->feature_persistent = 0; |
| 2349 | else | 2344 | else |
| 2350 | info->feature_persistent = persistent; | 2345 | info->feature_persistent = persistent; |
| 2351 | 2346 | ||
| 2352 | err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | 2347 | err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, |
| 2353 | "feature-max-indirect-segments", "%u", &indirect_segments, | 2348 | "feature-max-indirect-segments", "%u", |
| 2354 | NULL); | 2349 | &indirect_segments); |
| 2355 | if (err) | 2350 | if (err <= 0) |
| 2356 | info->max_indirect_segments = 0; | 2351 | info->max_indirect_segments = 0; |
| 2357 | else | 2352 | else |
| 2358 | info->max_indirect_segments = min(indirect_segments, | 2353 | info->max_indirect_segments = min(indirect_segments, |
