Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2015 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs <bskeggs@redhat.com>
0023  */
0024 #include "priv.h"
0025 
0026 static void
0027 nvkm_bus_intr(struct nvkm_subdev *subdev)
0028 {
0029     struct nvkm_bus *bus = nvkm_bus(subdev);
0030     bus->func->intr(bus);
0031 }
0032 
0033 static int
0034 nvkm_bus_init(struct nvkm_subdev *subdev)
0035 {
0036     struct nvkm_bus *bus = nvkm_bus(subdev);
0037     bus->func->init(bus);
0038     return 0;
0039 }
0040 
0041 static void *
0042 nvkm_bus_dtor(struct nvkm_subdev *subdev)
0043 {
0044     return nvkm_bus(subdev);
0045 }
0046 
0047 static const struct nvkm_subdev_func
0048 nvkm_bus = {
0049     .dtor = nvkm_bus_dtor,
0050     .init = nvkm_bus_init,
0051     .intr = nvkm_bus_intr,
0052 };
0053 
0054 int
0055 nvkm_bus_new_(const struct nvkm_bus_func *func, struct nvkm_device *device,
0056           enum nvkm_subdev_type type, int inst, struct nvkm_bus **pbus)
0057 {
0058     struct nvkm_bus *bus;
0059     if (!(bus = *pbus = kzalloc(sizeof(*bus), GFP_KERNEL)))
0060         return -ENOMEM;
0061     nvkm_subdev_ctor(&nvkm_bus, device, type, inst, &bus->subdev);
0062     bus->func = func;
0063     return 0;
0064 }