Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1149522pxb; Fri, 21 Jan 2022 10:55:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwb03rV6e7SBjb73ETTkTueGTQOP7ik9KFbVimszSmxQviC2d4IP97P/8cn6OyrcarEq4E7 X-Received: by 2002:a62:5e43:0:b0:4c7:375e:bcd0 with SMTP id s64-20020a625e43000000b004c7375ebcd0mr4721252pfb.7.1642791318025; Fri, 21 Jan 2022 10:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642791318; cv=none; d=google.com; s=arc-20160816; b=Vs0KotnjuIDg+qURuVhgeD1qtJj467QknmCwziIqco4lnqmH2V2rCDog+4pHBydcvq vOA/uYypC91/KUXsdmPhmLxufdLrML8cASrzy3RnNDVu7IUKm95N0h14zrBQ9zUrDrUQ 7j3oW3PKUXPPuUwdjyqKNqi95u22yIyKB6o24BE3QQQWukGHkojwnrdkE4izUmJb9or/ O58Ma57/gAqx/EsAkIlq5pX2B44SPX03INJ9JQdSMqTBFcDtm/VNZg2z9gQOP/Faz/Kb 4/OKL/fRANJY8VVRdPpfZSiN+vDJgRCK1ZbMXZbifhwJ2EB6UzhEOpoOR156XKiaGY1u vjYg== 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:references:organization:in-reply-to:subject:cc:to :from:dkim-signature; bh=ga/okBQe2Fk2y/3GAmGYVln6T2Ex6UizcSQdol1QGrc=; b=aiBcguH6evOiMKpb5mTTJhHTQxJ4WAYwo2CKJbl2HsTtHBb2R+45Ul5uNx28xhGt9I vly+a8IsdNrZc2sVlh08HUacb12JlPhAQyXmQZ/01a/UNAlKXc6QGeE/VMEf4s8VGXhn 6q+776FE5Knmj244P/NOn/JhelU5IhKylgfCTYmNPn92HDUg2UHNZiMc1ir/cc6oPGgS UTkzd1932TJ9ESm6dQJqXyEj8xDihouxPqiTBPY8mD5jGm+4VPbWYBWcAoHcGImGnzgA 8NM9t/lmp1JW2rhy9sEpI/ks7/5LaxxDCIVgIhR0h9qqSxQMr1u056BhFKuo7DNiKvki KD3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mYrG9e1o; 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 f7si8320693pfv.96.2022.01.21.10.55.06; Fri, 21 Jan 2022 10:55:18 -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=mYrG9e1o; 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 S1352040AbiASIDF (ORCPT + 99 others); Wed, 19 Jan 2022 03:03:05 -0500 Received: from mga14.intel.com ([192.55.52.115]:29408 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343971AbiASIC6 (ORCPT ); Wed, 19 Jan 2022 03:02:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642579378; x=1674115378; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=ttJ0yEmqdVCXnFR0RzsiyMUeg+GLGi5ZbTTPlF7sNtk=; b=mYrG9e1ovvkPWdIPpvPg8Wcb91xVxVYzvBRnOaBXEv/WatO+rbVHty+Q qz5hq6PY2pYP4z9wsS/r2rDIEuc9SwbuikVueEVdgKnQxT38agZFYmU6A j5os+aYPLDltT7j14kr9w3cqggXFvtLZ7+r4dzhJL7u82VAF58JXRijhz pGIDftbqzZFsR4i7bhLWpSib/7jIip1WAc0np29DmMpwKUQWkZnEOvvLn Pq9B/l7WIF3XrlvNKz+MY1lsDXsj5hMKfqiTYNJlakSzvn5yn7F7Wg4xZ zoSdgdu1dZM88htGut04hqWi3aoj+L0yywzBPcxbE7QGa3ButDb8QapP6 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10231"; a="245207743" X-IronPort-AV: E=Sophos;i="5.88,299,1635231600"; d="scan'208";a="245207743" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2022 00:02:47 -0800 X-IronPort-AV: E=Sophos;i="5.88,299,1635231600"; d="scan'208";a="477282343" Received: from elenadel-mobl.ger.corp.intel.com (HELO localhost) ([10.252.50.196]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2022 00:02:33 -0800 From: Jani Nikula To: Lucas De Marchi , 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 , Christian =?utf-8?Q?K=C3=B6nig?= , Chris Wilson , Daniel Vetter , David Airlie , "David S . Miller" , Emma Anholt , Eryk Brol , Francis Laniel , Greg Kroah-Hartman , Harry Wentland , Jakub Kicinski , 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: Re: [PATCH 0/3] lib/string_helpers: Add a few string helpers In-Reply-To: <20220119072450.2890107-1-lucas.demarchi@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220119072450.2890107-1-lucas.demarchi@intel.com> Date: Wed, 19 Jan 2022 10:02:31 +0200 Message-ID: <87sftk40h4.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Jan 2022, Lucas De Marchi wrote: > 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.co= m/ > 2) https://lore.kernel.org/all/20210215142137.64476-1-andriy.shevchenko@l= inux.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=C3=B6nig > (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. Thanks for picking this up again. I agree with the approach here. Acked-by: Jani Nikula > > 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=C3=B6nig > 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(-) --=20 Jani Nikula, Intel Open Source Graphics Center