Alan Tull | 473f01f | 2018-05-16 18:49:58 -0500 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 2 | /* |
Moritz Fischer | c71e805 | 2020-09-04 20:24:07 -0700 | [diff] [blame] | 3 | * FPGA Region - Support for FPGA programming under Linux |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2013-2016 Altera Corporation |
Alan Tull | ef3acdd | 2017-11-15 14:20:25 -0600 | [diff] [blame] | 6 | * Copyright (C) 2017 Intel Corporation |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 7 | */ |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 8 | #include <linux/fpga/fpga-bridge.h> |
| 9 | #include <linux/fpga/fpga-mgr.h> |
Alan Tull | 59460a9 | 2017-11-15 14:20:21 -0600 | [diff] [blame] | 10 | #include <linux/fpga/fpga-region.h> |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 11 | #include <linux/idr.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/list.h> |
| 14 | #include <linux/module.h> |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 15 | #include <linux/slab.h> |
| 16 | #include <linux/spinlock.h> |
| 17 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 18 | static DEFINE_IDA(fpga_region_ida); |
| 19 | static struct class *fpga_region_class; |
| 20 | |
Alan Tull | 503d4b7 | 2017-11-15 14:20:24 -0600 | [diff] [blame] | 21 | struct fpga_region *fpga_region_class_find( |
| 22 | struct device *start, const void *data, |
| 23 | int (*match)(struct device *, const void *)) |
| 24 | { |
| 25 | struct device *dev; |
| 26 | |
| 27 | dev = class_find_device(fpga_region_class, start, data, match); |
| 28 | if (!dev) |
| 29 | return NULL; |
| 30 | |
| 31 | return to_fpga_region(dev); |
| 32 | } |
| 33 | EXPORT_SYMBOL_GPL(fpga_region_class_find); |
| 34 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 35 | /** |
Tom Rix | 011c49e | 2021-06-08 14:23:47 -0700 | [diff] [blame] | 36 | * fpga_region_get - get an exclusive reference to an fpga region |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 37 | * @region: FPGA Region struct |
| 38 | * |
| 39 | * Caller should call fpga_region_put() when done with region. |
| 40 | * |
| 41 | * Return fpga_region struct if successful. |
| 42 | * Return -EBUSY if someone already has a reference to the region. |
Tom Rix | 011c49e | 2021-06-08 14:23:47 -0700 | [diff] [blame] | 43 | * Return -ENODEV if @np is not an FPGA Region. |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 44 | */ |
| 45 | static struct fpga_region *fpga_region_get(struct fpga_region *region) |
| 46 | { |
| 47 | struct device *dev = ®ion->dev; |
| 48 | |
| 49 | if (!mutex_trylock(®ion->mutex)) { |
| 50 | dev_dbg(dev, "%s: FPGA Region already in use\n", __func__); |
| 51 | return ERR_PTR(-EBUSY); |
| 52 | } |
| 53 | |
| 54 | get_device(dev); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 55 | if (!try_module_get(dev->parent->driver->owner)) { |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 56 | put_device(dev); |
| 57 | mutex_unlock(®ion->mutex); |
| 58 | return ERR_PTR(-ENODEV); |
| 59 | } |
| 60 | |
Alan Tull | c3d971a | 2017-11-15 14:20:14 -0600 | [diff] [blame] | 61 | dev_dbg(dev, "get\n"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 62 | |
| 63 | return region; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * fpga_region_put - release a reference to a region |
| 68 | * |
| 69 | * @region: FPGA region |
| 70 | */ |
| 71 | static void fpga_region_put(struct fpga_region *region) |
| 72 | { |
| 73 | struct device *dev = ®ion->dev; |
| 74 | |
Alan Tull | c3d971a | 2017-11-15 14:20:14 -0600 | [diff] [blame] | 75 | dev_dbg(dev, "put\n"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 76 | |
| 77 | module_put(dev->parent->driver->owner); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 78 | put_device(dev); |
| 79 | mutex_unlock(®ion->mutex); |
| 80 | } |
| 81 | |
| 82 | /** |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 83 | * fpga_region_program_fpga - program FPGA |
Alan Tull | 917a430 | 2018-05-16 18:50:01 -0500 | [diff] [blame] | 84 | * |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 85 | * @region: FPGA region |
Alan Tull | 917a430 | 2018-05-16 18:50:01 -0500 | [diff] [blame] | 86 | * |
Alan Tull | 61c3210 | 2017-11-15 14:20:19 -0600 | [diff] [blame] | 87 | * Program an FPGA using fpga image info (region->info). |
Alan Tull | 093a89d | 2018-04-16 20:43:37 -0700 | [diff] [blame] | 88 | * If the region has a get_bridges function, the exclusive reference for the |
| 89 | * bridges will be held if programming succeeds. This is intended to prevent |
| 90 | * reprogramming the region until the caller considers it safe to do so. |
| 91 | * The caller will need to call fpga_bridges_put() before attempting to |
| 92 | * reprogram the region. |
Alan Tull | 917a430 | 2018-05-16 18:50:01 -0500 | [diff] [blame] | 93 | * |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 94 | * Return 0 for success or negative error code. |
| 95 | */ |
Alan Tull | 59460a9 | 2017-11-15 14:20:21 -0600 | [diff] [blame] | 96 | int fpga_region_program_fpga(struct fpga_region *region) |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 97 | { |
Alan Tull | ebf877a5 | 2017-11-15 14:20:13 -0600 | [diff] [blame] | 98 | struct device *dev = ®ion->dev; |
Alan Tull | 61c3210 | 2017-11-15 14:20:19 -0600 | [diff] [blame] | 99 | struct fpga_image_info *info = region->info; |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 100 | int ret; |
| 101 | |
| 102 | region = fpga_region_get(region); |
| 103 | if (IS_ERR(region)) { |
Alan Tull | c3d971a | 2017-11-15 14:20:14 -0600 | [diff] [blame] | 104 | dev_err(dev, "failed to get FPGA region\n"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 105 | return PTR_ERR(region); |
| 106 | } |
| 107 | |
Alan Tull | 1df2dd7 | 2017-11-15 14:20:16 -0600 | [diff] [blame] | 108 | ret = fpga_mgr_lock(region->mgr); |
Alan Tull | ebf877a5 | 2017-11-15 14:20:13 -0600 | [diff] [blame] | 109 | if (ret) { |
| 110 | dev_err(dev, "FPGA manager is busy\n"); |
Alan Tull | 1df2dd7 | 2017-11-15 14:20:16 -0600 | [diff] [blame] | 111 | goto err_put_region; |
Alan Tull | ebf877a5 | 2017-11-15 14:20:13 -0600 | [diff] [blame] | 112 | } |
| 113 | |
Alan Tull | 52a3a7c | 2017-11-15 14:20:23 -0600 | [diff] [blame] | 114 | /* |
| 115 | * In some cases, we already have a list of bridges in the |
| 116 | * fpga region struct. Or we don't have any bridges. |
| 117 | */ |
| 118 | if (region->get_bridges) { |
| 119 | ret = region->get_bridges(region); |
| 120 | if (ret) { |
| 121 | dev_err(dev, "failed to get fpga region bridges\n"); |
| 122 | goto err_unlock_mgr; |
| 123 | } |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | ret = fpga_bridges_disable(®ion->bridge_list); |
| 127 | if (ret) { |
Alan Tull | c3d971a | 2017-11-15 14:20:14 -0600 | [diff] [blame] | 128 | dev_err(dev, "failed to disable bridges\n"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 129 | goto err_put_br; |
| 130 | } |
| 131 | |
Alan Tull | 61c3210 | 2017-11-15 14:20:19 -0600 | [diff] [blame] | 132 | ret = fpga_mgr_load(region->mgr, info); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 133 | if (ret) { |
Alan Tull | c3d971a | 2017-11-15 14:20:14 -0600 | [diff] [blame] | 134 | dev_err(dev, "failed to load FPGA image\n"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 135 | goto err_put_br; |
| 136 | } |
| 137 | |
| 138 | ret = fpga_bridges_enable(®ion->bridge_list); |
| 139 | if (ret) { |
Alan Tull | c3d971a | 2017-11-15 14:20:14 -0600 | [diff] [blame] | 140 | dev_err(dev, "failed to enable region bridges\n"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 141 | goto err_put_br; |
| 142 | } |
| 143 | |
Alan Tull | 1df2dd7 | 2017-11-15 14:20:16 -0600 | [diff] [blame] | 144 | fpga_mgr_unlock(region->mgr); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 145 | fpga_region_put(region); |
| 146 | |
| 147 | return 0; |
| 148 | |
| 149 | err_put_br: |
Alan Tull | 52a3a7c | 2017-11-15 14:20:23 -0600 | [diff] [blame] | 150 | if (region->get_bridges) |
| 151 | fpga_bridges_put(®ion->bridge_list); |
Alan Tull | ebf877a5 | 2017-11-15 14:20:13 -0600 | [diff] [blame] | 152 | err_unlock_mgr: |
Alan Tull | 1df2dd7 | 2017-11-15 14:20:16 -0600 | [diff] [blame] | 153 | fpga_mgr_unlock(region->mgr); |
Tobias Klauser | e73bbf6 | 2017-04-24 16:34:21 -0500 | [diff] [blame] | 154 | err_put_region: |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 155 | fpga_region_put(region); |
| 156 | |
| 157 | return ret; |
| 158 | } |
Alan Tull | 59460a9 | 2017-11-15 14:20:21 -0600 | [diff] [blame] | 159 | EXPORT_SYMBOL_GPL(fpga_region_program_fpga); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 160 | |
Wu Hao | 41a8b2c | 2018-06-30 08:53:12 +0800 | [diff] [blame] | 161 | static ssize_t compat_id_show(struct device *dev, |
| 162 | struct device_attribute *attr, char *buf) |
| 163 | { |
| 164 | struct fpga_region *region = to_fpga_region(dev); |
| 165 | |
| 166 | if (!region->compat_id) |
| 167 | return -ENOENT; |
| 168 | |
| 169 | return sprintf(buf, "%016llx%016llx\n", |
| 170 | (unsigned long long)region->compat_id->id_h, |
| 171 | (unsigned long long)region->compat_id->id_l); |
| 172 | } |
| 173 | |
| 174 | static DEVICE_ATTR_RO(compat_id); |
| 175 | |
| 176 | static struct attribute *fpga_region_attrs[] = { |
| 177 | &dev_attr_compat_id.attr, |
| 178 | NULL, |
| 179 | }; |
| 180 | ATTRIBUTE_GROUPS(fpga_region); |
| 181 | |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 182 | /** |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 183 | * fpga_region_register_full - create and register an FPGA Region device |
Russ Weight | 5e77886 | 2021-06-14 10:09:06 -0700 | [diff] [blame] | 184 | * @parent: device parent |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 185 | * @info: parameters for FPGA Region |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 186 | * |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 187 | * Return: struct fpga_region or ERR_PTR() |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 188 | */ |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 189 | struct fpga_region * |
| 190 | fpga_region_register_full(struct device *parent, const struct fpga_region_info *info) |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 191 | { |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 192 | struct fpga_region *region; |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 193 | int id, ret = 0; |
| 194 | |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 195 | if (!info) { |
| 196 | dev_err(parent, |
| 197 | "Attempt to register without required info structure\n"); |
| 198 | return ERR_PTR(-EINVAL); |
| 199 | } |
| 200 | |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 201 | region = kzalloc(sizeof(*region), GFP_KERNEL); |
| 202 | if (!region) |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 203 | return ERR_PTR(-ENOMEM); |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 204 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 205 | id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL); |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 206 | if (id < 0) { |
| 207 | ret = id; |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 208 | goto err_free; |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 209 | } |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 210 | |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 211 | region->mgr = info->mgr; |
| 212 | region->compat_id = info->compat_id; |
| 213 | region->priv = info->priv; |
| 214 | region->get_bridges = info->get_bridges; |
| 215 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 216 | mutex_init(®ion->mutex); |
| 217 | INIT_LIST_HEAD(®ion->bridge_list); |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 218 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 219 | region->dev.class = fpga_region_class; |
Russ Weight | 5e77886 | 2021-06-14 10:09:06 -0700 | [diff] [blame] | 220 | region->dev.parent = parent; |
| 221 | region->dev.of_node = parent->of_node; |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 222 | region->dev.id = id; |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 223 | |
| 224 | ret = dev_set_name(®ion->dev, "region%d", id); |
| 225 | if (ret) |
| 226 | goto err_remove; |
| 227 | |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 228 | ret = device_register(®ion->dev); |
| 229 | if (ret) { |
| 230 | put_device(®ion->dev); |
| 231 | return ERR_PTR(ret); |
| 232 | } |
| 233 | |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 234 | return region; |
Alan Tull | 52a3a7c | 2017-11-15 14:20:23 -0600 | [diff] [blame] | 235 | |
| 236 | err_remove: |
| 237 | ida_simple_remove(&fpga_region_ida, id); |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 238 | err_free: |
| 239 | kfree(region); |
| 240 | |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 241 | return ERR_PTR(ret); |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 242 | } |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 243 | EXPORT_SYMBOL_GPL(fpga_region_register_full); |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 244 | |
| 245 | /** |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 246 | * fpga_region_register - create and register an FPGA Region device |
Russ Weight | 5e77886 | 2021-06-14 10:09:06 -0700 | [diff] [blame] | 247 | * @parent: device parent |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 248 | * @mgr: manager that programs this region |
| 249 | * @get_bridges: optional function to get bridges to a list |
| 250 | * |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 251 | * This simple version of the register function should be sufficient for most users. |
| 252 | * The fpga_region_register_full() function is available for users that need to |
| 253 | * pass additional, optional parameters. |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 254 | * |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 255 | * Return: struct fpga_region or ERR_PTR() |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 256 | */ |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 257 | struct fpga_region * |
| 258 | fpga_region_register(struct device *parent, struct fpga_manager *mgr, |
| 259 | int (*get_bridges)(struct fpga_region *)) |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 260 | { |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 261 | struct fpga_region_info info = { 0 }; |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 262 | |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 263 | info.mgr = mgr; |
| 264 | info.get_bridges = get_bridges; |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 265 | |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 266 | return fpga_region_register_full(parent, &info); |
Alan Tull | 52a3a7c | 2017-11-15 14:20:23 -0600 | [diff] [blame] | 267 | } |
| 268 | EXPORT_SYMBOL_GPL(fpga_region_register); |
| 269 | |
Alan Tull | 917a430 | 2018-05-16 18:50:01 -0500 | [diff] [blame] | 270 | /** |
Tom Rix | 011c49e | 2021-06-08 14:23:47 -0700 | [diff] [blame] | 271 | * fpga_region_unregister - unregister an FPGA region |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 272 | * @region: FPGA region |
Alan Tull | fea82b7 | 2018-10-15 17:20:03 -0500 | [diff] [blame] | 273 | * |
Tom Rix | 011c49e | 2021-06-08 14:23:47 -0700 | [diff] [blame] | 274 | * This function is intended for use in an FPGA region driver's remove function. |
Alan Tull | 9f36897 | 2018-05-16 18:49:57 -0500 | [diff] [blame] | 275 | */ |
| 276 | void fpga_region_unregister(struct fpga_region *region) |
Alan Tull | 52a3a7c | 2017-11-15 14:20:23 -0600 | [diff] [blame] | 277 | { |
| 278 | device_unregister(®ion->dev); |
Alan Tull | 52a3a7c | 2017-11-15 14:20:23 -0600 | [diff] [blame] | 279 | } |
| 280 | EXPORT_SYMBOL_GPL(fpga_region_unregister); |
| 281 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 282 | static void fpga_region_dev_release(struct device *dev) |
| 283 | { |
Russ Weight | 8886a57 | 2021-11-18 17:55:53 -0800 | [diff] [blame] | 284 | struct fpga_region *region = to_fpga_region(dev); |
| 285 | |
| 286 | ida_simple_remove(&fpga_region_ida, region->dev.id); |
| 287 | kfree(region); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | /** |
| 291 | * fpga_region_init - init function for fpga_region class |
| 292 | * Creates the fpga_region class and registers a reconfig notifier. |
| 293 | */ |
| 294 | static int __init fpga_region_init(void) |
| 295 | { |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 296 | fpga_region_class = class_create(THIS_MODULE, "fpga_region"); |
| 297 | if (IS_ERR(fpga_region_class)) |
| 298 | return PTR_ERR(fpga_region_class); |
| 299 | |
Wu Hao | 41a8b2c | 2018-06-30 08:53:12 +0800 | [diff] [blame] | 300 | fpga_region_class->dev_groups = fpga_region_groups; |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 301 | fpga_region_class->dev_release = fpga_region_dev_release; |
| 302 | |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 303 | return 0; |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | static void __exit fpga_region_exit(void) |
| 307 | { |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 308 | class_destroy(fpga_region_class); |
| 309 | ida_destroy(&fpga_region_ida); |
| 310 | } |
| 311 | |
| 312 | subsys_initcall(fpga_region_init); |
| 313 | module_exit(fpga_region_exit); |
| 314 | |
| 315 | MODULE_DESCRIPTION("FPGA Region"); |
Alan Tull | 59460a9 | 2017-11-15 14:20:21 -0600 | [diff] [blame] | 316 | MODULE_AUTHOR("Alan Tull <atull@kernel.org>"); |
Alan Tull | 0fa20cd | 2016-11-01 14:14:29 -0500 | [diff] [blame] | 317 | MODULE_LICENSE("GPL v2"); |