diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2015-12-16 11:44:32 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-01-11 12:19:17 -0200 |
commit | c8d54cd53b43c514fbd8d36abf0f2f00f719dd54 (patch) | |
tree | 7e2f2f38d49fcedadf4b37ad6a173cf3c5bc4b26 /drivers/media/media-entity.c | |
parent | 665faa971d087e8b968ef75d04079a7a462ddfca (diff) | |
download | talos-op-linux-c8d54cd53b43c514fbd8d36abf0f2f00f719dd54.tar.gz talos-op-linux-c8d54cd53b43c514fbd8d36abf0f2f00f719dd54.zip |
[media] media: Add an API to manage entity enumerations
This is useful in e.g. knowing whether certain operations have already
been performed for an entity. The users include the framework itself (for
graph walking) and a number of drivers.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-entity.c')
-rw-r--r-- | drivers/media/media-entity.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 13c8ca11f169..5e3f32f63187 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -71,6 +71,46 @@ static inline const char *intf_type(struct media_interface *intf) }; /** + * __media_entity_enum_init - Initialise an entity enumeration + * + * @ent_enum: Entity enumeration to be initialised + * @idx_max: Maximum number of entities in the enumeration + * + * Returns zero on success or a negative error code. + */ +__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, + int idx_max) +{ + if (idx_max > MEDIA_ENTITY_ENUM_MAX_ID) { + ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG), + sizeof(long), GFP_KERNEL); + if (!ent_enum->bmap) + return -ENOMEM; + } else { + ent_enum->bmap = ent_enum->prealloc_bmap; + } + + bitmap_zero(ent_enum->bmap, idx_max); + ent_enum->idx_max = idx_max; + + return 0; +} +EXPORT_SYMBOL_GPL(__media_entity_enum_init); + +/** + * media_entity_enum_cleanup - Release resources of an entity enumeration + * + * @e: Entity enumeration to be released + */ +void media_entity_enum_cleanup(struct media_entity_enum *ent_enum) +{ + if (ent_enum->bmap != ent_enum->prealloc_bmap) + kfree(ent_enum->bmap); + ent_enum->bmap = NULL; +} +EXPORT_SYMBOL_GPL(media_entity_enum_cleanup); + +/** * dev_dbg_obj - Prints in debug mode a change on some object * * @event_name: Name of the event to report. Could be __func__ |