From patchwork Tue Oct 23 16:35: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: 10653433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BFF013A9 for ; Tue, 23 Oct 2018 16:37:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D9D72A022 for ; Tue, 23 Oct 2018 16:37:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 618682A093; Tue, 23 Oct 2018 16:37:01 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 1D4642A022 for ; Tue, 23 Oct 2018 16:37:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 229D76E1F2; Tue, 23 Oct 2018 16:37:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 597826E1F2 for ; Tue, 23 Oct 2018 16:36:55 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id b203-v6so2517870wme.5 for ; Tue, 23 Oct 2018 09:36:55 -0700 (PDT) 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=0Pmb/LbDWqIGQ5zF9ufu7GVmTP04nHxYPaOgCFK6DLI=; b=CTKvVk89APVWl1+IpHAc3zBKnqbFmVif1aPKa67zVQNXd2NiaZiabqgG892GFeAAdv ZZN+KRy8TyHU+XeP6/VTcirBdrQo6MGQeewyMh0GwnaacTZrpM77HYH/ekJTDSwumMgx Beplb1xHe9HqhOWuWMMYaFPBOGEUp7WGAmcY/wCi0i6o0m0CIcSba3sj6kvlxiqLxra+ 0Tree/uGpO52Hw5/csppFdBzwJj1Q0ApZxrjSfkx/t4uIDitYHs9RN6RlfzOcWiW/0Tt E206nzoEUHf03gHRPkQz0mzX26D+y+5TFaT1fxo+BiYU2FtkOpApKktwak4pPs+iHGI3 vYgw== X-Gm-Message-State: ABuFfogbyAkVNb7vN2Jw0c7ThZYyjDSiVRmh5Aq4Ng+kCbacQxj17EaN K6MEND5URj0xFcnVGWKNlKAohMEw X-Google-Smtp-Source: AJdET5fWL0C/ps5qej+LqctoOhKcyWy+WfP7LGVRUaUe3X1tpoz6d4pguQGGoJGK/pktHRSZCXAsag== X-Received: by 2002:a1c:9901:: with SMTP id b1-v6mr20335485wme.15.1540312613753; Tue, 23 Oct 2018 09:36:53 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id q77-v6sm3246732wmd.33.2018.10.23.09.36.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 09:36:52 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm: BUG_ON if passing NULL parent to drm_dev_init Date: Tue, 23 Oct 2018 17:35:49 +0100 Message-Id: <20181023163550.15211-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181023163550.15211-1-emil.l.velikov@gmail.com> References: <20181023163550.15211-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 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 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. v2: rebase, silence checkpatch "== NULL" warning Cc: Daniel Vetter Cc: Deepak Sharma Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter 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 36e8e9cbec52..aa1cef794f9a 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -476,8 +476,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 @@ -502,6 +500,8 @@ int drm_dev_init(struct drm_device *dev, return -ENODEV; } + BUG_ON(!parent); + kref_init(&dev->ref); dev->dev = parent; dev->driver = driver; @@ -556,9 +556,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;