mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-04 18:11:39 -04:00
media: v4l2-core: simplify v4l2_m2m_register_entity()
Avoid 'strlen()'/'kmalloc()'/'snprintf()' sequence by using the convenient 'kasprintf()' in 'v4l2_m2m_register_entity()'. Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
ceff18405f
commit
42bf68dfef
@@ -1037,8 +1037,6 @@ static int v4l2_m2m_register_entity(struct media_device *mdev,
|
||||
{
|
||||
struct media_entity *entity;
|
||||
struct media_pad *pads;
|
||||
char *name;
|
||||
unsigned int len;
|
||||
int num_pads;
|
||||
int ret;
|
||||
|
||||
@@ -1071,12 +1069,10 @@ static int v4l2_m2m_register_entity(struct media_device *mdev,
|
||||
entity->info.dev.major = VIDEO_MAJOR;
|
||||
entity->info.dev.minor = vdev->minor;
|
||||
}
|
||||
len = strlen(vdev->name) + 2 + strlen(m2m_entity_name[type]);
|
||||
name = kmalloc(len, GFP_KERNEL);
|
||||
if (!name)
|
||||
entity->name = kasprintf(GFP_KERNEL, "%s-%s", vdev->name,
|
||||
m2m_entity_name[type]);
|
||||
if (!entity->name)
|
||||
return -ENOMEM;
|
||||
snprintf(name, len, "%s-%s", vdev->name, m2m_entity_name[type]);
|
||||
entity->name = name;
|
||||
entity->function = function;
|
||||
|
||||
ret = media_entity_pads_init(entity, num_pads, pads);
|
||||
|
||||
Reference in New Issue
Block a user