Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1130119pxb; Fri, 21 Jan 2022 10:28:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/cKrG4bUd4wrfq1i2C295xuECc6ETxiM3QVxvMl/xFtjenr40+SL/I1qZd5Q/miQG9bID X-Received: by 2002:a17:90a:2e17:: with SMTP id q23mr1977990pjd.115.1642789706800; Fri, 21 Jan 2022 10:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642789706; cv=none; d=google.com; s=arc-20160816; b=lcdMLa5nkhMPR4q0v5MDxBolHLTtSKYf4KxzAmPzOWV6NN2shl3XHMX6ZO5f/n2zT7 C1mVogrYiGkOHu3bFsbHI1fUwJfoKwvKWfM9K16t9PFgmJZCq+Ok1ejbDy3R+8II0uJf QthOq3jKZ+4tfl5lHJa9VCSdgGd+3ZbC32q8SxPjN4TgMVeIwlG5X+MESMjBGx4fIXXq 6gIzo6FIOzowjojSGFPDATlu0Uqy2bkYh5MjZB8WvUlPIYNH/v/hlruRH7jpcWqWtxwY UTtnLjsSDQSrqeQo4cRBCu8whDvl0uTN73qa3h3pU9iJIg5M2JD6tJ4CHoOPL+IjoZ4P S4+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=eQXw0SNhh+e+e7JWFWt4s0+ob/DDY2NCMj0QRhI8/ZE=; b=o9WMCTiafbeWH1ogomu+zQ7NzNqzDR8Sg2318awDjSxYq+fno00eSCwbYF+FH1DSko N0SHYFAi2D7iOFgOjljKSNF35cwopxyO6xc57cKIs4Yfty5XJ1ku4q/Iq19kk48youD5 gGyxwqA/J7r825fAvbSH+TXUUNOBMhxn1beAXYDuSLgFkzXD3chPT/2tJ2SRxIYsu/c0 UvFQ1QTp7Fq9PYtlbdZee8LgTwLCP7zd0yecXgjVHuIn8wmc00mp351GJS26pDVYcAqO CPqpbmNM1V6iCn4K8Oj3lUOsC8S9x4CcY/v8ynHzKgxKyKKHva3vlAH+cbnDBEEL7b66 0JyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XkocNBOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si6191511pll.41.2022.01.21.10.27.56; Fri, 21 Jan 2022 10:28:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XkocNBOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351977AbiASHY1 (ORCPT + 99 others); Wed, 19 Jan 2022 02:24:27 -0500 Received: from mga09.intel.com ([134.134.136.24]:35948 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240572AbiASHY0 (ORCPT ); Wed, 19 Jan 2022 02:24:26 -0500 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="244799926" X-IronPort-AV: E=Sophos;i="5.88,299,1635231600"; d="scan'208";a="244799926" 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 Cc: Alex Deucher , Andrew Morton , Andy Shevchenko , Andy Shevchenko , Ben Skeggs , =?UTF-8?q?Christian=20K=C3=B6nig?= , Chris Wilson , Daniel Vetter , David Airlie , "David S . Miller" , Emma Anholt , Eryk Brol , Francis Laniel , Greg Kroah-Hartman , Harry Wentland , Jakub Kicinski , Jani Nikula , Joonas Lahtinen , Julia Lawall , Kentaro Takeda , Leo Li , Mikita Lipski , Petr Mladek , Rahul Lakkireddy , Raju Rangoju , Rasmus Villemoes , Rodrigo Vivi , Sakari Ailus , Sergey Senozhatsky , Steven Rostedt , Vishal Kulkarni Subject: [PATCH 0/3] lib/string_helpers: Add a few string helpers 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.34.1