Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2014 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 
0025 #include <nvif/device.h>
0026 
0027 u64
0028 nvif_device_time(struct nvif_device *device)
0029 {
0030     if (!device->user.func) {
0031         struct nv_device_time_v0 args = {};
0032         int ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_TIME,
0033                        &args, sizeof(args));
0034         WARN_ON_ONCE(ret != 0);
0035         return args.time;
0036     }
0037 
0038     return device->user.func->time(&device->user);
0039 }
0040 
0041 void
0042 nvif_device_dtor(struct nvif_device *device)
0043 {
0044     nvif_user_dtor(device);
0045     kfree(device->runlist);
0046     device->runlist = NULL;
0047     nvif_object_dtor(&device->object);
0048 }
0049 
0050 int
0051 nvif_device_ctor(struct nvif_object *parent, const char *name, u32 handle,
0052          s32 oclass, void *data, u32 size, struct nvif_device *device)
0053 {
0054     int ret = nvif_object_ctor(parent, name ? name : "nvifDevice", handle,
0055                    oclass, data, size, &device->object);
0056     device->runlist = NULL;
0057     device->user.func = NULL;
0058     if (ret == 0) {
0059         device->info.version = 0;
0060         ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_INFO,
0061                        &device->info, sizeof(device->info));
0062     }
0063     return ret;
0064 }