From patchwork Tue Jan 31 19:58:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13123346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9361C636CC for ; Tue, 31 Jan 2023 20:02:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A651110E38B; Tue, 31 Jan 2023 20:02:19 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id E973710E0B4 for ; Tue, 31 Jan 2023 20:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XZjrLCUy+Y+GPUw3s6ky4Y/Ag/gUMPF9eB2/jZzeMjk=; b=Oax1uePUE8v57hXBloFgGYNT9J p4NxLIe5aVU7N+eujoXPw3Rvv65VqMkxw1Wkk4PUA9BQ7jOKtqPVdF+SjwQCgB1ODtDRr5zfuszN+ /BYbdT1m5ULYc6lOIITZnA3UN20Vvlvp5ezV2y66Ej8g8Ni04JhhFzCw5fJFs8mPiYKflvrAB6JDG EdtsSuqvSSQs5579mVK7HEjiPCuh4QQtx+TS0gzVufj+jXuiXIV/qLX7FyhcPuFUzmcFKSWedBp+d Q0/9NesCtyzR+dwdh2UA9drgsa2nmfkIOWEigVGtn8eou7/rwLnJgdcCd61qAO2zCMLt/qBwDcb+8 Ff4GpqVw==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pMwpF-005kjr-Nb; Tue, 31 Jan 2023 21:01:54 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Liviu Dudau , Brian Starkey , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Melissa Wen , Rodrigo Siqueira , Jani Nikula Subject: [PATCH v3 3/6] drm/debugfs: Create wrapper to add files to debugfs list Date: Tue, 31 Jan 2023 16:58:23 -0300 Message-Id: <20230131195825.677487-4-mcanal@igalia.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230131195825.677487-1-mcanal@igalia.com> References: <20230131195825.677487-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , =?utf-8?q?Andr=C3=A9_A?= =?utf-8?q?lmeida?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Create a helper to encapsulate the code that adds a new debugfs file to a linked list related to a object. Moreover, the helper also provides more flexibily, as the parameter is a struct drm_debugfs_files. Signed-off-by: MaĆ­ra Canal --- drivers/gpu/drm/drm_debugfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index aa83f230c402..0e3f3ffa9f88 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -236,6 +236,13 @@ void drm_debugfs_files_destroy(struct drm_debugfs_files *debugfs_files) kfree(debugfs_files); } +static void drm_debugfs_files_add(struct drm_debugfs_files *debugfs_files, struct list_head *entry) +{ + mutex_lock(&debugfs_files->mutex); + list_add(entry, &debugfs_files->list); + mutex_unlock(&debugfs_files->mutex); +} + int drm_debugfs_init(struct drm_minor *minor, int minor_id, struct dentry *root) { @@ -357,9 +364,7 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name, entry->file.data = data; entry->dev = dev; - mutex_lock(&dev->debugfs_files->mutex); - list_add(&entry->list, &dev->debugfs_files->list); - mutex_unlock(&dev->debugfs_files->mutex); + drm_debugfs_files_add(dev->debugfs_files, &entry->list); } EXPORT_SYMBOL(drm_debugfs_add_file);