From patchwork Tue Jan 10 20:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 13095636 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 62C5CC46467 for ; Tue, 10 Jan 2023 20:23:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4E9E10E499; Tue, 10 Jan 2023 20:23:51 +0000 (UTC) Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87D1E10E499 for ; Tue, 10 Jan 2023 20:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1673382219; bh=KZfzfJaCNSjj2cTY/A9poRlxwbx4f/9t6x9qIyEDr8E=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=CZoF55ErL81RjxfbxOv/AGJIcDveO43CgMfLfYnt8wwGG2dpb8hrAqnhdZldpeusl Z/21vZg3MBNIugKKDxs2twaRgtbDn2ldWvu/AySGUWgYak3YzYdw1chsIb3BkDE57x PmcM+ivZJdxPDDz38imrY69pYS8R3CLSgubKPJRI= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 10 Jan 2023 21:23:39 +0100 (CET) X-EA-Auth: jYWb5T3M9TX6HZLgkCJh+aXe7wz+hgdymKalfl4XRaUsGWATnEes0XA+xMOkmZgIygg47pBLvZRa8Gb/Wq/ModSHcKL8W0Bd Date: Wed, 11 Jan 2023 01:53:34 +0530 From: Deepak R Varma To: Guido =?iso-8859-1?q?G=FCnther?= , Purism Kernel Team , Ondrej Jirman , Thierry Reding , Sam Ravnborg , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/panel: st7703: Avoid full proxy f_ops for st7703 debug attributes Message-ID: MIME-Version: 1.0 Content-Disposition: inline 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: Praveen Kumar , Saurabh Singh Sengar Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Using DEFINE_SIMPLE_ATTRIBUTE macro with the debugfs_create_file() function adds the overhead of introducing a proxy file operation functions to wrap the original read/write inside file removal protection functions. This adds significant overhead in terms of introducing and managing the proxy factory file operations structure and function wrapping at runtime. As a replacement, a combination of DEFINE_DEBUGFS_ATTRIBUTE macro paired with debugfs_create_file_unsafe() is suggested to be used instead. The DEFINE_DEBUGFS_ATTRIBUTE utilises debugfs_file_get() and debugfs_file_put() wrappers to protect the original read and write function calls for the debug attributes. There is no need for any runtime proxy file operations to be managed by the debugfs core. Following coccicheck make command helped identify this change: make coccicheck M=drivers/gpu/drm/i915/ MODE=patch COCCI=./scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci Signed-off-by: Deepak R Varma Acked-by: Sam Ravnborg --- Note: Patch compile tested only. drivers/gpu/drm/panel/panel-sitronix-st7703.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c index 86a472b01360..22ed7e2b0e00 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c @@ -510,15 +510,14 @@ static int allpixelson_set(void *data, u64 val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE(allpixelson_fops, NULL, - allpixelson_set, "%llu\n"); +DEFINE_DEBUGFS_ATTRIBUTE(allpixelson_fops, NULL, allpixelson_set, "%llu\n"); static void st7703_debugfs_init(struct st7703 *ctx) { ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL); - debugfs_create_file("allpixelson", 0600, ctx->debugfs, ctx, - &allpixelson_fops); + debugfs_create_file_unsafe("allpixelson", 0600, ctx->debugfs, ctx, + &allpixelson_fops); } static void st7703_debugfs_remove(struct st7703 *ctx)