From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-15 14:24:17
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.
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(-)
@@ -49,11 +50,6 @@ struct dmub_debugfs_trace_entry {uint32_tparam1;};-staticinlineconstchar*yesno(boolv)-{-returnv?"yes":"no";-}-/* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array**Functiontakesinattributespassedtodebugfswriteentry
@@ -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-*argumentisnon-zero.-*/-staticconstchar*yesno(intx)-{-staticconstchar*yes="yes";-staticconstchar*no="no";--returnx?yes:no;-}-staticintrss_config_show(structseq_file*seq,void*v){structadapter*adapter=seq->private;
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-15 14:24:17
We have already an implementation and a lot of code that can benefit
of the onoff() helper. Move it under string.h hood.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpu/drm/i915/i915_utils.h | 5 -----
include/linux/string.h | 5 +++++
2 files changed, 5 insertions(+), 5 deletions(-)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-15 14:24:44
We have already an implementation and a lot of code that can benefit
of the enableddisabled() helper. Move it under string.h hood.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpu/drm/i915/i915_utils.h | 5 -----
include/linux/string.h | 5 +++++
2 files changed, 5 insertions(+), 5 deletions(-)
From: Christian König <christian.koenig@amd.com> Date: 2021-02-15 14:27:40
Am 15.02.21 um 15:21 schrieb Andy Shevchenko:
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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Looks like a good idea to me, feel free to add an Acked-by: Christian
König [off-list ref] to the series.
But looking at the use cases for this, wouldn't it make more sense to
teach kprintf some new format modifier for this?
Christian.
@@ -49,11 +50,6 @@ struct dmub_debugfs_trace_entry {uint32_tparam1;};-staticinlineconstchar*yesno(boolv)-{-returnv?"yes":"no";-}-/* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array**Functiontakesinattributespassedtodebugfswriteentry
@@ -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-*argumentisnon-zero.-*/-staticconstchar*yesno(intx)-{-staticconstchar*yes="yes";-staticconstchar*no="no";--returnx?yes:no;-}-staticintrss_config_show(structseq_file*seq,void*v){structadapter*adapter=seq->private;
@@ -49,11 +50,6 @@ struct dmub_debugfs_trace_entry {uint32_tparam1;};-staticinlineconstchar*yesno(boolv)-{-returnv?"yes":"no";-}-/* parse_write_buffer_into_params - Helper function to parse debugfs write buffer into an array**Functiontakesinattributespassedtodebugfswriteentry
@@ -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-*argumentisnon-zero.-*/-staticconstchar*yesno(intx)-{-staticconstchar*yes="yes";-staticconstchar*no="no";--returnx?yes:no;-}-staticintrss_config_show(structseq_file*seq,void*v){structadapter*adapter=seq->private;
From: Andy Shevchenko <hidden> Date: 2021-02-15 14:40:59
+Cc: Sakari and printk people
On Mon, Feb 15, 2021 at 4:28 PM Christian König
[off-list ref] wrote:
Am 15.02.21 um 15:21 schrieb Andy Shevchenko:
quoted
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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Looks like a good idea to me, feel free to add an Acked-by: Christian
König [off-list ref] to the series.
Thanks.
But looking at the use cases for this, wouldn't it make more sense to
teach kprintf some new format modifier for this?
As a next step? IIRC Sakari has at some point the series converted
yesno and Co. to something which I don't remember the details of.
Guys, what do you think?
--
With Best Regards,
Andy Shevchenko
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-02-15 17:13:24
On Mon, Feb 15, 2021 at 04:37:50PM +0200, Jani Nikula wrote:
On Mon, 15 Feb 2021, Andy Shevchenko [off-list ref] wrote:
quoted
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]
Thanks for a pointer! I like your version, but here we also discussing a
possibility to do something like %py[DOY]. It will consolidate all those RO or
whatever sections inside one data structure.
From: Petr Mladek <pmladek@suse.com> Date: 2021-02-17 12:46:54
On Mon 2021-02-15 16:39:26, Andy Shevchenko wrote:
+Cc: Sakari and printk people
On Mon, Feb 15, 2021 at 4:28 PM Christian König
[off-list ref] wrote:
quoted
Am 15.02.21 um 15:21 schrieb Andy Shevchenko:
quoted
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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Looks like a good idea to me, feel free to add an Acked-by: Christian
König [off-list ref] to the series.
Thanks.
quoted
But looking at the use cases for this, wouldn't it make more sense to
teach kprintf some new format modifier for this?
As a next step? IIRC Sakari has at some point the series converted
yesno and Co. to something which I don't remember the details of.
Guys, what do you think?
Honestly, I think that yesno() is much easier to understand than %py.
And %py[DOY] looks really scary. It has been suggested at
https://lore.kernel.org/lkml/YCqaNnr7ynRydczE@smile.fi.intel.com/#t
Yes, enabledisable() is hard to parse but it is still self-explaining
and can be found easily by cscope. On the contrary, %pyD will likely
print some python code and it is not clear if it would be compatible
with v3. I am just kidding but you get the picture.
Best Regards,
Petr
From: Jani Nikula <jani.nikula@linux.intel.com> Date: 2021-02-17 17:14:10
On Wed, 17 Feb 2021, Petr Mladek [off-list ref] wrote:
On Mon 2021-02-15 16:39:26, Andy Shevchenko wrote:
quoted
+Cc: Sakari and printk people
On Mon, Feb 15, 2021 at 4:28 PM Christian König
[off-list ref] wrote:
quoted
Am 15.02.21 um 15:21 schrieb Andy Shevchenko:
quoted
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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Looks like a good idea to me, feel free to add an Acked-by: Christian
König [off-list ref] to the series.
Thanks.
quoted
But looking at the use cases for this, wouldn't it make more sense to
teach kprintf some new format modifier for this?
As a next step? IIRC Sakari has at some point the series converted
yesno and Co. to something which I don't remember the details of.
Guys, what do you think?
Honestly, I think that yesno() is much easier to understand than %py.
And %py[DOY] looks really scary. It has been suggested at
https://lore.kernel.org/lkml/YCqaNnr7ynRydczE@smile.fi.intel.com/#t
Yes, enabledisable() is hard to parse but it is still self-explaining
and can be found easily by cscope. On the contrary, %pyD will likely
print some python code and it is not clear if it would be compatible
with v3. I am just kidding but you get the picture.
Personally I prefer %s and the functions.
I think the format specifiers have become unwieldy. I don't remember any
of the kernel specific ones by heart, I always look them up or just
cargo-cult. I think the fourcc format specifiers are a nice cleanup, but
I don't remember them either. I'd like something like %foo{yesno} where,
if you remember the %foo part, you could actually also remember the
rest.
But really if you get *any* version accepted, I'm not going to argue
against it, and you can disregard this as meaningless bikeshedding.
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
From: Lucas De Marchi <hidden> Date: 2021-10-05 21:34:30
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
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-11-15 11:08:06
On Tue, Oct 05, 2021 at 02:34:23PM -0700, Lucas De Marchi wrote:
On Mon, Feb 15, 2021 at 04:21:35PM +0200, Andy Shevchenko wrote:
quoted
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.
Seems reasonable to use string_helpers (headers and/or C-file).
After reading the threads, I don't see real opposition to it.
Is there a tree you plan to take this through?
I rest my series in favour of Jani's approach, so I suppose there is no go
for _this_ series.
From: Jani Nikula <jani.nikula@linux.intel.com> Date: 2021-11-15 11:43:23
On Mon, 15 Nov 2021, Andy Shevchenko [off-list ref] wrote:
On Tue, Oct 05, 2021 at 02:34:23PM -0700, Lucas De Marchi wrote:
quoted
On Mon, Feb 15, 2021 at 04:21:35PM +0200, Andy Shevchenko wrote:
quoted
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.
Seems reasonable to use string_helpers (headers and/or C-file).
quoted
After reading the threads, I don't see real opposition to it.
Is there a tree you plan to take this through?
I rest my series in favour of Jani's approach, so I suppose there is no go
for _this_ series.
If you want to make it happen, please pick it up and drive it. I'm
thoroughly had enough of this.
BR,
Jani.
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2021-11-15 14:24:01
On Mon, Nov 15, 2021 at 01:43:02PM +0200, Jani Nikula wrote:
On Mon, 15 Nov 2021, Andy Shevchenko [off-list ref] wrote:
quoted
On Tue, Oct 05, 2021 at 02:34:23PM -0700, Lucas De Marchi wrote:
quoted
On Mon, Feb 15, 2021 at 04:21:35PM +0200, Andy Shevchenko wrote:
quoted
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.
Seems reasonable to use string_helpers (headers and/or C-file).
quoted
After reading the threads, I don't see real opposition to it.
Is there a tree you plan to take this through?
I rest my series in favour of Jani's approach, so I suppose there is no go
for _this_ series.
If you want to make it happen, please pick it up and drive it. I'm
thoroughly had enough of this.
My point is still the same, so it's more to Lucas.
I'm not going to drive this activity due to lack of time.