From patchwork Fri Jun 10 11:14:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 9169495 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 97B2760573 for ; Fri, 10 Jun 2016 11:16:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 886B228328 for ; Fri, 10 Jun 2016 11:16:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D31B2835A; Fri, 10 Jun 2016 11:16:31 +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 6D04428359 for ; Fri, 10 Jun 2016 11:16:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBKOz-0001yX-Mp; Fri, 10 Jun 2016 11:15:01 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBKOw-0001v6-Os; Fri, 10 Jun 2016 11:14:59 +0000 Received: by mail-wm0-x244.google.com with SMTP id m124so17091846wme.3; Fri, 10 Jun 2016 04:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=oChNnTVEU4W7CPyrGbTvCPfCvDZ65/i93PVvI98Bjuk=; b=0NyQxQeBu8J2q5CWfdNrFAIERRzMEHC/vvyZah4Qs42/BjpvIMTsAFpjYlmxxsWMlF 17bqdSDbytC2szeF5D0QC2mCAYPLBi42vcEHiFfkfQ1ObPwBsaZ9m0XnmhVb6GLWaFtn 0IsDbIy/4IZDpkWHhvOXXHH3f7hFVsbl1Sq8EhSMeWeVshVAl8hlPFG4r/LTsO7jwjyY 6/oGEBh1N5/Du5cIOiPkyVz0fHssVuq+Wz9GYoGIpwpnuU0eIrDMXbzCFe+wsHdeCsz/ wgAa672ooqIOkfuMpZdPswRg4/FRLa7JzCIRFgAUGW8xhq9RKBEpGtZfjyQb0nNraGML 3jZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=oChNnTVEU4W7CPyrGbTvCPfCvDZ65/i93PVvI98Bjuk=; b=mDxN4es/KYADYVqYp9t9rh9Yke1AKE8CbDQ76VvLPhM1oq4TpajFg737SQUUL1gj1P BECsflnE8NvcXyf5bVImz2OJAMG04oj+D5NCtLGP+NfupbELK6vONkp3X1f/6Vr/0Huh nI8SQJzgdd2WXEY4DxeuvnGCCg3p0FSrQMECdtQlZodEY7fUkKVvt9OJ795Da/Iqsn15 OPPEoqBsYPJD1dy2EppyTdRHtJr86+VQuw82VLGmksk4jbFehzqn9aceYFxVJboedXR8 PtRBLEDAV2Ur6A+lf+ekI5mZuSKGGPe1mS+794nyVQ5M45KqEN1aV+fJqe5p9+ajNmlz kELQ== X-Gm-Message-State: ALyK8tKPkMAuMr+Wyn2z3+JcLNm1VZ8X9w2hTowSUJ8l9Wr3P5ZevMVKKqocHjllvclg9w== X-Received: by 10.195.9.67 with SMTP id dq3mr1806177wjd.140.1465557276657; Fri, 10 Jun 2016 04:14:36 -0700 (PDT) Received: from cizrna.lan ([109.72.12.252]) by smtp.gmail.com with ESMTPSA id f73sm2280003wmg.1.2016.06.10.04.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 04:14:35 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH] drm/rockchip: Drop drm_driver.load/unload callbacks Date: Fri, 10 Jun 2016 13:14:13 +0200 Message-Id: <1465557253-10670-1-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160610_041459_111420_BCD20CCD X-CRM114-Status: GOOD ( 14.35 ) 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: Heiko Stuebner , Tomeu Vizoso , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 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 They are deprecated and by moving their implementations to bind/unbind we can call drm_connector_register_all instead of open-coding it. Signed-off-by: Tomeu Vizoso Cc: Daniel Vetter --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 87 ++++++++++------------------- 1 file changed, 30 insertions(+), 57 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index f5a68fc031ed..8202c0634e4c 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -37,6 +37,7 @@ #define DRIVER_MINOR 0 static bool is_support_iommu = true; +static struct drm_driver rockchip_drm_driver; /* * Attach a (component) device to the shared drm dma mapping from master drm @@ -132,18 +133,29 @@ static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev, priv->crtc_funcs[pipe]->disable_vblank(crtc); } -static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags) +static int rockchip_drm_bind(struct device *dev) { + struct drm_device *drm_dev; struct rockchip_drm_private *private; struct dma_iommu_mapping *mapping = NULL; - struct device *dev = drm_dev->dev; - struct drm_connector *connector; int ret; - private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL); - if (!private) + drm_dev = drm_dev_alloc(&rockchip_drm_driver, dev); + if (!drm_dev) return -ENOMEM; + ret = drm_dev_register(drm_dev, 0); + if (ret) + goto err_free; + + dev_set_drvdata(dev, drm_dev); + + private = devm_kzalloc(drm_dev->dev, sizeof(*private), GFP_KERNEL); + if (!private) { + ret = -ENOMEM; + goto err_unregister; + } + mutex_init(&private->commit.lock); INIT_WORK(&private->commit.work, rockchip_drm_atomic_work); @@ -186,21 +198,10 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags) if (ret) goto err_detach_device; - /* - * All components are now added, we can publish the connector sysfs - * entries to userspace. This will generate hotplug events and so - * userspace will expect to be able to access DRM at this point. - */ - list_for_each_entry(connector, &drm_dev->mode_config.connector_list, - head) { - ret = drm_connector_register(connector); - if (ret) { - dev_err(drm_dev->dev, - "[CONNECTOR:%d:%s] drm_connector_register failed: %d\n", - connector->base.id, - connector->name, ret); - goto err_unbind; - } + ret = drm_connector_register_all(drm_dev); + if (ret) { + dev_err(dev, "failed to register connectors\n"); + goto err_unbind; } /* init kms poll for handling hpd */ @@ -240,12 +241,16 @@ err_release_mapping: err_config_cleanup: drm_mode_config_cleanup(drm_dev); drm_dev->dev_private = NULL; +err_unregister: + drm_dev_unregister(drm_dev); +err_free: + drm_dev_unref(drm_dev); return ret; } -static int rockchip_drm_unload(struct drm_device *drm_dev) +static void rockchip_drm_unbind(struct device *dev) { - struct device *dev = drm_dev->dev; + struct drm_device *drm_dev = dev_get_drvdata(dev); rockchip_drm_fbdev_fini(drm_dev); drm_vblank_cleanup(drm_dev); @@ -255,8 +260,9 @@ static int rockchip_drm_unload(struct drm_device *drm_dev) arm_iommu_detach_device(dev); drm_mode_config_cleanup(drm_dev); drm_dev->dev_private = NULL; - - return 0; + drm_dev_unregister(drm_dev); + drm_dev_unref(drm_dev); + dev_set_drvdata(dev, NULL); } static void rockchip_drm_crtc_cancel_pending_vblank(struct drm_crtc *crtc, @@ -308,8 +314,6 @@ const struct vm_operations_struct rockchip_drm_vm_ops = { static struct drm_driver rockchip_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, - .load = rockchip_drm_load, - .unload = rockchip_drm_unload, .preclose = rockchip_drm_preclose, .lastclose = rockchip_drm_lastclose, .get_vblank_counter = drm_vblank_no_hw_counter, @@ -449,37 +453,6 @@ static void rockchip_add_endpoints(struct device *dev, } } -static int rockchip_drm_bind(struct device *dev) -{ - struct drm_device *drm; - int ret; - - drm = drm_dev_alloc(&rockchip_drm_driver, dev); - if (!drm) - return -ENOMEM; - - ret = drm_dev_register(drm, 0); - if (ret) - goto err_free; - - dev_set_drvdata(dev, drm); - - return 0; - -err_free: - drm_dev_unref(drm); - return ret; -} - -static void rockchip_drm_unbind(struct device *dev) -{ - struct drm_device *drm = dev_get_drvdata(dev); - - drm_dev_unregister(drm); - drm_dev_unref(drm); - dev_set_drvdata(dev, NULL); -} - static const struct component_master_ops rockchip_drm_ops = { .bind = rockchip_drm_bind, .unbind = rockchip_drm_unbind,