public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] EDAC: constantify the struct bus_type usage
@ 2023-12-19 13:13 Greg Kroah-Hartman
  2023-12-28 15:00 ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-12-19 13:13 UTC (permalink / raw)
  To: bp, tony.luck
  Cc: linux-kernel, Greg Kroah-Hartman, James Morse,
	Mauro Carvalho Chehab, Robert Richter, linux-edac

In many places in the edac code, struct bus_type pointers are passed
around and then eventually sent to the driver core, which can handle a
constant pointer.  So constantify all of the edac usage of these as well
because the data in them is never modified by the edac code either.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Robert Richter <rric@kernel.org>
Cc: linux-edac@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/edac/edac_device.h       | 2 +-
 drivers/edac/edac_device_sysfs.c | 2 +-
 drivers/edac/edac_module.c       | 4 ++--
 drivers/edac/edac_pci_sysfs.c    | 2 +-
 include/linux/edac.h             | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/edac/edac_device.h b/drivers/edac/edac_device.h
index 3f44e6b9d387..7db22a4c83ef 100644
--- a/drivers/edac/edac_device.h
+++ b/drivers/edac/edac_device.h
@@ -176,7 +176,7 @@ struct edac_device_ctl_info {
 	struct edac_dev_sysfs_attribute *sysfs_attributes;
 
 	/* pointer to main 'edac' subsys in sysfs */
-	struct bus_type *edac_subsys;
+	const struct bus_type *edac_subsys;
 
 	/* the internal state of this controller instance */
 	int op_state;
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 010c26be5846..237a542e045a 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -229,7 +229,7 @@ static struct kobj_type ktype_device_ctrl = {
 int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
 {
 	struct device *dev_root;
-	struct bus_type *edac_subsys;
+	const struct bus_type *edac_subsys;
 	int err = -ENODEV;
 
 	edac_dbg(1, "\n");
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index 32a931d0cb71..1c9f62382666 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -67,7 +67,7 @@ char *edac_op_state_to_string(int opstate)
  * sysfs object: /sys/devices/system/edac
  *	need to export to other files
  */
-static struct bus_type edac_subsys = {
+static const struct bus_type edac_subsys = {
 	.name = "edac",
 	.dev_name = "edac",
 };
@@ -90,7 +90,7 @@ static void edac_subsys_exit(void)
 }
 
 /* return pointer to the 'edac' node in sysfs */
-struct bus_type *edac_get_sysfs_subsys(void)
+const struct bus_type *edac_get_sysfs_subsys(void)
 {
 	return &edac_subsys;
 }
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 287cc51dbc86..e823e4da086a 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -338,7 +338,7 @@ static struct kobj_type ktype_edac_pci_main_kobj = {
 static int edac_pci_main_kobj_setup(void)
 {
 	int err = -ENODEV;
-	struct bus_type *edac_subsys;
+	const struct bus_type *edac_subsys;
 	struct device *dev_root;
 
 	edac_dbg(0, "\n");
diff --git a/include/linux/edac.h b/include/linux/edac.h
index fa4bda2a70f6..ccaf2ae0801d 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -30,7 +30,7 @@ struct device;
 
 extern int edac_op_state;
 
-struct bus_type *edac_get_sysfs_subsys(void);
+const struct bus_type *edac_get_sysfs_subsys(void);
 
 static inline void opstate_init(void)
 {
@@ -492,7 +492,7 @@ struct edac_raw_error_desc {
  */
 struct mem_ctl_info {
 	struct device			dev;
-	struct bus_type			*bus;
+	const struct bus_type		*bus;
 
 	struct list_head link;	/* for global list of mem_ctl_info structs */
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] EDAC: constantify the struct bus_type usage
  2023-12-19 13:13 [PATCH] EDAC: constantify the struct bus_type usage Greg Kroah-Hartman
@ 2023-12-28 15:00 ` Borislav Petkov
  2023-12-29  9:10   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2023-12-28 15:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: tony.luck, linux-kernel, James Morse, Mauro Carvalho Chehab,
	Robert Richter, linux-edac

On Tue, Dec 19, 2023 at 02:13:10PM +0100, Greg Kroah-Hartman wrote:
> In many places in the edac code, struct bus_type pointers are passed
> around and then eventually sent to the driver core, which can handle a
> constant pointer.  So constantify all of the edac usage of these as well
> because the data in them is never modified by the edac code either.

"constantify", huh? Not enough words in the English language so let's do
new ones?

:-)

So what's the plan with this "constantification"?

Because:

drivers/edac/edac_module.c: In function ‘edac_subsys_init’:
drivers/edac/edac_module.c:80:38: warning: passing argument 1 of ‘subsys_system_register’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   80 |         err = subsys_system_register(&edac_subsys, NULL);
      |                                      ^~~~~~~~~~~~
In file included from ./include/linux/edac.h:16,
                 from drivers/edac/edac_module.c:13:
./include/linux/device.h:75:45: note: expected ‘struct bus_type *’ but argument is of type ‘const struct bus_type *’
   75 | int subsys_system_register(struct bus_type *subsys,
      |

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] EDAC: constantify the struct bus_type usage
  2023-12-28 15:00 ` Borislav Petkov
@ 2023-12-29  9:10   ` Greg Kroah-Hartman
  2023-12-29  9:29     ` Borislav Petkov
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-12-29  9:10 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: tony.luck, linux-kernel, James Morse, Mauro Carvalho Chehab,
	Robert Richter, linux-edac

On Thu, Dec 28, 2023 at 04:00:03PM +0100, Borislav Petkov wrote:
> On Tue, Dec 19, 2023 at 02:13:10PM +0100, Greg Kroah-Hartman wrote:
> > In many places in the edac code, struct bus_type pointers are passed
> > around and then eventually sent to the driver core, which can handle a
> > constant pointer.  So constantify all of the edac usage of these as well
> > because the data in them is never modified by the edac code either.
> 
> "constantify", huh? Not enough words in the English language so let's do
> new ones?
> 
> :-)

Hey, we could be using German and then it would be something like
"Konstantifizierung" :)

> So what's the plan with this "constantification"?
> 
> Because:
> 
> drivers/edac/edac_module.c: In function ‘edac_subsys_init’:
> drivers/edac/edac_module.c:80:38: warning: passing argument 1 of ‘subsys_system_register’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>    80 |         err = subsys_system_register(&edac_subsys, NULL);
>       |                                      ^~~~~~~~~~~~
> In file included from ./include/linux/edac.h:16,
>                  from drivers/edac/edac_module.c:13:
> ./include/linux/device.h:75:45: note: expected ‘struct bus_type *’ but argument is of type ‘const struct bus_type *’
>    75 | int subsys_system_register(struct bus_type *subsys,
>       |

Ah, oops, that means this depends on a patch in my trees already that
fix this up.  You can wait until after 6.8-rc1 to get to this, or I can
take it in my tree if you want now, which ever is easiest for you.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] EDAC: constantify the struct bus_type usage
  2023-12-29  9:10   ` Greg Kroah-Hartman
@ 2023-12-29  9:29     ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2023-12-29  9:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: tony.luck, linux-kernel, James Morse, Mauro Carvalho Chehab,
	Robert Richter, linux-edac

On Fri, Dec 29, 2023 at 09:10:02AM +0000, Greg Kroah-Hartman wrote:
> Hey, we could be using German and then it would be something like
> "Konstantifizierung" :)

Ewww. Or to say in German: "Oh nee". :-P

Lemme guess, that must sound similar in Dutch. google translate says
"constantificatie". Fun.

> Ah, oops, that means this depends on a patch in my trees already that
> fix this up.  You can wait until after 6.8-rc1 to get to this, or I can
> take it in my tree if you want now, which ever is easiest for you.

Either's fine with me so I leave it up to you.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-29  9:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 13:13 [PATCH] EDAC: constantify the struct bus_type usage Greg Kroah-Hartman
2023-12-28 15:00 ` Borislav Petkov
2023-12-29  9:10   ` Greg Kroah-Hartman
2023-12-29  9:29     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox