From patchwork Sat Dec 17 00:47:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9478747 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 F13EA6082B for ; Sat, 17 Dec 2016 00:50:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A1B2879E for ; Sat, 17 Dec 2016 00:50:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D660B28772; Sat, 17 Dec 2016 00:50:39 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 795AF28768 for ; Sat, 17 Dec 2016 00:50:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cI3Am-0006sL-VM; Sat, 17 Dec 2016 00:48:24 +0000 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cI3Af-0006qz-CC for linux-arm-kernel@lists.infradead.org; Sat, 17 Dec 2016 00:48:18 +0000 Received: by mail-pg0-x22b.google.com with SMTP id f188so37454739pgc.3 for ; Fri, 16 Dec 2016 16:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hex654IPPmQi/TOQ+uLCAqLzr+fZC1SbrYQ+LItVeV0=; b=FtmaZeqOMHIc+PA32n/XOqPJ+DytXFvBvOoHlFIC/GQpKEgcujDwxvxPUCscCmbwaV haCMX5LDnrM41VCYDiRHlyLwiBaD9ZaPdyA9RGpfUHw5bVpQsHuc2SEHEcV+LFD94a0D Zus5sxgyAojbfvJ95+l/jQ+GWpPvHGvso1OYkx0MWhmu+ofENfhK3QMYiRJwJ0YWfKwl 7Sg9B8TNZfjxuXWzwW9UjIgkGM7nwOm4D1sxgkdPl6PvUqm3QM8BbOSgdaqlnyALLWfX qbk1CveBn+jTztfKB8JTAUwYQQTa8JmE9yrJ0YtVxspJCeENd/HyNS+TGcVzujaKuh/1 x8mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hex654IPPmQi/TOQ+uLCAqLzr+fZC1SbrYQ+LItVeV0=; b=WE/1y6TQa+Lm6h1472jUhrRoHNV9mx9qiwXaUZQpyf1tlIy0xQqvYjXDfjKMdNw0rN KVVXoWUcb+Cv+Gav9dKXbui34iEChN8L1QE/9qzadaZNVX9O2h3hzJjBCNA56Iwhr7bf Eh6t5MZe1nwj7/XQqNwppcIB5l3gD52ReexSdrCYblHEqrjswKcpDzDMplqrvBykDOzI UksEucpq50PA3AZ93gXIPx8cGDq8QjP444n9Df+1dJ9vkZRwmUzRiv+EvHQ/3HxHqsKH CTyznE9uhJ054FfqmCIsdqNgBLNo5k+9DF8EWWp/DUZdvGHxagdN0mDpuDt/hVphzosf cCPA== X-Gm-Message-State: AKaTC01614aQR+/G2adCNG+VXLGMl6FmbY8Dsh4FO4MQv3W769ejtiZjGgwDksmT2Zz9vFFo X-Received: by 10.84.173.195 with SMTP id p61mr12531466plb.158.1481935676401; Fri, 16 Dec 2016 16:47:56 -0800 (PST) Received: from localhost (c-98-203-232-209.hsd1.wa.comcast.net. [98.203.232.209]) by smtp.gmail.com with ESMTPSA id y200sm14357994pfb.16.2016.12.16.16.47.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 16:47:55 -0800 (PST) From: Kevin Hilman To: Hans Verkuil , Laurent Pinchart , Sakari Ailus Subject: [PATCH v6.1 1/5] [media] davinci: VPIF: fix module loading, init errors Date: Fri, 16 Dec 2016 16:47:54 -0800 Message-Id: <20161217004754.10241-1-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161207183025.20684-2-khilman@baylibre.com> References: <20161207183025.20684-2-khilman@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161216_164817_555242_04699E4F X-CRM114-Status: GOOD ( 14.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sekhar Nori , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Fix problems with automatic module loading by adding MODULE_ALIAS. Also fix various load-time errors cause by incorrect or not present platform_data. Acked-by: Sakari Ailus Signed-off-by: Kevin Hilman --- Minor tweaks since v6 - added ack from Sakari - droped an extraneous change for NULL subdev_info drivers/media/platform/davinci/vpif.c | 5 ++++- drivers/media/platform/davinci/vpif_capture.c | 13 +++++++++++++ drivers/media/platform/davinci/vpif_display.c | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c index 0380cf2e5775..f50148dcba64 100644 --- a/drivers/media/platform/davinci/vpif.c +++ b/drivers/media/platform/davinci/vpif.c @@ -32,6 +32,9 @@ MODULE_DESCRIPTION("TI DaVinci Video Port Interface driver"); MODULE_LICENSE("GPL"); +#define VPIF_DRIVER_NAME "vpif" +MODULE_ALIAS("platform:" VPIF_DRIVER_NAME); + #define VPIF_CH0_MAX_MODES 22 #define VPIF_CH1_MAX_MODES 2 #define VPIF_CH2_MAX_MODES 15 @@ -466,7 +469,7 @@ static const struct dev_pm_ops vpif_pm = { static struct platform_driver vpif_driver = { .driver = { - .name = "vpif", + .name = VPIF_DRIVER_NAME, .pm = vpif_pm_ops, }, .remove = vpif_remove, diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 5104cc0ee40e..892a26f3c5b4 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -45,6 +45,7 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Debug level 0-1"); #define VPIF_DRIVER_NAME "vpif_capture" +MODULE_ALIAS("platform:" VPIF_DRIVER_NAME); /* global variables */ static struct vpif_device vpif_obj = { {NULL} }; @@ -647,6 +648,10 @@ static int vpif_input_to_subdev( vpif_dbg(2, debug, "vpif_input_to_subdev\n"); + if (!chan_cfg) + return -1; + if (input_index >= chan_cfg->input_count) + return -1; subdev_name = chan_cfg->inputs[input_index].subdev_name; if (subdev_name == NULL) return -1; @@ -685,6 +690,9 @@ static int vpif_set_input( if (sd_index >= 0) { sd = vpif_obj.sd[sd_index]; subdev_info = &vpif_cfg->subdev_info[sd_index]; + } else { + /* no subdevice, no input to setup */ + return 0; } /* first setup input path from sub device to vpif */ @@ -1435,6 +1443,11 @@ static __init int vpif_probe(struct platform_device *pdev) int res_idx = 0; int i, err; + if (!pdev->dev.platform_data) { + dev_warn(&pdev->dev, "Missing platform data. Giving up.\n"); + return -EINVAL; + } + vpif_dev = &pdev->dev; err = initialize_vpif(); diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 75b27233ec2f..7f632b757d32 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -42,6 +42,7 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Debug level 0-1"); #define VPIF_DRIVER_NAME "vpif_display" +MODULE_ALIAS("platform:" VPIF_DRIVER_NAME); /* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */ static int ycmux_mode; @@ -1249,6 +1250,11 @@ static __init int vpif_probe(struct platform_device *pdev) int res_idx = 0; int i, err; + if (!pdev->dev.platform_data) { + dev_warn(&pdev->dev, "Missing platform data. Giving up.\n"); + return -EINVAL; + } + vpif_dev = &pdev->dev; err = initialize_vpif();