From patchwork Wed Dec 7 05:08:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9463927 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 6D1F66022E for ; Wed, 7 Dec 2016 05:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6237D2847E for ; Wed, 7 Dec 2016 05:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54F952849D; Wed, 7 Dec 2016 05:08:41 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1FD322847E for ; Wed, 7 Dec 2016 05:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752699AbcLGFIh (ORCPT ); Wed, 7 Dec 2016 00:08:37 -0500 Received: from mail-pg0-f51.google.com ([74.125.83.51]:33389 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752652AbcLGFIg (ORCPT ); Wed, 7 Dec 2016 00:08:36 -0500 Received: by mail-pg0-f51.google.com with SMTP id 3so157601916pgd.0 for ; Tue, 06 Dec 2016 21:08:36 -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=VfPcReYvFOD4MsHUP5lHeW0+Akv+hoPAvNGnPWX/31Y=; b=x4arWXYEDZDgVqGUgnp2kb2kFecOZ8p/p/8Q5uEpHvpIXsVeoomxdQjyGzp08aMTFI 8hRrRhJZhhrELm3iR+NwYX6XORiGDTXEhAabD349pqpK7qDaRrVQvOS3ixHIjNh54SPb b1sqoTsK6wKlBKRmNUKHISrsaczntlme8U+N/13eyp2H7MbjRbu8cAfjxvEDVzVs0CB2 xFxzO9qN8rA5kHrGHtCCEMdJFy+3K8NZ0G+bzgCxGsghp7Zzw+wAfznDy97Y0jmD2nHd /AU2klJ7Q19Vu3S9DD4eOLY5aRja9LrwdAYweRB5EkC4Kg2olIpLrLYi91XUvZLfSqvd 1Ssw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VfPcReYvFOD4MsHUP5lHeW0+Akv+hoPAvNGnPWX/31Y=; b=FIG6YXGQNIsnmvLfLwTb/7wikv1TzwFMyylD1286nyKTgWrWgdHlEYgtNB1FKNLTtT vz2gh5J0u0CdyL49i9ugnHO8gYGGr+gTQ3jHnd3UwD99cSTcE8JSi2qPHpOm4qNOJ/uN yuFa0hdzMXOFbkqWv99Oqqq9yw1wN5YjVE1UNajHbo3yUlrHLW8DZvGNjm/73Ay+/UDY RcWa+SeFNb7E3M9O6oISSlWuu8XPhGCRXcXZtpnvd5Nm357ESwqQD8+ZOWquc4W5ToR2 CTPumm9Y8qldCZjnHCSzH2o/Y3zFTk4BW3Aywx9lsCYJdPyXJkdXl2lK0mR7sf835zyB eztw== X-Gm-Message-State: AKaTC03CfQLpasG7I69DJcxhYpiwPT33kUun0QpxcCbQCt9y+7bHi0+yjTPmkW1dM2BMdHR3 X-Received: by 10.84.204.8 with SMTP id a8mr145970670ple.172.1481087315807; Tue, 06 Dec 2016 21:08:35 -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 j190sm38540228pgd.23.2016.12.06.21.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 21:08:35 -0800 (PST) From: Kevin Hilman To: Hans Verkuil , Laurent Pinchart , Sakari Ailus , linux-media@vger.kernel.org Cc: Sekhar Nori , Axel Haslam , =?UTF-8?q?Bartosz=20Go=C5=82aszewski?= , Alexandre Bailon , David Lechner , Patrick Titiano , linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 1/5] [media] davinci: VPIF: fix module loading, init errors Date: Tue, 6 Dec 2016 21:08:22 -0800 Message-Id: <20161207050826.23174-2-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161207050826.23174-1-khilman@baylibre.com> References: <20161207050826.23174-1-khilman@baylibre.com> MIME-Version: 1.0 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 Fix problems with automatic module loading by adding MODULE_ALIAS. Also fix various load-time errors cause by incorrect or not present platform_data. Signed-off-by: Kevin Hilman --- drivers/media/platform/davinci/vpif.c | 5 ++++- drivers/media/platform/davinci/vpif_capture.c | 15 ++++++++++++++- drivers/media/platform/davinci/vpif_display.c | 6 ++++++ 3 files changed, 24 insertions(+), 2 deletions(-) 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..20c4344ed118 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; @@ -654,7 +659,7 @@ static int vpif_input_to_subdev( /* loop through the sub device list to get the sub device info */ for (i = 0; i < vpif_cfg->subdev_count; i++) { subdev_info = &vpif_cfg->subdev_info[i]; - if (!strcmp(subdev_info->name, subdev_name)) + if (subdev_info && !strcmp(subdev_info->name, subdev_name)) return i; } 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();