/* SPDX-License-Identifier: GPL-2.0+ */1/*2* media-dev-allocator.h - Media Controller Device Allocator API3*4* Copyright (c) 2019 Shuah Khan <[email protected]>5*6* Credits: Suggested by Laurent Pinchart <[email protected]>7*/89/*10* This file adds a global ref-counted Media Controller Device Instance API.11* A system wide global media device list is managed and each media device12* includes a kref count. The last put on the media device releases the media13* device instance.14*/1516#ifndef _MEDIA_DEV_ALLOCATOR_H17#define _MEDIA_DEV_ALLOCATOR_H1819struct usb_device;2021#if defined(CONFIG_MEDIA_CONTROLLER) && IS_ENABLED(CONFIG_USB)22/**23* media_device_usb_allocate() - Allocate and return struct &media device24*25* @udev: struct &usb_device pointer26* @module_name: should be filled with %KBUILD_MODNAME27* @owner: struct module pointer %THIS_MODULE for the driver.28* %THIS_MODULE is null for a built-in driver.29* It is safe even when %THIS_MODULE is null.30*31* This interface should be called to allocate a Media Device when multiple32* drivers share usb_device and the media device. This interface allocates33* &media_device structure and calls media_device_usb_init() to initialize34* it.35*36*/37struct media_device *media_device_usb_allocate(struct usb_device *udev,38const char *module_name,39struct module *owner);40/**41* media_device_delete() - Release media device. Calls kref_put().42*43* @mdev: struct &media_device pointer44* @module_name: should be filled with %KBUILD_MODNAME45* @owner: struct module pointer %THIS_MODULE for the driver.46* %THIS_MODULE is null for a built-in driver.47* It is safe even when %THIS_MODULE is null.48*49* This interface should be called to put Media Device Instance kref.50*/51void media_device_delete(struct media_device *mdev, const char *module_name,52struct module *owner);53#else54static inline struct media_device *media_device_usb_allocate(55struct usb_device *udev, const char *module_name,56struct module *owner)57{ return NULL; }58static inline void media_device_delete(59struct media_device *mdev, const char *module_name,60struct module *owner) { }61#endif /* CONFIG_MEDIA_CONTROLLER && CONFIG_USB */62#endif /* _MEDIA_DEV_ALLOCATOR_H */636465