cregit-Linux how code gets into the kernel

Release 4.11 drivers/vfio/mdev/vfio_mdev.c

/*
 * VFIO based driver for Mediated device
 *
 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 *     Author: Neo Jia <cjia@nvidia.com>
 *             Kirti Wankhede <kwankhede@nvidia.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/vfio.h>
#include <linux/mdev.h>

#include "mdev_private.h"


#define DRIVER_VERSION  "0.1"

#define DRIVER_AUTHOR   "NVIDIA Corporation"

#define DRIVER_DESC     "VFIO based driver for Mediated device"


static int vfio_mdev_open(void *device_data) { struct mdev_device *mdev = device_data; struct mdev_parent *parent = mdev->parent; int ret; if (unlikely(!parent->ops->open)) return -EINVAL; if (!try_module_get(THIS_MODULE)) return -ENODEV; ret = parent->ops->open(mdev); if (ret) module_put(THIS_MODULE); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede7998.75%150.00%
Alex Williamson11.25%150.00%
Total80100.00%2100.00%


static void vfio_mdev_release(void *device_data) { struct mdev_device *mdev = device_data; struct mdev_parent *parent = mdev->parent; if (likely(parent->ops->release)) parent->ops->release(mdev); module_put(THIS_MODULE); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede5098.04%150.00%
Alex Williamson11.96%150.00%
Total51100.00%2100.00%


static long vfio_mdev_unlocked_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { struct mdev_device *mdev = device_data; struct mdev_parent *parent = mdev->parent; if (unlikely(!parent->ops->ioctl)) return -EINVAL; return parent->ops->ioctl(mdev, cmd, arg); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede6398.44%150.00%
Alex Williamson11.56%150.00%
Total64100.00%2100.00%


static ssize_t vfio_mdev_read(void *device_data, char __user *buf, size_t count, loff_t *ppos) { struct mdev_device *mdev = device_data; struct mdev_parent *parent = mdev->parent; if (unlikely(!parent->ops->read)) return -EINVAL; return parent->ops->read(mdev, buf, count, ppos); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede6998.57%150.00%
Alex Williamson11.43%150.00%
Total70100.00%2100.00%


static ssize_t vfio_mdev_write(void *device_data, const char __user *buf, size_t count, loff_t *ppos) { struct mdev_device *mdev = device_data; struct mdev_parent *parent = mdev->parent; if (unlikely(!parent->ops->write)) return -EINVAL; return parent->ops->write(mdev, buf, count, ppos); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede7098.59%150.00%
Alex Williamson11.41%150.00%
Total71100.00%2100.00%


static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma) { struct mdev_device *mdev = device_data; struct mdev_parent *parent = mdev->parent; if (unlikely(!parent->ops->mmap)) return -EINVAL; return parent->ops->mmap(mdev, vma); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede5898.31%150.00%
Alex Williamson11.69%150.00%
Total59100.00%2100.00%

static const struct vfio_device_ops vfio_mdev_dev_ops = { .name = "vfio-mdev", .open = vfio_mdev_open, .release = vfio_mdev_release, .ioctl = vfio_mdev_unlocked_ioctl, .read = vfio_mdev_read, .write = vfio_mdev_write, .mmap = vfio_mdev_mmap, };
int vfio_mdev_probe(struct device *dev) { struct mdev_device *mdev = to_mdev_device(dev); return vfio_add_group_dev(dev, &vfio_mdev_dev_ops, mdev); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede31100.00%1100.00%
Total31100.00%1100.00%


void vfio_mdev_remove(struct device *dev) { vfio_del_group_dev(dev); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede15100.00%1100.00%
Total15100.00%1100.00%

struct mdev_driver vfio_mdev_driver = { .name = "vfio_mdev", .probe = vfio_mdev_probe, .remove = vfio_mdev_remove, };
static int __init vfio_mdev_init(void) { return mdev_register_driver(&vfio_mdev_driver, THIS_MODULE); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede18100.00%1100.00%
Total18100.00%1100.00%


static void __exit vfio_mdev_exit(void) { mdev_unregister_driver(&vfio_mdev_driver); }

Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede15100.00%1100.00%
Total15100.00%1100.00%

module_init(vfio_mdev_init) module_exit(vfio_mdev_exit) MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC);

Overall Contributors

PersonTokensPropCommitsCommitProp
Kirti Wankhede59799.00%150.00%
Alex Williamson61.00%150.00%
Total603100.00%2100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.