From patchwork Wed Jan 19 07:24:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 12717167 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 D427BC4167B for ; Wed, 19 Jan 2022 07:24:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC50B10E1B6; Wed, 19 Jan 2022 07:24:27 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 71CE110E173; Wed, 19 Jan 2022 07:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642577066; x=1674113066; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lRyYmpoponpkRQxOs7JfGkkt5rdxgzCiwRUBQKDLGQA=; b=XkocNBOnPF48WNQmC1eOR34uIJgisv1uB8MeY6xcfIBJt3fT8JBegmb4 Q7Zizod06Kd35NrEPi1e7/ThV9/o6LRdum9sAJYEqcK3+wc6N/0bzlLA2 e7MgMMtiA80iVTyk+6dAnYreK1xbA6LtAekrcyKwpz3V4VkixsBimhHPf v43Jj6DnVyTyQrONayOCtan19DONQERO2zIVh43XTFEMwkoF36ElPb8ON 9VxiVL4+9nWZgHo/Igs4u7RREzzG40TE0oTyCPyrs6Yr5KqcF5doEIcs8 Wnx9Y+Nv+UqrkUfLUdY1LwlWI9iFn1kqV4SfoO8kuqGi+Y3ghrI85BcrJ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10231"; a="244799924" X-IronPort-AV: E=Sophos;i="5.88,299,1635231600"; d="scan'208";a="244799924" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 23:24:25 -0800 X-IronPort-AV: E=Sophos;i="5.88,299,1635231600"; d="scan'208";a="530544489" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.202]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 23:24:25 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-security-module@vger.kernel.org, nouveau@lists.freedesktop.org, netdev@vger.kernel.org Date: Tue, 18 Jan 2022 23:24:47 -0800 Message-Id: <20220119072450.2890107-1-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 0/3] lib/string_helpers: Add a few string helpers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emma Anholt , David Airlie , Rasmus Villemoes , Chris Wilson , Vishal Kulkarni , Francis Laniel , Kentaro Takeda , Andy Shevchenko , Andy Shevchenko , Ben Skeggs , Jakub Kicinski , Harry Wentland , Petr Mladek , Sakari Ailus , Leo Li , Julia Lawall , Rahul Lakkireddy , Steven Rostedt , Mikita Lipski , Eryk Brol , Greg Kroah-Hartman , =?utf-8?q?Christian_K?= =?utf-8?q?=C3=B6nig?= , Sergey Senozhatsky , Raju Rangoju , Alex Deucher , Andrew Morton , "David S . Miller" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add some helpers under lib/string_helpers.h so they can be used throughout the kernel. When I started doing this there were 2 other previous attempts I know of, not counting the iterations each of them had: 1) https://lore.kernel.org/all/20191023131308.9420-1-jani.nikula@intel.com/ 2) https://lore.kernel.org/all/20210215142137.64476-1-andriy.shevchenko@linux.intel.com/#t Going through the comments I tried to find some common ground and justification for what is in here, addressing some of the concerns raised. a. This version should be a drop-in replacement for what is currently in the tree, with no change in behavior or binary size. For binary size what I checked wat that the linked objects in the end have the same size (gcc 11). From comments in the previous attempts this seems also the case for earlier compiler versions b. I didn't change the function name to choice_* as suggested by Andrew Morton in 20191023155619.43e0013f0c8c673a5c508c1e@linux-foundation.org because other people argumented in favor of shorter names for these simple helpers - if they are long and people simply not use due to that, we failed c. Use string_helper.h for these helpers - pulling string.h in the compilations units was one of the concerns and I think re-using this already existing header is better than creating a new string-choice.h d. This doesn't bring onoff() helper as there are some places in the kernel with onoff as variable - another name is probably needed for this function in order not to shadow the variable, or those variables could be renamed. Or if people wanting try to find a short one e. One alternative to all of this suggested by Christian König (43456ba7-c372-84cc-4949-dcb817188e21@amd.com) would be to add a printk format. But besides the comment, he also seemed to like the common function. This brought the argument from others that the simple yesno()/enabledisable() already used in the code is easier to remember and use than e.g. %py[DOY] Last patch also has some additional conversion of open coded cases. I preferred starting with drm/ since this is "closer to home". I hope this is a good summary of the previous attempts and a way we can move forward. Andrew Morton, Petr Mladek, Andy Shevchenko: if this is accepted, my proposal is to take first 2 patches either through mm tree or maybe vsprintf. Last patch can be taken later through drm. thanks Lucas De Marchi Cc: Alex Deucher Cc: Andrew Morton Cc: Andy Shevchenko Cc: Andy Shevchenko Cc: Ben Skeggs Cc: Christian König Cc: Chris Wilson Cc: Daniel Vetter Cc: David Airlie Cc: David S. Miller Cc: Emma Anholt Cc: Eryk Brol Cc: Francis Laniel Cc: Greg Kroah-Hartman Cc: Harry Wentland Cc: Jakub Kicinski Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Julia Lawall Cc: Kentaro Takeda Cc: Leo Li Cc: Mikita Lipski Cc: Petr Mladek Cc: Rahul Lakkireddy Cc: Raju Rangoju Cc: Rasmus Villemoes Cc: Rodrigo Vivi Cc: Sakari Ailus Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Vishal Kulkarni Lucas De Marchi (3): lib/string_helpers: Consolidate yesno() implementation lib/string_helpers: Add helpers for enable[d]/disable[d] drm: Convert open yes/no strings to yesno() drivers/gpu/drm/amd/amdgpu/atom.c | 3 ++- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 6 +----- drivers/gpu/drm/drm_client_modeset.c | 3 ++- drivers/gpu/drm/drm_dp_helper.c | 3 ++- drivers/gpu/drm/drm_gem.c | 3 ++- drivers/gpu/drm/i915/i915_utils.h | 15 --------------- drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c | 4 +++- drivers/gpu/drm/radeon/atom.c | 3 ++- drivers/gpu/drm/v3d/v3d_debugfs.c | 11 ++++++----- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 3 ++- .../net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 11 ----------- include/linux/string_helpers.h | 4 ++++ security/tomoyo/audit.c | 2 +- security/tomoyo/common.c | 18 ++++-------------- security/tomoyo/common.h | 1 - 15 files changed, 31 insertions(+), 59 deletions(-) Acked-by: Jani Nikula Reviewed-by: Andy Shevchenko Acked-by: Daniel Vetter