From patchwork Sun Sep 6 17:31:00 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: 7132181 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DC5FABEEC1 for ; Sun, 6 Sep 2015 17:31:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06172206CB for ; Sun, 6 Sep 2015 17:31:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10CED206C0 for ; Sun, 6 Sep 2015 17:31:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752926AbbIFRbw (ORCPT ); Sun, 6 Sep 2015 13:31:52 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:53835 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752830AbbIFRbf (ORCPT ); Sun, 6 Sep 2015 13:31:35 -0400 Received: from 201.86.133.245.dynamic.adsl.gvt.net.br ([201.86.133.245] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZYdmx-0008Hn-2a; Sun, 06 Sep 2015 17:31:35 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.85) (envelope-from ) id 1ZYdmS-0004m0-Vd; Sun, 06 Sep 2015 14:31:04 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Hans Verkuil Subject: [PATCH 17/18] [media] dvbdev: move indirect links on dvr/demux to a separate function Date: Sun, 6 Sep 2015 14:31:00 -0300 Message-Id: <85b36c34704eeba890472e7973d2e01a69c4b87c.1441559233.git.mchehab@osg.samsung.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Cleanup the code a little bit by moving the routine that creates links between DVR and demux to the I/O entitis into a separate function. While here, fix the code to use strncmp() instead of strcmp(). Signed-off-by: Mauro Carvalho Chehab Acked-by: Hans Verkuil diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 8527fc40e6a0..ea76fe54e0e4 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -522,6 +522,28 @@ EXPORT_SYMBOL(dvb_unregister_device); #ifdef CONFIG_MEDIA_CONTROLLER_DVB + +static int dvb_create_io_intf_links(struct dvb_adapter *adap, + struct media_interface *intf, + char *name) +{ + struct media_device *mdev = adap->mdev; + struct media_entity *entity; + struct media_link *link; + + media_device_for_each_entity(entity, mdev) { + if (entity->function == MEDIA_ENT_F_IO) { + if (strncmp(entity->name, name, strlen(name))) + continue; + link = media_create_intf_link(entity, intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } + } + return 0; +} + int dvb_create_media_graph(struct dvb_adapter *adap) { struct media_device *mdev = adap->mdev; @@ -619,25 +641,15 @@ int dvb_create_media_graph(struct dvb_adapter *adap) if (!link) return -ENOMEM; } - - media_device_for_each_entity(entity, mdev) { - if (entity->function == MEDIA_ENT_F_IO) { - if (!strcmp(entity->name, DVR_TSOUT)) { - link = media_create_intf_link(entity, - intf, - MEDIA_LNK_FL_ENABLED); - if (!link) - return -ENOMEM; - } - if (!strcmp(entity->name, DEMUX_TSOUT)) { - link = media_create_intf_link(entity, - intf, - MEDIA_LNK_FL_ENABLED); - if (!link) - return -ENOMEM; - } - break; - } + if (intf->type == MEDIA_INTF_T_DVB_DVR) { + ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT); + if (ret) + return ret; + } + if (intf->type == MEDIA_INTF_T_DVB_DEMUX) { + ret = dvb_create_io_intf_links(adap, intf, DEMUX_TSOUT); + if (ret) + return ret; } } return 0;