From patchwork Fri Dec 11 13:34:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 7829861 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5B97A9F387 for ; Fri, 11 Dec 2015 13:34:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D86720499 for ; Fri, 11 Dec 2015 13:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D97D820588 for ; Fri, 11 Dec 2015 13:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbbLKNeb (ORCPT ); Fri, 11 Dec 2015 08:34:31 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:51753 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752139AbbLKNe3 (ORCPT ); Fri, 11 Dec 2015 08:34:29 -0500 Received: from 179.186.108.20.dynamic.adsl.gvt.net.br ([179.186.108.20] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1a7Nq8-000356-HC; Fri, 11 Dec 2015 13:34:28 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.86) (envelope-from ) id 1a7Npw-0003H8-4Q; Fri, 11 Dec 2015 11:34:16 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH 02/10] media-device: better name Kernelspace/Userspace links Date: Fri, 11 Dec 2015 11:34:07 -0200 Message-Id: <7c094f54c1423902d848a9dbcb6a462d347fe086.1449840443.git.mchehab@osg.samsung.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The __media_device_enum_links() copies links definitions from Kernelspace to userspace. It has to work with 3 structs that handle with links. Better name them to: link: Kernelspace internal link representation, of the type media_link; klink_desc: struct media_link_desc pointer to the kernel memory where the data will be filled; ulink_desc: struct media_link_desc pointer to the memory where the data will be copied to userspace. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 61883abaf095..14bd568e2f41 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -151,24 +151,25 @@ static long __media_device_enum_links(struct media_device *mdev, } if (links->links) { - struct media_link *ent_link; - struct media_link_desc __user *ulink = links->links; + struct media_link *link; + struct media_link_desc __user *ulink_desc = links->links; - list_for_each_entry(ent_link, &entity->links, list) { - struct media_link_desc link; + list_for_each_entry(link, &entity->links, list) { + struct media_link_desc klink_desc; /* Ignore backlinks. */ - if (ent_link->source->entity != entity) + if (link->source->entity != entity) continue; - memset(&link, 0, sizeof(link)); - media_device_kpad_to_upad(ent_link->source, - &link.source); - media_device_kpad_to_upad(ent_link->sink, - &link.sink); - link.flags = ent_link->flags; - if (copy_to_user(ulink, &link, sizeof(*ulink))) + memset(&klink_desc, 0, sizeof(klink_desc)); + media_device_kpad_to_upad(link->source, + &klink_desc.source); + media_device_kpad_to_upad(link->sink, + &klink_desc.sink); + klink_desc.flags = link->flags; + if (copy_to_user(ulink_desc, &klink_desc, + sizeof(*ulink_desc))) return -EFAULT; - ulink++; + ulink_desc++; } }