Quellcode-Bibliothek mc-dev-allocator.c
Sprache: C
// SPDX-License-Identifier: GPL-2.0 /* * media-dev-allocator.c - Media Controller Device Allocator API * * Copyright (c) 2019 Shuah Khan <shuah@kernel.org> * * Credits: Suggested by Laurent Pinchart <laurent.pinchart@ideasonboard.com>
*/
/* * This file adds a global refcounted Media Controller Device Instance API. * A system wide global media device list is managed and each media device * includes a kref count. The last put on the media device releases the media * device instance. *
*/
/* Callers should hold media_device_lock when calling this function */ staticstruct media_device *__media_device_get(struct device *dev, constchar *module_name, struct module *owner)
{ struct media_device_instance *mdi;
list_for_each_entry(mdi, &media_device_list, list) { if (mdi->mdev.dev != dev) continue;
kref_get(&mdi->refcount);
/* get module reference for the media_device owner */ if (owner != mdi->owner && !try_module_get(mdi->owner))
dev_err(dev, "%s: module %s get owner reference error\n",
__func__, module_name); else
dev_dbg(dev, "%s: module %s got owner reference\n",
__func__, module_name); return &mdi->mdev;
}
mdi = kzalloc(sizeof(*mdi), GFP_KERNEL); if (!mdi) return NULL;
/* check if media device is already initialized */ if (!mdev->dev)
__media_device_usb_init(mdev, udev, udev->product,
module_name);
mutex_unlock(&media_device_lock); return mdev;
}
EXPORT_SYMBOL_GPL(media_device_usb_allocate);
mutex_lock(&media_device_lock); /* put module reference for the media_device owner */ if (mdi->owner != owner) {
module_put(mdi->owner);
dev_dbg(mdi->mdev.dev, "%s: module %s put owner module reference\n",
__func__, module_name);
}
mutex_unlock(&media_device_lock);
kref_put(&mdi->refcount, media_device_instance_release);
}
EXPORT_SYMBOL_GPL(media_device_delete);
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.