hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/nvdimm/badrange.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright(c) 2017 Intel Corporation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of version 2 of the GNU General Public License as
6
- * published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License for more details.
124 */
135 #include <linux/libnvdimm.h>
146 #include <linux/badblocks.h>
....@@ -219,7 +211,7 @@
219211 }
220212
221213 static void badblocks_populate(struct badrange *badrange,
222
- struct badblocks *bb, const struct resource *res)
214
+ struct badblocks *bb, const struct range *range)
223215 {
224216 struct badrange_entry *bre;
225217
....@@ -230,34 +222,34 @@
230222 u64 bre_end = bre->start + bre->length - 1;
231223
232224 /* Discard intervals with no intersection */
233
- if (bre_end < res->start)
225
+ if (bre_end < range->start)
234226 continue;
235
- if (bre->start > res->end)
227
+ if (bre->start > range->end)
236228 continue;
237229 /* Deal with any overlap after start of the namespace */
238
- if (bre->start >= res->start) {
230
+ if (bre->start >= range->start) {
239231 u64 start = bre->start;
240232 u64 len;
241233
242
- if (bre_end <= res->end)
234
+ if (bre_end <= range->end)
243235 len = bre->length;
244236 else
245
- len = res->start + resource_size(res)
237
+ len = range->start + range_len(range)
246238 - bre->start;
247
- __add_badblock_range(bb, start - res->start, len);
239
+ __add_badblock_range(bb, start - range->start, len);
248240 continue;
249241 }
250242 /*
251243 * Deal with overlap for badrange starting before
252244 * the namespace.
253245 */
254
- if (bre->start < res->start) {
246
+ if (bre->start < range->start) {
255247 u64 len;
256248
257
- if (bre_end < res->end)
258
- len = bre->start + bre->length - res->start;
249
+ if (bre_end < range->end)
250
+ len = bre->start + bre->length - range->start;
259251 else
260
- len = resource_size(res);
252
+ len = range_len(range);
261253 __add_badblock_range(bb, 0, len);
262254 }
263255 }
....@@ -275,7 +267,7 @@
275267 * and add badblocks entries for all matching sub-ranges
276268 */
277269 void nvdimm_badblocks_populate(struct nd_region *nd_region,
278
- struct badblocks *bb, const struct resource *res)
270
+ struct badblocks *bb, const struct range *range)
279271 {
280272 struct nvdimm_bus *nvdimm_bus;
281273
....@@ -287,7 +279,7 @@
287279 nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev);
288280
289281 nvdimm_bus_lock(&nvdimm_bus->dev);
290
- badblocks_populate(&nvdimm_bus->badrange, bb, res);
282
+ badblocks_populate(&nvdimm_bus->badrange, bb, range);
291283 nvdimm_bus_unlock(&nvdimm_bus->dev);
292284 }
293285 EXPORT_SYMBOL_GPL(nvdimm_badblocks_populate);