From patchwork Sun Dec 17 15:40:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10117753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A98F60327 for ; Sun, 17 Dec 2017 15:41:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21802292A1 for ; Sun, 17 Dec 2017 15:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1673C293AD; Sun, 17 Dec 2017 15:41:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BED61292A1 for ; Sun, 17 Dec 2017 15:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757277AbdLQPlJ (ORCPT ); Sun, 17 Dec 2017 10:41:09 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:40511 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757142AbdLQPlC (ORCPT ); Sun, 17 Dec 2017 10:41:02 -0500 Received: by mail-wr0-f196.google.com with SMTP id q9so11927047wre.7 for ; Sun, 17 Dec 2017 07:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=ndLtRTzjfdQkv4dgQj3UwU0ejaNQy/CI/2Pw1epmdsg=; b=B7WEEIb9Xosi8tTlJlQNlYFmt1eqgeRJLe/ILjEYHPmH7GpJyEFAD1K9vV57iNzmDQ 2O+l0gSak8cLbhP/v7Q1d8CayF37vwrKsVRbbZtZM0Pv2g+7yPFJCk6sbZpUbGaGDYVK H3NR0Xc/UpRQLBL58VXcF7p/vaQQ1Vgmqd6ggKEhqZcYPXvDY4r4cWJxcOaGBw8vCwg/ we/QbuoJ16hwBKfjNfILG8MYNTI5SG1QELurA+tvSa5I1P0Z8d9gmOcq7UE7+kzGBKSx RfbXzGc0VtNwb0dUY34cJdbJX9Wl4wtfs8tpJL+Z+JfTupWm3BCDJ2n3giMZmQyq4tzF S4wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ndLtRTzjfdQkv4dgQj3UwU0ejaNQy/CI/2Pw1epmdsg=; b=O5QZ4Y8xH9Rnfu8oQSfmDK2z81NbE7ZuyWgsnF3JjD5CoSnhZyX/OtdJyMCvGGLnff 2ue22RgCkGcHam5hDzcOu8mHGNXVbCcj2LKYRAc+N1Qf+a1tDwkvmpKru9NLbJFHWTDE g5oQm0dlzo2zZWfLNxT5+PyCMFV7LAo2/GnHnpeRCzGzUH13CWgEt5C9WIZUfEYGuK36 mWnYs0zBB1tnaS+wICiPtL4cyUxRink0t3L0hHXwoZF5nsUHV2r7Ye0QZDWwTnahTox0 nTpVAP6KViKqFvbh5UDwb7H8bPildUzZbUxu9vix8ioaXRNxwGWdAl6jn2Z9v+7NXLhw d7Vg== X-Gm-Message-State: AKGB3mLa/BtUFkKAtHEFSmZDFGIkzSYQmGkNxTA+T948y5bHZ456h17z 4cZFPjG955bkq8vUkhk4/CgKDQ== X-Google-Smtp-Source: ACJfBou2Pw9ysL4HJ48cBrB0K3GVWVBz41kGlZn+xpcfq0K4s5/QYK8My5jrz+GNvtQ6PaF7tySDSQ== X-Received: by 10.223.132.129 with SMTP id 1mr6816877wrg.136.1513525261087; Sun, 17 Dec 2017 07:41:01 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id m52sm2420974wrm.12.2017.12.17.07.41.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Dec 2017 07:41:00 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH 8/8] [media] ddbridge: improve ddb_ports_attach() failure handling Date: Sun, 17 Dec 2017 16:40:49 +0100 Message-Id: <20171217154049.1125-9-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171217154049.1125-1-d.scheller.oss@gmail.com> References: <20171217154049.1125-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller As all error handling improved quite a bit, don't stop attaching frontends if one of them failed, since - if other tuner modules are connected to the PCIe bridge - other hardware may just work, so don't break on a single port failure, but rather initialise as much as possible. Ie. if there are issues with a C2T2-equipped PCIe bridge card which has additional DuoFlex modules connected and the bridge generally works, the DuoFlex tuners can still work fine. If all ports failed to initialise where connected hardware was detected on at first, return -ENODEV though to cause this PCI device to fail and free all allocated resources. In any case, leave a kernel log warning (or error, even) if things went wrong. Signed-off-by: Daniel Scheller --- drivers/media/pci/ddbridge/ddbridge-core.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 940371067346..c7d923e0e21a 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1964,7 +1964,7 @@ static int ddb_port_attach(struct ddb_port *port) int ddb_ports_attach(struct ddb *dev) { - int i, ret = 0; + int i, numports, err_ports = 0, ret = 0; struct ddb_port *port; if (dev->port_num) { @@ -1974,11 +1974,31 @@ int ddb_ports_attach(struct ddb *dev) return ret; } } + + numports = dev->port_num; + for (i = 0; i < dev->port_num; i++) { port = &dev->port[i]; - ret = ddb_port_attach(port); + if (port->class != DDB_PORT_NONE) { + ret = ddb_port_attach(port); + if (ret) + err_ports++; + } else { + numports--; + } } - return ret; + + if (err_ports) { + if (err_ports == numports) { + dev_err(dev->dev, "All connected ports failed to initialise!\n"); + return -ENODEV; + } + + dev_warn(dev->dev, "%d of %d connected ports failed to initialise!\n", + err_ports, numports); + } + + return 0; } void ddb_ports_detach(struct ddb *dev)