From patchwork Wed Mar 28 01:24:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10311979 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 EDA0A60212 for ; Wed, 28 Mar 2018 01:31:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F056A2918C for ; Wed, 28 Mar 2018 01:31:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E52E129E61; Wed, 28 Mar 2018 01:31:08 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 928B02918C for ; Wed, 28 Mar 2018 01:31:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F97E89227; Wed, 28 Mar 2018 01:31:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id A32076E02A for ; Wed, 28 Mar 2018 01:30:57 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id o8so669343wra.1 for ; Tue, 27 Mar 2018 18:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MZ1547yhkD7U30prfmwEf7eyz6547lJG3k22e43AKpE=; b=h8W3a+1vkKO3akpMMP8P13iyr63v7OBn1WhswkTY631V2Q5pezXCSWWNqz2moIGrJ/ ouhWKgpJs6ldebYJWiOzpVIMCV4X735XkA4wDunjy4sPytb9QcD2NvJb0l2JtpiYhS2O L5dDdk0bbfRA7QUI4BbyJvwIgTjtlFTlKob6F96+4C2op5TsyPZNxS8pTyZaBBCnBYwM 2Xu8guWmj8CfJCanX4pas6x9syuQqiGIhqNxKIq68mRGX8v6SzgHYKpV65tdjJmeGk9+ 4Z+IGrlyaOImBBmy3QS4b/zTNhthVb9ylFwkjZ8rXJL0hmREP4ElQfM0su1iYQS+jZ6P kMlQ== 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; bh=MZ1547yhkD7U30prfmwEf7eyz6547lJG3k22e43AKpE=; b=Jib1jHQMnHkOu2UrbRKE5UfWF/Whqk4IGotdMZzifZNXq5HLQsfIAFsWXbHNHyQD9J ydyyDty68iudeWBShWkbv17VrM79xLRDEmZtNVrjJOpw/v4LvLFcwYUCW7VyEM1TGzKR Jwm4k5jt79BVxZ9QcnQ6KacoGaOUMqv2/43ggWjrydivyhjv2MBoMCnDENCp3SKhNusm QMfCqQpSzYjOWGbvuh7HeC8IJpRAU9zkykO3NQ7O0WS/vmVxulSki7Thd75PCGdVMZrz GG8Y7zoNJ9wYVojkWx1Ij0/0fMxLQkz1Ooq5AtKM4eLaw56PWWHuWrafsIvDj25nGlFr qumg== X-Gm-Message-State: AElRT7FP63Glnh5QeFr/aDQdpG6BZJNroYAAr3ahP9N6fDS9wVXb5pVv B6EvKgRzIarR58gXR62WXqP5wg== X-Google-Smtp-Source: AIpwx4/JaAMLy3fS5uV4ygtZ4oMS4OtBlplr2iEZQoQO+tE7SnSVUt6LLZ22pMTpFYWlRlGRShnnfg== X-Received: by 10.223.182.66 with SMTP id i2mr1111638wre.11.1522200655961; Tue, 27 Mar 2018 18:30:55 -0700 (PDT) Received: from localhost.localdomain (cpc91192-cmbg18-2-0-cust374.5-4.cable.virginm.net. [80.6.113.119]) by smtp.gmail.com with ESMTPSA id m9sm2641005wrf.13.2018.03.27.18.30.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 18:30:55 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm: BUG_ON if passing NULL parent to drm_dev_init Date: Wed, 28 Mar 2018 02:24:49 +0100 Message-Id: <20180328012451.31479-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180328012451.31479-1-emil.l.velikov@gmail.com> References: <20180328012451.31479-1-emil.l.velikov@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Deepak Sharma , Daniel Vetter , emil.l.velikov@gmail.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Previous commit removed the only reason why we were allowing NULL as a parent device. With that resolved, we can enforce nobody else does that mistake. With that we can drop the ugly drm_dev_set_unique workaround. Cc: Daniel Vetter Cc: Deepak Sharma Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index a1b9338736e3..88da984ff9eb 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -432,8 +432,6 @@ static void drm_fs_inode_free(struct inode *inode) * The initial ref-count of the object is 1. Use drm_dev_get() and * drm_dev_put() to take and drop further ref-counts. * - * Note that for purely virtual devices @parent can be NULL. - * * Drivers that do not want to allocate their own device struct * embedding &struct drm_device can call drm_dev_alloc() instead. For drivers * that do embed &struct drm_device it must be placed first in the overall @@ -458,6 +456,8 @@ int drm_dev_init(struct drm_device *dev, return -ENODEV; } + BUG_ON(parent == NULL); + kref_init(&dev->ref); dev->dev = parent; dev->driver = driver; @@ -506,9 +506,7 @@ int drm_dev_init(struct drm_device *dev, } } - /* Use the parent device name as DRM device unique identifier, but fall - * back to the driver name for virtual devices like vgem. */ - ret = drm_dev_set_unique(dev, parent ? dev_name(parent) : driver->name); + ret = drm_dev_set_unique(dev, dev_name(parent)); if (ret) goto err_setunique;