.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
12 | 4 | */ |
---|
13 | 5 | #include <linux/blkdev.h> |
---|
14 | 6 | #include <linux/device.h> |
---|
.. | .. |
---|
32 | 24 | kfree(nd_btt->uuid); |
---|
33 | 25 | kfree(nd_btt); |
---|
34 | 26 | } |
---|
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); |
---|
46 | 27 | |
---|
47 | 28 | struct nd_btt *to_nd_btt(struct device *dev) |
---|
48 | 29 | { |
---|
.. | .. |
---|
70 | 51 | struct nd_btt *nd_btt = to_nd_btt(dev); |
---|
71 | 52 | ssize_t rc; |
---|
72 | 53 | |
---|
73 | | - device_lock(dev); |
---|
| 54 | + nd_device_lock(dev); |
---|
74 | 55 | nvdimm_bus_lock(dev); |
---|
75 | 56 | rc = nd_size_select_store(dev, buf, &nd_btt->lbasize, |
---|
76 | 57 | btt_lbasize_supported); |
---|
77 | 58 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
---|
78 | 59 | buf[len - 1] == '\n' ? "" : "\n"); |
---|
79 | 60 | nvdimm_bus_unlock(dev); |
---|
80 | | - device_unlock(dev); |
---|
| 61 | + nd_device_unlock(dev); |
---|
81 | 62 | |
---|
82 | 63 | return rc ? rc : len; |
---|
83 | 64 | } |
---|
.. | .. |
---|
99 | 80 | struct nd_btt *nd_btt = to_nd_btt(dev); |
---|
100 | 81 | ssize_t rc; |
---|
101 | 82 | |
---|
102 | | - device_lock(dev); |
---|
| 83 | + nd_device_lock(dev); |
---|
103 | 84 | rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len); |
---|
104 | 85 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
---|
105 | 86 | buf[len - 1] == '\n' ? "" : "\n"); |
---|
106 | | - device_unlock(dev); |
---|
| 87 | + nd_device_unlock(dev); |
---|
107 | 88 | |
---|
108 | 89 | return rc ? rc : len; |
---|
109 | 90 | } |
---|
.. | .. |
---|
128 | 109 | struct nd_btt *nd_btt = to_nd_btt(dev); |
---|
129 | 110 | ssize_t rc; |
---|
130 | 111 | |
---|
131 | | - device_lock(dev); |
---|
| 112 | + nd_device_lock(dev); |
---|
132 | 113 | nvdimm_bus_lock(dev); |
---|
133 | 114 | rc = nd_namespace_store(dev, &nd_btt->ndns, buf, len); |
---|
134 | 115 | dev_dbg(dev, "result: %zd wrote: %s%s", rc, buf, |
---|
135 | 116 | buf[len - 1] == '\n' ? "" : "\n"); |
---|
136 | 117 | nvdimm_bus_unlock(dev); |
---|
137 | | - device_unlock(dev); |
---|
| 118 | + nd_device_unlock(dev); |
---|
138 | 119 | |
---|
139 | 120 | return rc; |
---|
140 | 121 | } |
---|
.. | .. |
---|
146 | 127 | struct nd_btt *nd_btt = to_nd_btt(dev); |
---|
147 | 128 | ssize_t rc; |
---|
148 | 129 | |
---|
149 | | - device_lock(dev); |
---|
| 130 | + nd_device_lock(dev); |
---|
150 | 131 | if (dev->driver) |
---|
151 | 132 | rc = sprintf(buf, "%llu\n", nd_btt->size); |
---|
152 | 133 | else { |
---|
153 | 134 | /* no size to convey if the btt instance is disabled */ |
---|
154 | 135 | rc = -ENXIO; |
---|
155 | 136 | } |
---|
156 | | - device_unlock(dev); |
---|
| 137 | + nd_device_unlock(dev); |
---|
157 | 138 | |
---|
158 | 139 | return rc; |
---|
159 | 140 | } |
---|
.. | .. |
---|
186 | 167 | NULL, |
---|
187 | 168 | }; |
---|
188 | 169 | |
---|
| 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 | + |
---|
189 | 182 | static struct device *__nd_btt_create(struct nd_region *nd_region, |
---|
190 | 183 | unsigned long lbasize, u8 *uuid, |
---|
191 | 184 | struct nd_namespace_common *ndns) |
---|
.. | .. |
---|
212 | 205 | dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id); |
---|
213 | 206 | dev->parent = &nd_region->dev; |
---|
214 | 207 | dev->type = &nd_btt_device_type; |
---|
215 | | - dev->groups = nd_btt_attribute_groups; |
---|
216 | 208 | device_initialize(&nd_btt->dev); |
---|
217 | 209 | if (ndns && !__nd_attach_ndns(&nd_btt->dev, ndns, &nd_btt->ndns)) { |
---|
218 | 210 | dev_dbg(&ndns->dev, "failed, already claimed by %s\n", |
---|