hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/nvdimm/btt_devs.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright(c) 2013-2015 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/blkdev.h>
146 #include <linux/device.h>
....@@ -32,17 +24,6 @@
3224 kfree(nd_btt->uuid);
3325 kfree(nd_btt);
3426 }
35
-
36
-static struct device_type nd_btt_device_type = {
37
- .name = "nd_btt",
38
- .release = nd_btt_release,
39
-};
40
-
41
-bool is_nd_btt(struct device *dev)
42
-{
43
- return dev->type == &nd_btt_device_type;
44
-}
45
-EXPORT_SYMBOL(is_nd_btt);
4627
4728 struct nd_btt *to_nd_btt(struct device *dev)
4829 {
....@@ -70,14 +51,14 @@
7051 struct nd_btt *nd_btt = to_nd_btt(dev);
7152 ssize_t rc;
7253
73
- device_lock(dev);
54
+ nd_device_lock(dev);
7455 nvdimm_bus_lock(dev);
7556 rc = nd_size_select_store(dev, buf, &nd_btt->lbasize,
7657 btt_lbasize_supported);
7758 dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
7859 buf[len - 1] == '\n' ? "" : "\n");
7960 nvdimm_bus_unlock(dev);
80
- device_unlock(dev);
61
+ nd_device_unlock(dev);
8162
8263 return rc ? rc : len;
8364 }
....@@ -99,11 +80,11 @@
9980 struct nd_btt *nd_btt = to_nd_btt(dev);
10081 ssize_t rc;
10182
102
- device_lock(dev);
83
+ nd_device_lock(dev);
10384 rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len);
10485 dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
10586 buf[len - 1] == '\n' ? "" : "\n");
106
- device_unlock(dev);
87
+ nd_device_unlock(dev);
10788
10889 return rc ? rc : len;
10990 }
....@@ -128,13 +109,13 @@
128109 struct nd_btt *nd_btt = to_nd_btt(dev);
129110 ssize_t rc;
130111
131
- device_lock(dev);
112
+ nd_device_lock(dev);
132113 nvdimm_bus_lock(dev);
133114 rc = nd_namespace_store(dev, &nd_btt->ndns, buf, len);
134115 dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf,
135116 buf[len - 1] == '\n' ? "" : "\n");
136117 nvdimm_bus_unlock(dev);
137
- device_unlock(dev);
118
+ nd_device_unlock(dev);
138119
139120 return rc;
140121 }
....@@ -146,14 +127,14 @@
146127 struct nd_btt *nd_btt = to_nd_btt(dev);
147128 ssize_t rc;
148129
149
- device_lock(dev);
130
+ nd_device_lock(dev);
150131 if (dev->driver)
151132 rc = sprintf(buf, "%llu\n", nd_btt->size);
152133 else {
153134 /* no size to convey if the btt instance is disabled */
154135 rc = -ENXIO;
155136 }
156
- device_unlock(dev);
137
+ nd_device_unlock(dev);
157138
158139 return rc;
159140 }
....@@ -186,6 +167,18 @@
186167 NULL,
187168 };
188169
170
+static const struct device_type nd_btt_device_type = {
171
+ .name = "nd_btt",
172
+ .release = nd_btt_release,
173
+ .groups = nd_btt_attribute_groups,
174
+};
175
+
176
+bool is_nd_btt(struct device *dev)
177
+{
178
+ return dev->type == &nd_btt_device_type;
179
+}
180
+EXPORT_SYMBOL(is_nd_btt);
181
+
189182 static struct device *__nd_btt_create(struct nd_region *nd_region,
190183 unsigned long lbasize, u8 *uuid,
191184 struct nd_namespace_common *ndns)
....@@ -212,7 +205,6 @@
212205 dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
213206 dev->parent = &nd_region->dev;
214207 dev->type = &nd_btt_device_type;
215
- dev->groups = nd_btt_attribute_groups;
216208 device_initialize(&nd_btt->dev);
217209 if (ndns && !__nd_attach_ndns(&nd_btt->dev, ndns, &nd_btt->ndns)) {
218210 dev_dbg(&ndns->dev, "failed, already claimed by %s\n",