Re: [PATCH V3 4/7] mdev: introduce device specific ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 17 Oct 2019 16:30:43 +0800
Jason Wang <jasowang@xxxxxxxxxx> wrote:

> On 2019/10/17 上午12:53, Alex Williamson wrote:

> >>> Yet another suggestion: have the class id derive from the function
> >>> you use to set up the ops.
> >>>
> >>> void mdev_set_vfio_ops(struct mdev_device *mdev, const struct
> >>> vfio_mdev_ops *vfio_ops) {
> >>> 	mdev->device_ops = vfio_ops;
> >>> 	mdev->class_id = MDEV_ID_VFIO;
> >>> }
> >>>
> >>> void mdev_set_virtio_ops(struct mdev_device *mdev, const struct
> >>> virtio_mdev_ops *virtio_ops) {
> >>> 	mdev->device_ops = virtio_ops;
> >>> 	mdev->class_id = MDEV_ID_VIRTIO;
> >>> }
> >>>
> >>> void mdev_set_vhost_ops(struct mdev_device *mdev, const struct
> >>> virtio_mdev_ops *virtio_ops) {
> >>> 	mdev->device_ops = virtio_ops;
> >>> 	mdev->class_id = MDEV_ID_VHOST;
> >>> }
> >>>
> >>> void mdev_set_vendor_ops(struct mdev_device *mdev) /* no ops */ {
> >>> 	mdev->class_id = MDEV_ID_VENDOR;
> >>> }  
> > One further step towards making this hard to use incorrectly might be
> > to return an error if class_id is already set.  Thanks,
> >
> > Alex  
> 
> 
> I will add a BUG_ON() when class_id has already set.

Probably better a WARN_ON()?
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux