Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4986452pxb; Mon, 15 Feb 2021 06:42:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+2YRCQYx6I2uoCr3oKSnBdyBhZzS8rc1jaGn/9x7/GJ5boSY7XVLgJnnchYiViki3SC2P X-Received: by 2002:a17:906:b291:: with SMTP id q17mr9430814ejz.221.1613400158820; Mon, 15 Feb 2021 06:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613400158; cv=none; d=google.com; s=arc-20160816; b=lQ18ei9uUDEvaa+9iWyyGfvdvm6NBTURB22IrYA4Sca39PSqIawnXMcx1FlH7uuVi2 /PlN4Gezey+UE+ALV/crszj0n1xLpqANeVTuGF0YORV6L3uBuPxMSGdCCPFq2QQR9efi BXjdaiVOhyywbfy3yJKsF/RX53nfvWlAJq0PzN5f/ubsqkhPlcccNDgfF4s9m0SA++Fw 3zvq0oHgE573/RyU4FWqQnV+JXt73Uhp6lUVDcgqum5QYrENgJjaRChTX/7FfjWjZGp+ Ehc7FQxErWZ/lKhzauRJ0VMygObcPMpXtY+0afyR5OZB3aNbzGy+/NVhD/dWVRYdMb87 mOIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=xHHK/8u1vvqLCn02B/LysumJrqAoRzRE7llT1JjDcjg=; b=vpfuJEyId4bG4TAAzSZGj8KZVdCmXSRLAcn7eTRU86pN17rVuRdA6uFljAqbT9RGzg /95KvesbIWtJKed5O9SDa5GoHzwI/ppv2fBHTpUzHTnrPycAMbsDSNzQleHayCn/X+Ll o8XtAUp0HAOXpSVJApUrzpEk3LSqXseMtC1V6wopzdeGYB6JXGyeAVzRggllFFGHQE+R 1jewNfolbnQAyH319sa5Q6izLGOqabAVL6ZApeBFN/Gc9HI/nAkpQoZQw/73bQpnTOsv TZ9pdywcJn74HeumXj7Z3qFkBzhmvcwqma13WUfrypEOft4bWT2SieiIsZvrWX0YBcPn J62A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 o21si4254857edc.561.2021.02.15.06.42.15; Mon, 15 Feb 2021 06:42:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbhBOOjI (ORCPT + 99 others); Mon, 15 Feb 2021 09:39:08 -0500 Received: from mga14.intel.com ([192.55.52.115]:21619 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbhBOOil (ORCPT ); Mon, 15 Feb 2021 09:38:41 -0500 IronPort-SDR: 06+VMcysW8htvBSZM+hrfQtYcAMV9mRkD9itR+xLtk2wWTQFs/qR5nbY50RA7SZoWQM67tUE4h FkVIcv1yRiRQ== X-IronPort-AV: E=McAfee;i="6000,8403,9895"; a="181917719" X-IronPort-AV: E=Sophos;i="5.81,180,1610438400"; d="scan'208";a="181917719" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2021 06:38:00 -0800 IronPort-SDR: 5G8UVXefhcghHCN5eZ/Jau7JxqKQnqEhDlAhzJFDDDqpdGCxOwiDwXnHQUq21bhQHRB6bO3MsA uHOLp8d45o9Q== X-IronPort-AV: E=Sophos;i="5.81,180,1610438400"; d="scan'208";a="399097442" Received: from martincl-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.34.223]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2021 06:37:53 -0800 From: Jani Nikula To: Andy Shevchenko , Alex Deucher , Mikita Lipski , Eryk Brol , Chris Wilson , "David S. Miller" , Rahul Lakkireddy , Francis Laniel , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, netdev@vger.kernel.org Cc: Harry Wentland , Leo Li , Christian =?utf-8?Q?K=C3=B6nig?= , David Airlie , Daniel Vetter , Joonas Lahtinen , Rodrigo Vivi , Raju Rangoju , Jakub Kicinski , Andy Shevchenko Subject: Re: [PATCH v1 1/3] string: Consolidate yesno() helpers under string.h hood In-Reply-To: <20210215142137.64476-1-andriy.shevchenko@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20210215142137.64476-1-andriy.shevchenko@linux.intel.com> Date: Mon, 15 Feb 2021 16:37:50 +0200 Message-ID: <87y2fpbdmp.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Feb 2021, Andy Shevchenko wrote: > We have already few similar implementation and a lot of code that can benefit > of the yesno() helper. Consolidate yesno() helpers under string.h hood. Good luck. I gave up after just four versions. [1] Acked-by: Jani Nikula BR, Jani. [1] http://lore.kernel.org/r/20191023131308.9420-1-jani.nikula@intel.com > > Signed-off-by: Andy Shevchenko > --- > .../drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 6 +----- > drivers/gpu/drm/i915/i915_utils.h | 6 +----- > drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 12 +----------- > include/linux/string.h | 5 +++++ > 4 files changed, 8 insertions(+), 21 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > index 360952129b6d..7fde4f90e513 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > @@ -23,6 +23,7 @@ > * > */ > > +#include > #include > > #include > @@ -49,11 +50,6 @@ struct dmub_debugfs_trace_entry { > uint32_t param1; > }; > > -static inline const char *yesno(bool v) > -{ > - return v ? "yes" : "no"; > -} > - > /* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array > * > * Function takes in attributes passed to debugfs write entry > diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h > index abd4dcd9f79c..e6da5a951132 100644 > --- a/drivers/gpu/drm/i915/i915_utils.h > +++ b/drivers/gpu/drm/i915/i915_utils.h > @@ -27,6 +27,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -408,11 +409,6 @@ wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms) > #define MBps(x) KBps(1000 * (x)) > #define GBps(x) ((u64)1000 * MBps((x))) > > -static inline const char *yesno(bool v) > -{ > - return v ? "yes" : "no"; > -} > - > static inline const char *onoff(bool v) > { > return v ? "on" : "off"; > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c > index 7d49fd4edc9e..c857d73abbd7 100644 > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c > @@ -34,6 +34,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -2015,17 +2016,6 @@ static const struct file_operations rss_debugfs_fops = { > /* RSS Configuration. > */ > > -/* Small utility function to return the strings "yes" or "no" if the supplied > - * argument is non-zero. > - */ > -static const char *yesno(int x) > -{ > - static const char *yes = "yes"; > - static const char *no = "no"; > - > - return x ? yes : no; > -} > - > static int rss_config_show(struct seq_file *seq, void *v) > { > struct adapter *adapter = seq->private; > diff --git a/include/linux/string.h b/include/linux/string.h > index 9521d8cab18e..fd946a5e18c8 100644 > --- a/include/linux/string.h > +++ b/include/linux/string.h > @@ -308,4 +308,9 @@ static __always_inline size_t str_has_prefix(const char *str, const char *prefix > return strncmp(str, prefix, len) == 0 ? len : 0; > } > > +static inline const char *yesno(bool yes) > +{ > + return yes ? "yes" : "no"; > +} > + > #endif /* _LINUX_STRING_H_ */ -- Jani Nikula, Intel Open Source Graphics Center