Currently, debugfs functions are using symbolic macros as permission
bits, but checkpatch reinforces permission bits in the octal form, as
they are more readable and easier to understand [1].
Therefore, use octal permission bits in all debugfs functions.
[1] https://docs.kernel.org/dev-tools/checkpatch.html#permissions
Suggested-by: Jani Nikula <[email protected]>
Signed-off-by: Maíra Canal <[email protected]>
---
drivers/gpu/drm/drm_debugfs.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 5ea237839439..4f643a490dc3 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -207,7 +207,7 @@ void drm_debugfs_create_files(const struct drm_info_list *files, int count,
tmp->minor = minor;
tmp->dent = debugfs_create_file(files[i].name,
- S_IFREG | S_IRUGO, root, tmp,
+ 0444, root, tmp,
&drm_debugfs_fops);
tmp->info_ent = &files[i];
@@ -246,7 +246,7 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
dev->driver->debugfs_init(minor);
list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
- debugfs_create_file(entry->file.name, S_IFREG | S_IRUGO,
+ debugfs_create_file(entry->file.name, 0444,
minor->debugfs_root, entry, &drm_debugfs_entry_fops);
list_del(&entry->list);
}
@@ -263,7 +263,7 @@ void drm_debugfs_late_register(struct drm_device *dev)
return;
list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
- debugfs_create_file(entry->file.name, S_IFREG | S_IRUGO,
+ debugfs_create_file(entry->file.name, 0444,
minor->debugfs_root, entry, &drm_debugfs_entry_fops);
list_del(&entry->list);
}
@@ -508,15 +508,15 @@ void drm_debugfs_connector_add(struct drm_connector *connector)
connector->debugfs_entry = root;
/* force */
- debugfs_create_file("force", S_IRUGO | S_IWUSR, root, connector,
+ debugfs_create_file("force", 0644, root, connector,
&drm_connector_fops);
/* edid */
- debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, connector,
+ debugfs_create_file("edid_override", 0644, root, connector,
&drm_edid_fops);
/* vrr range */
- debugfs_create_file("vrr_range", S_IRUGO, root, connector,
+ debugfs_create_file("vrr_range", 0444, root, connector,
&vrr_range_fops);
/* max bpc */
--
2.39.0
The structs drm_debugfs_info and drm_debugfs_entry don't have
descriptions for their parameters, which is causing the following warnings:
include/drm/drm_debugfs.h:93: warning: Function parameter or member
'name' not described in 'drm_debugfs_info'
include/drm/drm_debugfs.h:93: warning: Function parameter or member
'show' not described in 'drm_debugfs_info'
include/drm/drm_debugfs.h:93: warning: Function parameter or member
'driver_features' not described in 'drm_debugfs_info'
include/drm/drm_debugfs.h:93: warning: Function parameter or member
'data' not described in 'drm_debugfs_info'
include/drm/drm_debugfs.h:105: warning: Function parameter or member
'dev' not described in 'drm_debugfs_entry'
include/drm/drm_debugfs.h:105: warning: Function parameter or member
'file' not described in 'drm_debugfs_entry'
include/drm/drm_debugfs.h:105: warning: Function parameter or member
'list' not described in 'drm_debugfs_entry'
Therefore, fix the warnings by adding descriptions to all struct
parameters.
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: Maíra Canal <[email protected]>
---
include/drm/drm_debugfs.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h
index 53b7297260a5..7616f457ce70 100644
--- a/include/drm/drm_debugfs.h
+++ b/include/drm/drm_debugfs.h
@@ -86,9 +86,22 @@ struct drm_info_node {
* core.
*/
struct drm_debugfs_info {
+ /** @name: File name */
const char *name;
+
+ /**
+ * @show:
+ *
+ * Show callback. &seq_file->private will be set to the &struct
+ * drm_debugfs_entry corresponding to the instance of this info
+ * on a given &struct drm_device.
+ */
int (*show)(struct seq_file*, void*);
+
+ /** @driver_features: Required driver features for this entry. */
u32 driver_features;
+
+ /** @data: Driver-private data, should not be device-specific. */
void *data;
};
@@ -99,8 +112,13 @@ struct drm_debugfs_info {
* drm_debugfs_info on a &struct drm_device.
*/
struct drm_debugfs_entry {
+ /** @dev: &struct drm_device for this node. */
struct drm_device *dev;
+
+ /** @file: Template for this node. */
struct drm_debugfs_info file;
+
+ /** @list: Linked list of all device nodes. */
struct list_head list;
};
--
2.39.0
On Thu, Jan 05, 2023 at 04:30:39PM -0300, Ma?ra Canal wrote:
> The structs drm_debugfs_info and drm_debugfs_entry don't have
> descriptions for their parameters, which is causing the following warnings:
>
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'name' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'show' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'driver_features' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'data' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:105: warning: Function parameter or member
> 'dev' not described in 'drm_debugfs_entry'
> include/drm/drm_debugfs.h:105: warning: Function parameter or member
> 'file' not described in 'drm_debugfs_entry'
> include/drm/drm_debugfs.h:105: warning: Function parameter or member
> 'list' not described in 'drm_debugfs_entry'
>
> Therefore, fix the warnings by adding descriptions to all struct
> parameters.
>
> Reported-by: Stephen Rothwell <[email protected]>
> Signed-off-by: Ma?ra Canal <[email protected]>
> ---
> include/drm/drm_debugfs.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h
> index 53b7297260a5..7616f457ce70 100644
> --- a/include/drm/drm_debugfs.h
> +++ b/include/drm/drm_debugfs.h
> @@ -86,9 +86,22 @@ struct drm_info_node {
> * core.
> */
> struct drm_debugfs_info {
> + /** @name: File name */
> const char *name;
> +
> + /**
> + * @show:
> + *
> + * Show callback. &seq_file->private will be set to the &struct
> + * drm_debugfs_entry corresponding to the instance of this info
> + * on a given &struct drm_device.
So this is a bit late, but why don't we pass that drm_debugfs_entry as an
explicit parameter? Or maybe just the struct drm_device, because that and
the void *data is really all there is to pass along. Would give us more
type-safety, which really is the main reason for having drm-specific
debugfs functions.
Either way, on the series: Reviewed-by: Daniel Vetter <[email protected]>
> + */
> int (*show)(struct seq_file*, void*);
> +
> + /** @driver_features: Required driver features for this entry. */
> u32 driver_features;
> +
> + /** @data: Driver-private data, should not be device-specific. */
> void *data;
> };
>
> @@ -99,8 +112,13 @@ struct drm_debugfs_info {
> * drm_debugfs_info on a &struct drm_device.
> */
> struct drm_debugfs_entry {
> + /** @dev: &struct drm_device for this node. */
> struct drm_device *dev;
> +
> + /** @file: Template for this node. */
> struct drm_debugfs_info file;
> +
> + /** @list: Linked list of all device nodes. */
> struct list_head list;
> };
>
> --
> 2.39.0
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
On Thu, 05 Jan 2023, Maíra Canal <[email protected]> wrote:
> Currently, debugfs functions are using symbolic macros as permission
> bits, but checkpatch reinforces permission bits in the octal form, as
> they are more readable and easier to understand [1].
>
> Therefore, use octal permission bits in all debugfs functions.
>
> [1] https://docs.kernel.org/dev-tools/checkpatch.html#permissions
>
> Suggested-by: Jani Nikula <[email protected]>
> Signed-off-by: Maíra Canal <[email protected]>
The commit message should also mention S_IFREG is redundant. Can be
fixed while applying.
Reviewed-by: Jani Nikula <[email protected]>
> ---
> drivers/gpu/drm/drm_debugfs.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index 5ea237839439..4f643a490dc3 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -207,7 +207,7 @@ void drm_debugfs_create_files(const struct drm_info_list *files, int count,
>
> tmp->minor = minor;
> tmp->dent = debugfs_create_file(files[i].name,
> - S_IFREG | S_IRUGO, root, tmp,
> + 0444, root, tmp,
> &drm_debugfs_fops);
> tmp->info_ent = &files[i];
>
> @@ -246,7 +246,7 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
> dev->driver->debugfs_init(minor);
>
> list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
> - debugfs_create_file(entry->file.name, S_IFREG | S_IRUGO,
> + debugfs_create_file(entry->file.name, 0444,
> minor->debugfs_root, entry, &drm_debugfs_entry_fops);
> list_del(&entry->list);
> }
> @@ -263,7 +263,7 @@ void drm_debugfs_late_register(struct drm_device *dev)
> return;
>
> list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
> - debugfs_create_file(entry->file.name, S_IFREG | S_IRUGO,
> + debugfs_create_file(entry->file.name, 0444,
> minor->debugfs_root, entry, &drm_debugfs_entry_fops);
> list_del(&entry->list);
> }
> @@ -508,15 +508,15 @@ void drm_debugfs_connector_add(struct drm_connector *connector)
> connector->debugfs_entry = root;
>
> /* force */
> - debugfs_create_file("force", S_IRUGO | S_IWUSR, root, connector,
> + debugfs_create_file("force", 0644, root, connector,
> &drm_connector_fops);
>
> /* edid */
> - debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, connector,
> + debugfs_create_file("edid_override", 0644, root, connector,
> &drm_edid_fops);
>
> /* vrr range */
> - debugfs_create_file("vrr_range", S_IRUGO, root, connector,
> + debugfs_create_file("vrr_range", 0444, root, connector,
> &vrr_range_fops);
>
> /* max bpc */
--
Jani Nikula, Intel Open Source Graphics Center
On 1/6/23 17:19, Daniel Vetter wrote:
> On Thu, Jan 05, 2023 at 04:30:39PM -0300, Maíra Canal wrote:
>> The structs drm_debugfs_info and drm_debugfs_entry don't have
>> descriptions for their parameters, which is causing the following warnings:
>>
>> include/drm/drm_debugfs.h:93: warning: Function parameter or member
>> 'name' not described in 'drm_debugfs_info'
>> include/drm/drm_debugfs.h:93: warning: Function parameter or member
>> 'show' not described in 'drm_debugfs_info'
>> include/drm/drm_debugfs.h:93: warning: Function parameter or member
>> 'driver_features' not described in 'drm_debugfs_info'
>> include/drm/drm_debugfs.h:93: warning: Function parameter or member
>> 'data' not described in 'drm_debugfs_info'
>> include/drm/drm_debugfs.h:105: warning: Function parameter or member
>> 'dev' not described in 'drm_debugfs_entry'
>> include/drm/drm_debugfs.h:105: warning: Function parameter or member
>> 'file' not described in 'drm_debugfs_entry'
>> include/drm/drm_debugfs.h:105: warning: Function parameter or member
>> 'list' not described in 'drm_debugfs_entry'
>>
>> Therefore, fix the warnings by adding descriptions to all struct
>> parameters.
>>
>> Reported-by: Stephen Rothwell <[email protected]>
>> Signed-off-by: Maíra Canal <[email protected]>
>> ---
>> include/drm/drm_debugfs.h | 18 ++++++++++++++++++
>> 1 file changed, 18 insertions(+)
>>
>> diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h
>> index 53b7297260a5..7616f457ce70 100644
>> --- a/include/drm/drm_debugfs.h
>> +++ b/include/drm/drm_debugfs.h
>> @@ -86,9 +86,22 @@ struct drm_info_node {
>> * core.
>> */
>> struct drm_debugfs_info {
>> + /** @name: File name */
>> const char *name;
>> +
>> + /**
>> + * @show:
>> + *
>> + * Show callback. &seq_file->private will be set to the &struct
>> + * drm_debugfs_entry corresponding to the instance of this info
>> + * on a given &struct drm_device.
>
> So this is a bit late, but why don't we pass that drm_debugfs_entry as an
> explicit parameter? Or maybe just the struct drm_device, because that and
> the void *data is really all there is to pass along. Would give us more
> type-safety, which really is the main reason for having drm-specific
> debugfs functions.
It seems like a better idea to pass the drm_debugfs_entry as an explicit
parameter. I can work on it, but I guess it is a better idea to finish
the conversion of all drm_debugfs_create_files() to drm_debugfs_add_files()
and then perform the change in the show() signature.
Best Regards,
- Maíra Canal
>
> Either way, on the series: Reviewed-by: Daniel Vetter <[email protected]>
>
>> + */
>> int (*show)(struct seq_file*, void*);
>> +
>> + /** @driver_features: Required driver features for this entry. */
>> u32 driver_features;
>> +
>> + /** @data: Driver-private data, should not be device-specific. */
>> void *data;
>> };
>>
>> @@ -99,8 +112,13 @@ struct drm_debugfs_info {
>> * drm_debugfs_info on a &struct drm_device.
>> */
>> struct drm_debugfs_entry {
>> + /** @dev: &struct drm_device for this node. */
>> struct drm_device *dev;
>> +
>> + /** @file: Template for this node. */
>> struct drm_debugfs_info file;
>> +
>> + /** @list: Linked list of all device nodes. */
>> struct list_head list;
>> };
>>
>> --
>> 2.39.0
>>
>
On 1/5/23 16:30, Maíra Canal wrote:
> The structs drm_debugfs_info and drm_debugfs_entry don't have
> descriptions for their parameters, which is causing the following warnings:
>
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'name' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'show' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'driver_features' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:93: warning: Function parameter or member
> 'data' not described in 'drm_debugfs_info'
> include/drm/drm_debugfs.h:105: warning: Function parameter or member
> 'dev' not described in 'drm_debugfs_entry'
> include/drm/drm_debugfs.h:105: warning: Function parameter or member
> 'file' not described in 'drm_debugfs_entry'
> include/drm/drm_debugfs.h:105: warning: Function parameter or member
> 'list' not described in 'drm_debugfs_entry'
>
> Therefore, fix the warnings by adding descriptions to all struct
> parameters.
>
> Reported-by: Stephen Rothwell <[email protected]>
> Signed-off-by: Maíra Canal <[email protected]>
Applied series to drm-misc-next.
Best Regards,
- Maíra Canal
> ---
> include/drm/drm_debugfs.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h
> index 53b7297260a5..7616f457ce70 100644
> --- a/include/drm/drm_debugfs.h
> +++ b/include/drm/drm_debugfs.h
> @@ -86,9 +86,22 @@ struct drm_info_node {
> * core.
> */
> struct drm_debugfs_info {
> + /** @name: File name */
> const char *name;
> +
> + /**
> + * @show:
> + *
> + * Show callback. &seq_file->private will be set to the &struct
> + * drm_debugfs_entry corresponding to the instance of this info
> + * on a given &struct drm_device.
> + */
> int (*show)(struct seq_file*, void*);
> +
> + /** @driver_features: Required driver features for this entry. */
> u32 driver_features;
> +
> + /** @data: Driver-private data, should not be device-specific. */
> void *data;
> };
>
> @@ -99,8 +112,13 @@ struct drm_debugfs_info {
> * drm_debugfs_info on a &struct drm_device.
> */
> struct drm_debugfs_entry {
> + /** @dev: &struct drm_device for this node. */
> struct drm_device *dev;
> +
> + /** @file: Template for this node. */
> struct drm_debugfs_info file;
> +
> + /** @list: Linked list of all device nodes. */
> struct list_head list;
> };
>
On Mon, Jan 09, 2023 at 08:28:20AM -0300, Ma?ra Canal wrote:
> On 1/6/23 17:19, Daniel Vetter wrote:
> > On Thu, Jan 05, 2023 at 04:30:39PM -0300, Ma?ra Canal wrote:
> > > The structs drm_debugfs_info and drm_debugfs_entry don't have
> > > descriptions for their parameters, which is causing the following warnings:
> > >
> > > include/drm/drm_debugfs.h:93: warning: Function parameter or member
> > > 'name' not described in 'drm_debugfs_info'
> > > include/drm/drm_debugfs.h:93: warning: Function parameter or member
> > > 'show' not described in 'drm_debugfs_info'
> > > include/drm/drm_debugfs.h:93: warning: Function parameter or member
> > > 'driver_features' not described in 'drm_debugfs_info'
> > > include/drm/drm_debugfs.h:93: warning: Function parameter or member
> > > 'data' not described in 'drm_debugfs_info'
> > > include/drm/drm_debugfs.h:105: warning: Function parameter or member
> > > 'dev' not described in 'drm_debugfs_entry'
> > > include/drm/drm_debugfs.h:105: warning: Function parameter or member
> > > 'file' not described in 'drm_debugfs_entry'
> > > include/drm/drm_debugfs.h:105: warning: Function parameter or member
> > > 'list' not described in 'drm_debugfs_entry'
> > >
> > > Therefore, fix the warnings by adding descriptions to all struct
> > > parameters.
> > >
> > > Reported-by: Stephen Rothwell <[email protected]>
> > > Signed-off-by: Ma?ra Canal <[email protected]>
> > > ---
> > > include/drm/drm_debugfs.h | 18 ++++++++++++++++++
> > > 1 file changed, 18 insertions(+)
> > >
> > > diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h
> > > index 53b7297260a5..7616f457ce70 100644
> > > --- a/include/drm/drm_debugfs.h
> > > +++ b/include/drm/drm_debugfs.h
> > > @@ -86,9 +86,22 @@ struct drm_info_node {
> > > * core.
> > > */
> > > struct drm_debugfs_info {
> > > + /** @name: File name */
> > > const char *name;
> > > +
> > > + /**
> > > + * @show:
> > > + *
> > > + * Show callback. &seq_file->private will be set to the &struct
> > > + * drm_debugfs_entry corresponding to the instance of this info
> > > + * on a given &struct drm_device.
> >
> > So this is a bit late, but why don't we pass that drm_debugfs_entry as an
> > explicit parameter? Or maybe just the struct drm_device, because that and
> > the void *data is really all there is to pass along. Would give us more
> > type-safety, which really is the main reason for having drm-specific
> > debugfs functions.
>
> It seems like a better idea to pass the drm_debugfs_entry as an explicit
> parameter. I can work on it, but I guess it is a better idea to finish
> the conversion of all drm_debugfs_create_files() to drm_debugfs_add_files()
> and then perform the change in the show() signature.
So drm_debugfs_entry still feels like a bit too high level, do callers
really need that? They get the void * and I guess need the struct
drm_device *
This really starts to matter more when we also roll this out for
connector/crtc, then you can give them directly a pointer to that. And the
drm_debugfs_entry thing becomes an implementation detail entirely.
Or do I miss something?
Also yes we can do that later on, it shouldn't be too annyoing to roll
out.
-Daniel
>
> Best Regards,
> - Ma?ra Canal
>
> >
> > Either way, on the series: Reviewed-by: Daniel Vetter <[email protected]>
> >
> > > + */
> > > int (*show)(struct seq_file*, void*);
> > > +
> > > + /** @driver_features: Required driver features for this entry. */
> > > u32 driver_features;
> > > +
> > > + /** @data: Driver-private data, should not be device-specific. */
> > > void *data;
> > > };
> > > @@ -99,8 +112,13 @@ struct drm_debugfs_info {
> > > * drm_debugfs_info on a &struct drm_device.
> > > */
> > > struct drm_debugfs_entry {
> > > + /** @dev: &struct drm_device for this node. */
> > > struct drm_device *dev;
> > > +
> > > + /** @file: Template for this node. */
> > > struct drm_debugfs_info file;
> > > +
> > > + /** @list: Linked list of all device nodes. */
> > > struct list_head list;
> > > };
> > > --
> > > 2.39.0
> > >
> >
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch