From: Lucas De Marchi <lucas.demarchi@intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: "Alex Deucher" <alexander.deucher@amd.com>, "Mikita Lipski" <mikita.lipski@amd.com>, "Eryk Brol" <eryk.brol@amd.com>, "Chris Wilson" <chris@chris-wilson.co.uk>, "David S. Miller" <davem@davemloft.net>, "Rahul Lakkireddy" <rahul.lakkireddy@chelsio.com>, "Francis Laniel" <laniel_francis@privacyrequired.com>, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, netdev@vger.kernel.org, "Harry Wentland" <harry.wentland@amd.com>, "Leo Li" <sunpeng.li@amd.com>, "Christian König" <christian.koenig@amd.com>, "David Airlie" <airlied@linux.ie>, "Daniel Vetter" <daniel@ffwll.ch>, "Jani Nikula" <jani.nikula@linux.intel.com>, "Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>, "Rodrigo Vivi" <rodrigo.vivi@intel.com>, "Raju Rangoju" <rajur@chelsio.com>, "Jakub Kicinski" <kuba@kernel.org> Subject: Re: [PATCH v1 1/3] string: Consolidate yesno() helpers under string.h hood Date: Tue, 5 Oct 2021 14:34:23 -0700 [thread overview] Message-ID: <20211005213423.dklsii4jx37pjvb4@ldmartin-desk2> (raw) In-Reply-To: <20210215142137.64476-1-andriy.shevchenko@linux.intel.com> On Mon, Feb 15, 2021 at 04:21:35PM +0200, 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. I was taking a look on i915_utils.h to reduce it and move some of it elsewhere to be shared with others. I was starting with these helpers and had [1] done, then Jani pointed me to this thread and also his previous tentative. I thought the natural place for this would be include/linux/string_helpers.h, but I will leave it up to you. After reading the threads, I don't see real opposition to it. Is there a tree you plan to take this through? thanks Lucas De Marchi [1] https://lore.kernel.org/lkml/20211005212634.3223113-1-lucas.demarchi@intel.com/T/#u > >Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> >--- > .../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 <linux/string.h> > #include <linux/uaccess.h> > > #include <drm/drm_debugfs.h> >@@ -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 <linux/list.h> > #include <linux/overflow.h> >+#include <linux/string.h> > #include <linux/sched.h> > #include <linux/types.h> > #include <linux/workqueue.h> >@@ -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 <linux/seq_file.h> > #include <linux/debugfs.h> >+#include <linux/string.h> > #include <linux/string_helpers.h> > #include <linux/sort.h> > #include <linux/ctype.h> >@@ -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_ */ >-- >2.30.0 > >
WARNING: multiple messages have this Message-ID (diff)
From: Lucas De Marchi <lucas.demarchi@intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: "Alex Deucher" <alexander.deucher@amd.com>, "Mikita Lipski" <mikita.lipski@amd.com>, "Eryk Brol" <eryk.brol@amd.com>, "Chris Wilson" <chris@chris-wilson.co.uk>, "David S. Miller" <davem@davemloft.net>, "Rahul Lakkireddy" <rahul.lakkireddy@chelsio.com>, "Francis Laniel" <laniel_francis@privacyrequired.com>, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, netdev@vger.kernel.org, "Harry Wentland" <harry.wentland@amd.com>, "Leo Li" <sunpeng.li@amd.com>, "Christian König" <christian.koenig@amd.com>, "David Airlie" <airlied@linux.ie>, "Daniel Vetter" <daniel@ffwll.ch>, "Jani Nikula" <jani.nikula@linux.intel.com>, "Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>, "Rodrigo Vivi" <rodrigo.vivi@intel.com>, "Raju Rangoju" <rajur@chelsio.com>, "Jakub Kicinski" <kuba@kernel.org> Subject: Re: [Intel-gfx] [PATCH v1 1/3] string: Consolidate yesno() helpers under string.h hood Date: Tue, 5 Oct 2021 14:34:23 -0700 [thread overview] Message-ID: <20211005213423.dklsii4jx37pjvb4@ldmartin-desk2> (raw) In-Reply-To: <20210215142137.64476-1-andriy.shevchenko@linux.intel.com> On Mon, Feb 15, 2021 at 04:21:35PM +0200, 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. I was taking a look on i915_utils.h to reduce it and move some of it elsewhere to be shared with others. I was starting with these helpers and had [1] done, then Jani pointed me to this thread and also his previous tentative. I thought the natural place for this would be include/linux/string_helpers.h, but I will leave it up to you. After reading the threads, I don't see real opposition to it. Is there a tree you plan to take this through? thanks Lucas De Marchi [1] https://lore.kernel.org/lkml/20211005212634.3223113-1-lucas.demarchi@intel.com/T/#u > >Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> >--- > .../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 <linux/string.h> > #include <linux/uaccess.h> > > #include <drm/drm_debugfs.h> >@@ -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 <linux/list.h> > #include <linux/overflow.h> >+#include <linux/string.h> > #include <linux/sched.h> > #include <linux/types.h> > #include <linux/workqueue.h> >@@ -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 <linux/seq_file.h> > #include <linux/debugfs.h> >+#include <linux/string.h> > #include <linux/string_helpers.h> > #include <linux/sort.h> > #include <linux/ctype.h> >@@ -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_ */ >-- >2.30.0 > >
next prev parent reply other threads:[~2021-10-05 21:34 UTC|newest] Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-15 14:21 [PATCH v1 1/3] string: Consolidate yesno() helpers under string.h hood Andy Shevchenko 2021-02-15 14:21 ` Andy Shevchenko 2021-02-15 14:21 ` [Intel-gfx] " Andy Shevchenko 2021-02-15 14:21 ` Andy Shevchenko 2021-02-15 14:21 ` [PATCH v1 2/3] string: Move onoff() helper " Andy Shevchenko 2021-02-15 14:21 ` Andy Shevchenko 2021-02-15 14:21 ` [Intel-gfx] " Andy Shevchenko 2021-02-15 14:21 ` Andy Shevchenko 2021-02-15 14:21 ` [PATCH v1 3/3] string: Move enableddisabled() " Andy Shevchenko 2021-02-15 14:21 ` Andy Shevchenko 2021-02-15 14:21 ` [Intel-gfx] " Andy Shevchenko 2021-02-15 14:21 ` Andy Shevchenko 2021-02-15 14:26 ` [PATCH v1 1/3] string: Consolidate yesno() helpers " Christian König 2021-02-15 14:26 ` Christian König 2021-02-15 14:26 ` [Intel-gfx] " Christian König 2021-02-15 14:26 ` Christian König 2021-02-15 14:39 ` Andy Shevchenko 2021-02-15 14:39 ` Andy Shevchenko 2021-02-15 14:39 ` [Intel-gfx] " Andy Shevchenko 2021-02-15 14:39 ` Andy Shevchenko 2021-02-17 12:45 ` Petr Mladek 2021-02-17 12:45 ` Petr Mladek 2021-02-17 12:45 ` [Intel-gfx] " Petr Mladek 2021-02-17 12:45 ` Petr Mladek 2021-02-17 17:13 ` Jani Nikula 2021-02-17 17:13 ` Jani Nikula 2021-02-17 17:13 ` [Intel-gfx] " Jani Nikula 2021-02-17 17:13 ` Jani Nikula 2021-02-15 14:37 ` Jani Nikula 2021-02-15 14:37 ` Jani Nikula 2021-02-15 14:37 ` [Intel-gfx] " Jani Nikula 2021-02-15 14:37 ` Jani Nikula 2021-02-15 15:58 ` Andy Shevchenko 2021-02-15 15:58 ` Andy Shevchenko 2021-02-15 15:58 ` [Intel-gfx] " Andy Shevchenko 2021-02-15 15:58 ` Andy Shevchenko 2021-02-15 16:00 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v1,1/3] " Patchwork 2021-02-15 16:30 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork 2021-02-15 18:21 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork 2021-10-05 21:34 ` Lucas De Marchi [this message] 2021-10-05 21:34 ` [Intel-gfx] [PATCH v1 1/3] " Lucas De Marchi 2021-11-15 11:07 ` Andy Shevchenko 2021-11-15 11:07 ` Andy Shevchenko 2021-11-15 11:07 ` Andy Shevchenko 2021-11-15 11:07 ` [Intel-gfx] " Andy Shevchenko 2021-11-15 11:43 ` Jani Nikula 2021-11-15 11:43 ` Jani Nikula 2021-11-15 11:43 ` [Intel-gfx] " Jani Nikula 2021-11-15 11:43 ` Jani Nikula 2021-11-15 14:22 ` Andy Shevchenko 2021-11-15 14:22 ` Andy Shevchenko 2021-11-15 14:22 ` Andy Shevchenko 2021-11-15 14:22 ` [Intel-gfx] " Andy Shevchenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211005213423.dklsii4jx37pjvb4@ldmartin-desk2 \ --to=lucas.demarchi@intel.com \ --cc=airlied@linux.ie \ --cc=alexander.deucher@amd.com \ --cc=amd-gfx@lists.freedesktop.org \ --cc=andriy.shevchenko@linux.intel.com \ --cc=chris@chris-wilson.co.uk \ --cc=christian.koenig@amd.com \ --cc=daniel@ffwll.ch \ --cc=davem@davemloft.net \ --cc=dri-devel@lists.freedesktop.org \ --cc=eryk.brol@amd.com \ --cc=harry.wentland@amd.com \ --cc=intel-gfx@lists.freedesktop.org \ --cc=jani.nikula@linux.intel.com \ --cc=joonas.lahtinen@linux.intel.com \ --cc=kuba@kernel.org \ --cc=laniel_francis@privacyrequired.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mikita.lipski@amd.com \ --cc=netdev@vger.kernel.org \ --cc=rahul.lakkireddy@chelsio.com \ --cc=rajur@chelsio.com \ --cc=rodrigo.vivi@intel.com \ --cc=sunpeng.li@amd.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.