summaryrefslogtreecommitdiffstats
path: root/drivers/media/media-device.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-12-11 16:07:57 -0200
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-01-11 12:19:07 -0200
commitb3b7a9f138b7539c25e036d398616f6737b08ff7 (patch)
tree710cdd2e8b21ef4471baf424c0ef6261d30f26df /drivers/media/media-device.c
parentd1b9da2d606ecec587177c4c90f1905c57538149 (diff)
downloadlinux-b3b7a9f138b7539c25e036d398616f6737b08ff7.tar.bz2
[media] media-device: Use u64 ints for pointers
By using u64 integers and pointers, we can get rid of compat32 logic. So, let's do it! Suggested-by: Arnd Bergmann <arnd@arndb.de> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r--drivers/media/media-device.c77
1 files changed, 41 insertions, 36 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index f09f3a6f9c50..6406914a9bf5 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -240,10 +240,10 @@ static long __media_device_get_topology(struct media_device *mdev,
struct media_interface *intf;
struct media_pad *pad;
struct media_link *link;
- struct media_v2_entity uentity;
- struct media_v2_interface uintf;
- struct media_v2_pad upad;
- struct media_v2_link ulink;
+ struct media_v2_entity kentity, *uentity;
+ struct media_v2_interface kintf, *uintf;
+ struct media_v2_pad kpad, *upad;
+ struct media_v2_link klink, *ulink;
unsigned int i;
int ret = 0;
@@ -251,10 +251,10 @@ static long __media_device_get_topology(struct media_device *mdev,
/* Get entities and number of entities */
i = 0;
+ uentity = media_get_uptr(topo->ptr_entities);
media_device_for_each_entity(entity, mdev) {
i++;
-
- if (ret || !topo->entities)
+ if (ret || !uentity)
continue;
if (i > topo->num_entities) {
@@ -263,23 +263,24 @@ static long __media_device_get_topology(struct media_device *mdev,
}
/* Copy fields to userspace struct if not error */
- memset(&uentity, 0, sizeof(uentity));
- uentity.id = entity->graph_obj.id;
- uentity.function = entity->function;
- strncpy(uentity.name, entity->name,
- sizeof(uentity.name));
+ memset(&kentity, 0, sizeof(kentity));
+ kentity.id = entity->graph_obj.id;
+ kentity.function = entity->function;
+ strncpy(kentity.name, entity->name,
+ sizeof(kentity.name));
- if (copy_to_user(&topo->entities[i - 1], &uentity, sizeof(uentity)))
+ if (copy_to_user(uentity, &kentity, sizeof(kentity)))
ret = -EFAULT;
+ uentity++;
}
topo->num_entities = i;
/* Get interfaces and number of interfaces */
i = 0;
+ uintf = media_get_uptr(topo->ptr_interfaces);
media_device_for_each_intf(intf, mdev) {
i++;
-
- if (ret || !topo->interfaces)
+ if (ret || !uintf)
continue;
if (i > topo->num_interfaces) {
@@ -287,33 +288,34 @@ static long __media_device_get_topology(struct media_device *mdev,
continue;
}
- memset(&uintf, 0, sizeof(uintf));
+ memset(&kintf, 0, sizeof(kintf));
/* Copy intf fields to userspace struct */
- uintf.id = intf->graph_obj.id;
- uintf.intf_type = intf->type;
- uintf.flags = intf->flags;
+ kintf.id = intf->graph_obj.id;
+ kintf.intf_type = intf->type;
+ kintf.flags = intf->flags;
if (media_type(&intf->graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) {
struct media_intf_devnode *devnode;
devnode = intf_to_devnode(intf);
- uintf.devnode.major = devnode->major;
- uintf.devnode.minor = devnode->minor;
+ kintf.devnode.major = devnode->major;
+ kintf.devnode.minor = devnode->minor;
}
- if (copy_to_user(&topo->interfaces[i - 1], &uintf, sizeof(uintf)))
+ if (copy_to_user(uintf, &kintf, sizeof(kintf)))
ret = -EFAULT;
+ uintf++;
}
topo->num_interfaces = i;
/* Get pads and number of pads */
i = 0;
+ upad = media_get_uptr(topo->ptr_pads);
media_device_for_each_pad(pad, mdev) {
i++;
-
- if (ret || !topo->pads)
+ if (ret || !upad)
continue;
if (i > topo->num_pads) {
@@ -321,27 +323,29 @@ static long __media_device_get_topology(struct media_device *mdev,
continue;
}
- memset(&upad, 0, sizeof(upad));
+ memset(&kpad, 0, sizeof(kpad));
/* Copy pad fields to userspace struct */
- upad.id = pad->graph_obj.id;
- upad.entity_id = pad->entity->graph_obj.id;
- upad.flags = pad->flags;
+ kpad.id = pad->graph_obj.id;
+ kpad.entity_id = pad->entity->graph_obj.id;
+ kpad.flags = pad->flags;
- if (copy_to_user(&topo->pads[i - 1], &upad, sizeof(upad)))
+ if (copy_to_user(upad, &kpad, sizeof(kpad)))
ret = -EFAULT;
+ upad++;
}
topo->num_pads = i;
/* Get links and number of links */
i = 0;
+ ulink = media_get_uptr(topo->ptr_links);
media_device_for_each_link(link, mdev) {
if (link->is_backlink)
continue;
i++;
- if (ret || !topo->links)
+ if (ret || !ulink)
continue;
if (i > topo->num_links) {
@@ -349,19 +353,20 @@ static long __media_device_get_topology(struct media_device *mdev,
continue;
}
- memset(&ulink, 0, sizeof(ulink));
+ memset(&klink, 0, sizeof(klink));
/* Copy link fields to userspace struct */
- ulink.id = link->graph_obj.id;
- ulink.source_id = link->gobj0->id;
- ulink.sink_id = link->gobj1->id;
- ulink.flags = link->flags;
+ klink.id = link->graph_obj.id;
+ klink.source_id = link->gobj0->id;
+ klink.sink_id = link->gobj1->id;
+ klink.flags = link->flags;
if (media_type(link->gobj0) != MEDIA_GRAPH_PAD)
- ulink.flags |= MEDIA_LNK_FL_INTERFACE_LINK;
+ klink.flags |= MEDIA_LNK_FL_INTERFACE_LINK;
- if (copy_to_user(&topo->links[i - 1], &ulink, sizeof(ulink)))
+ if (copy_to_user(ulink, &klink, sizeof(klink)))
ret = -EFAULT;
+ ulink++;
}
topo->num_links = i;