2 * Copyright 2012 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
27 nvkm_bar_flush(struct nvkm_bar *bar)
29 if (bar && bar->func->flush)
30 bar->func->flush(bar);
34 nvkm_bar_kmap(struct nvkm_bar *bar)
36 /* disallow kmap() until after vm has been bootstrapped */
37 if (bar && bar->func->kmap && bar->subdev.oneinit)
38 return bar->func->kmap(bar);
43 nvkm_bar_umap(struct nvkm_bar *bar, u64 size, int type, struct nvkm_vma *vma)
45 return bar->func->umap(bar, size, type, vma);
49 nvkm_bar_oneinit(struct nvkm_subdev *subdev)
51 struct nvkm_bar *bar = nvkm_bar(subdev);
52 return bar->func->oneinit(bar);
56 nvkm_bar_init(struct nvkm_subdev *subdev)
58 struct nvkm_bar *bar = nvkm_bar(subdev);
59 return bar->func->init(bar);
63 nvkm_bar_dtor(struct nvkm_subdev *subdev)
65 struct nvkm_bar *bar = nvkm_bar(subdev);
66 return bar->func->dtor(bar);
69 static const struct nvkm_subdev_func
71 .dtor = nvkm_bar_dtor,
72 .oneinit = nvkm_bar_oneinit,
73 .init = nvkm_bar_init,
77 nvkm_bar_ctor(const struct nvkm_bar_func *func, struct nvkm_device *device,
78 int index, struct nvkm_bar *bar)
80 nvkm_subdev_ctor(&nvkm_bar, device, index, &bar->subdev);
82 spin_lock_init(&bar->lock);