Skip to contentSkip to conversation

auxbus: make to_auxiliary_drv accept and return a constant pointer

PATCH In review Greg Kroah-Hartman 5 participants 13 messages Jun 11, 2024 – Jun 12, 2024

Subsystems (13)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/6 auxbus: make to_auxiliary_drv accept and return a constant pointer

In the quest to make struct device constant, start by making to_auziliary_drv() return a constant pointer so that drivers that call this can be fixed up before the driver core changes.

As the return type previously was not constant, also fix up all callers that were assuming that the pointer was not going to be a constant one in order to not break the build.

Cc Greg Kroah-Hartman <[email protected]>
Cc Dave Ertman <[email protected]>
Cc Ira Weiny <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Bingbu Cao <[email protected]>
Cc Tianshu Qiu <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Michael Chan <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Jesse Brandeburg <[email protected]>
Cc Tony Nguyen <[email protected]>
Cc Saeed Mahameed <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Tariq Toukan <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Bard Liao <[email protected]>
Cc Ranjani Sridharan <[email protected]>
Cc Daniel Baluta <[email protected]>
Cc Kai Vehmanen <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Richard Cochran <[email protected]>
---
 drivers/base/auxiliary.c                      | 8 ++++----
 drivers/media/pci/intel/ipu6/ipu6-bus.h       | 2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 4 ++--
 drivers/net/ethernet/intel/ice/ice_ptp.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/dev.c | 4 ++--
 include/linux/auxiliary_bus.h                 | 2 +-
 sound/soc/sof/sof-client.c                    | 4 ++--
 7 files changed, 13 insertions(+), 13 deletions(-)
drivers/base/auxiliary.c +4 -4
index d3a2c40c2f12..5832e31bb77b 100644
@@ -180,7 +180,7 @@ static const struct auxiliary_device_id *auxiliary_match_id(const struct auxilia
 static int auxiliary_match(struct device *dev, struct device_driver *drv)
 {
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
-	struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
+	const struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
 
 	return !!auxiliary_match_id(auxdrv->id_table, auxdev);
 }
@@ -203,7 +203,7 @@ static const struct dev_pm_ops auxiliary_dev_pm_ops = {
 
 static int auxiliary_bus_probe(struct device *dev)
 {
-	struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+	const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
 	int ret;
 
@@ -222,7 +222,7 @@ static int auxiliary_bus_probe(struct device *dev)
 
 static void auxiliary_bus_remove(struct device *dev)
 {
-	struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+	const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
 
 	if (auxdrv->remove)
@@ -232,7 +232,7 @@ static void auxiliary_bus_remove(struct device *dev)
 
 static void auxiliary_bus_shutdown(struct device *dev)
 {
-	struct auxiliary_driver *auxdrv = NULL;
+	const struct auxiliary_driver *auxdrv = NULL;
 	struct auxiliary_device *auxdev;
 
 	if (dev->driver) {
drivers/media/pci/intel/ipu6/ipu6-bus.h +1 -1
index b26c6aee1621..bb4926dfdf08 100644
@@ -21,7 +21,7 @@ struct ipu6_buttress_ctrl;
 
 struct ipu6_bus_device {
 	struct auxiliary_device auxdev;
-	struct auxiliary_driver *auxdrv;
+	const struct auxiliary_driver *auxdrv;
 	const struct ipu6_auxdrv_data *auxdrv_data;
 	struct list_head list;
 	void *pdata;
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +2 -2
index ba3fa1c2e5d9..b9e7d3e7b15d 100644
@@ -239,7 +239,7 @@ void bnxt_ulp_stop(struct bnxt *bp)
 
 		adev = &aux_priv->aux_dev;
 		if (adev->dev.driver) {
-			struct auxiliary_driver *adrv;
+			const struct auxiliary_driver *adrv;
 			pm_message_t pm = {};
 
 			adrv = to_auxiliary_drv(adev->dev.driver);
@@ -277,7 +277,7 @@ void bnxt_ulp_start(struct bnxt *bp, int err)
 
 		adev = &aux_priv->aux_dev;
 		if (adev->dev.driver) {
-			struct auxiliary_driver *adrv;
+			const struct auxiliary_driver *adrv;
 
 			adrv = to_auxiliary_drv(adev->dev.driver);
 			edev->en_state = bp->state;
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
index 0f17fc1181d2..7341e7c4ef24 100644
@@ -2784,7 +2784,7 @@ static struct ice_pf *
 ice_ptp_aux_dev_to_owner_pf(struct auxiliary_device *aux_dev)
 {
 	struct ice_ptp_port_owner *ports_owner;
-	struct auxiliary_driver *aux_drv;
+	const struct auxiliary_driver *aux_drv;
 	struct ice_ptp *owner_ptp;
 
 	if (!aux_dev->dev.driver)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +2 -2
index 47e7c2639774..9a79674d27f1 100644
@@ -349,7 +349,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
 {
 	struct mlx5_priv *priv = &dev->priv;
 	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	int ret = 0, i;
 
 	devl_assert_locked(priv_to_devlink(dev));
@@ -406,7 +406,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev, bool suspend)
 {
 	struct mlx5_priv *priv = &dev->priv;
 	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	pm_message_t pm = {};
 	int i;
 
include/linux/auxiliary_bus.h +1 -1
index de21d9d24a95..bdff7b85f2ae 100644
@@ -203,7 +203,7 @@ static inline struct auxiliary_device *to_auxiliary_dev(struct device *dev)
 	return container_of(dev, struct auxiliary_device, dev);
 }
 
-static inline struct auxiliary_driver *to_auxiliary_drv(struct device_driver *drv)
+static inline const struct auxiliary_driver *to_auxiliary_drv(const struct device_driver *drv)
 {
 	return container_of(drv, struct auxiliary_driver, driver);
 }
sound/soc/sof/sof-client.c +2 -2
index 99f74def4ab6..5d6005a88e79 100644
@@ -357,7 +357,7 @@ EXPORT_SYMBOL_NS_GPL(sof_client_ipc4_find_module, SND_SOC_SOF_CLIENT);
 
 int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state)
 {
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	struct sof_client_dev *cdev;
 
 	mutex_lock(&sdev->ipc_client_mutex);
@@ -380,7 +380,7 @@ EXPORT_SYMBOL_NS_GPL(sof_suspend_clients, SND_SOC_SOF_CLIENT);
 
 int sof_resume_clients(struct snd_sof_dev *sdev)
 {
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	struct sof_client_dev *cdev;
 
 	mutex_lock(&sdev->ipc_client_mutex);
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH 2/6 driver core: platform: fix ups for constant struct device_driver

Fix up a few places in the platform core code that can easily handle struct device_driver being constant. This is part of the work to make all struct device_driver pointers be constant.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/platform.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/base/platform.c +6 -6
index c8aa1be70526..a6884479f4ac 100644
@@ -1122,7 +1122,7 @@ static int platform_legacy_resume(struct device *dev)
 
 int platform_pm_suspend(struct device *dev)
 {
-	struct device_driver *drv = dev->driver;
+	const struct device_driver *drv = dev->driver;
 	int ret = 0;
 
 	if (!drv)
@@ -1140,7 +1140,7 @@ int platform_pm_suspend(struct device *dev)
 
 int platform_pm_resume(struct device *dev)
 {
-	struct device_driver *drv = dev->driver;
+	const struct device_driver *drv = dev->driver;
 	int ret = 0;
 
 	if (!drv)
@@ -1162,7 +1162,7 @@ int platform_pm_resume(struct device *dev)
 
 int platform_pm_freeze(struct device *dev)
 {
-	struct device_driver *drv = dev->driver;
+	const struct device_driver *drv = dev->driver;
 	int ret = 0;
 
 	if (!drv)
@@ -1180,7 +1180,7 @@ int platform_pm_freeze(struct device *dev)
 
 int platform_pm_thaw(struct device *dev)
 {
-	struct device_driver *drv = dev->driver;
+	const struct device_driver *drv = dev->driver;
 	int ret = 0;
 
 	if (!drv)
@@ -1198,7 +1198,7 @@ int platform_pm_thaw(struct device *dev)
 
 int platform_pm_poweroff(struct device *dev)
 {
-	struct device_driver *drv = dev->driver;
+	const struct device_driver *drv = dev->driver;
 	int ret = 0;
 
 	if (!drv)
@@ -1216,7 +1216,7 @@ int platform_pm_poweroff(struct device *dev)
 
 int platform_pm_restore(struct device *dev)
 {
-	struct device_driver *drv = dev->driver;
+	const struct device_driver *drv = dev->driver;
 	int ret = 0;
 
 	if (!drv)
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

PATCH 3/6 driver core: driver: mark driver_add/remove_groups constant

In reply to Greg Kroah-Hartman

driver_add_groups() and driver_remove_groups should take a constant pointer as the structure is not modified, so make the change.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/base.h   | 4 ++--
 drivers/base/driver.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/base/base.h +2 -2
index db4f910e8e36..cba8307908c7 100644
@@ -175,8 +175,8 @@ static inline void dev_sync_state(struct device *dev)
 		dev->driver->sync_state(dev);
 }
 
-int driver_add_groups(struct device_driver *drv, const struct attribute_group **groups);
-void driver_remove_groups(struct device_driver *drv, const struct attribute_group **groups);
+int driver_add_groups(const struct device_driver *drv, const struct attribute_group **groups);
+void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups);
 void device_driver_detach(struct device *dev);
 
 int devres_release_all(struct device *dev);
drivers/base/driver.c +2 -2
index c8436c26ed6a..85b4c00df078 100644
@@ -199,13 +199,13 @@ void driver_remove_file(struct device_driver *drv,
 }
 EXPORT_SYMBOL_GPL(driver_remove_file);
 
-int driver_add_groups(struct device_driver *drv,
+int driver_add_groups(const struct device_driver *drv,
 		      const struct attribute_group **groups)
 {
 	return sysfs_create_groups(&drv->p->kobj, groups);
 }
 
-void driver_remove_groups(struct device_driver *drv,
+void driver_remove_groups(const struct device_driver *drv,
 			  const struct attribute_group **groups)
 {
 	sysfs_remove_groups(&drv->p->kobj, groups);
Signature · 1 line
2.45.2
author maintainer
#3 lore raw

PATCH 4/6 driver core: make device_release_driver_internal() take a const *

In reply to Greg Kroah-Hartman

Change device_release_driver_internal() to take a const struct device_driver * as it is not modifying it at all.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/base.h | 2 +-
 drivers/base/dd.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/base.h +1 -1
index cba8307908c7..d332b87cde9e 100644
@@ -155,7 +155,7 @@ bool bus_is_registered(const struct bus_type *bus);
 
 int bus_add_driver(struct device_driver *drv);
 void bus_remove_driver(struct device_driver *drv);
-void device_release_driver_internal(struct device *dev, struct device_driver *drv,
+void device_release_driver_internal(struct device *dev, const struct device_driver *drv,
 				    struct device *parent);
 
 void driver_detach(struct device_driver *drv);
drivers/base/dd.c +1 -1
index 83d352394fdf..c24eca917d41 100644
@@ -1284,7 +1284,7 @@ static void __device_release_driver(struct device *dev, struct device *parent)
 }
 
 void device_release_driver_internal(struct device *dev,
-				    struct device_driver *drv,
+				    const struct device_driver *drv,
 				    struct device *parent)
 {
 	__device_driver_lock(dev, parent);
Signature · 1 line
2.45.2
author maintainer
#4 lore raw

PATCH 5/6 driver core: make driver_detach() take a const *

In reply to Greg Kroah-Hartman

driver_detach() does not modify the driver itself, so make the pointer constant. In doing so, the function driver_allows_async_probing() also needs to be changed so that the pointer type passes through to that function properly.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/base.h | 2 +-
 drivers/base/dd.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/base.h +1 -1
index d332b87cde9e..9df8028c3201 100644
@@ -158,7 +158,7 @@ void bus_remove_driver(struct device_driver *drv);
 void device_release_driver_internal(struct device *dev, const struct device_driver *drv,
 				    struct device *parent);
 
-void driver_detach(struct device_driver *drv);
+void driver_detach(const struct device_driver *drv);
 void driver_deferred_probe_del(struct device *dev);
 void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf);
 static inline int driver_match_device(struct device_driver *drv,
drivers/base/dd.c +2 -2
index c24eca917d41..76b26096b033 100644
@@ -863,7 +863,7 @@ static int __init save_async_options(char *buf)
 }
 __setup("driver_async_probe=", save_async_options);
 
-static bool driver_allows_async_probing(struct device_driver *drv)
+static bool driver_allows_async_probing(const struct device_driver *drv)
 {
 	switch (drv->probe_type) {
 	case PROBE_PREFER_ASYNCHRONOUS:
@@ -1333,7 +1333,7 @@ void device_driver_detach(struct device *dev)
  * driver_detach - detach driver from all devices it controls.
  * @drv: driver.
  */
-void driver_detach(struct device_driver *drv)
+void driver_detach(const struct device_driver *drv)
 {
 	struct device_private *dev_prv;
 	struct device *dev;
Signature · 1 line
2.45.2
author maintainer
#5 lore raw

PATCH 6/6 driver core: mark async_driver as a const *

In reply to Greg Kroah-Hartman

Within struct device_private, mark the async_driver * as const as it is never modified. This requires some internal-to-the-driver-core functions to also have their parameters marked as constant, and there is one place where we cast _back_ from the const pointer to a real one, as the driver core still wants to modify the structure in a number of remaining places.

Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/base.h |  2 +-
 drivers/base/dd.c   | 15 ++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/base/base.h +1 -1
index 9df8028c3201..50151e7db796 100644
@@ -112,7 +112,7 @@ struct device_private {
 	struct klist_node knode_bus;
 	struct klist_node knode_class;
 	struct list_head deferred_probe;
-	struct device_driver *async_driver;
+	const struct device_driver *async_driver;
 	char *deferred_probe_reason;
 	struct device *device;
 	u8 dead:1;
drivers/base/dd.c +8 -7
index 76b26096b033..8ec22229e259 100644
@@ -568,7 +568,7 @@ static void device_remove(struct device *dev)
 		dev->driver->remove(dev);
 }
 
-static int call_driver_probe(struct device *dev, struct device_driver *drv)
+static int call_driver_probe(struct device *dev, const struct device_driver *drv)
 {
 	int ret = 0;
 
@@ -599,7 +599,7 @@ static int call_driver_probe(struct device *dev, struct device_driver *drv)
 	return ret;
 }
 
-static int really_probe(struct device *dev, struct device_driver *drv)
+static int really_probe(struct device *dev, const struct device_driver *drv)
 {
 	bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
 			   !drv->suppress_bind_attrs;
@@ -628,7 +628,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 	}
 
 re_probe:
-	dev->driver = drv;
+	// FIXME - this cast should not be needed "soon"
+	dev->driver = (struct device_driver *)drv;
 
 	/* If using pinctrl, bind pins now before probing */
 	ret = pinctrl_bind_pins(dev);
@@ -727,7 +728,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 /*
  * For initcall_debug, show the driver probe time.
  */
-static int really_probe_debug(struct device *dev, struct device_driver *drv)
+static int really_probe_debug(struct device *dev, const struct device_driver *drv)
 {
 	ktime_t calltime, rettime;
 	int ret;
@@ -774,7 +775,7 @@ void wait_for_device_probe(void)
 }
 EXPORT_SYMBOL_GPL(wait_for_device_probe);
 
-static int __driver_probe_device(struct device_driver *drv, struct device *dev)
+static int __driver_probe_device(const struct device_driver *drv, struct device *dev)
 {
 	int ret = 0;
 
@@ -819,7 +820,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev)
  *
  * If the device has a parent, runtime-resume the parent before driver probing.
  */
-static int driver_probe_device(struct device_driver *drv, struct device *dev)
+static int driver_probe_device(const struct device_driver *drv, struct device *dev)
 {
 	int trigger_count = atomic_read(&deferred_trigger_count);
 	int ret;
@@ -1137,7 +1138,7 @@ EXPORT_SYMBOL_GPL(device_driver_attach);
 static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie)
 {
 	struct device *dev = _dev;
-	struct device_driver *drv;
+	const struct device_driver *drv;
 	int ret;
 
 	__device_driver_lock(dev, dev->parent);
Signature · 1 line
2.45.2
author maintainer
#7 lore raw
Quoted 6 lines · Mark Brown
Quoted 3 lines · Greg Kroah-Hartman

In the quest to make struct device constant, start by making to_auziliary_drv() return a constant pointer so that drivers that call this can be fixed up before the driver core changes.

thanks for the review.

maintainer Acked-by on v1 1/6
#8 lore raw
In reply to Greg Kroah-Hartman

Hi Greg,

Quoted 2 lines · Greg Kroah-Hartman

In the quest to make struct device constant, start by making to_auziliary_drv() return a constant pointer so that drivers that call

s/z/s/

Quoted 5 lines

this can be fixed up before the driver core changes.

As the return type previously was not constant, also fix up all callers that were assuming that the pointer was not going to be a constant one in order to not break the build.

Signature · 3 lines
Kind regards,

Sakari Ailus
maintainer
#10 lore raw
In reply to Greg Kroah-Hartman
Quoted 1 line · Greg Kroah-Hartman

In the quest to make struct device constant, start by making

just curious, how far it will go? eg. do you plan to convert get/put_device() to accept const? or convert devlink API to accept consts?

Quoted 1 line

to_auziliary_drv() return a constant pointer so that drivers that call

typo: s/auz/aux/

Quoted 7 lines

this can be fixed up before the driver core changes.

As the return type previously was not constant, also fix up all callers that were assuming that the pointer was not going to be a constant one in order to not break the build.

Cc Greg Kroah-Hartman <[email protected]>

[...]

Quoted 18 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
index 0f17fc1181d2..7341e7c4ef24 100644
@@ -2784,7 +2784,7 @@ static struct ice_pf *
  ice_ptp_aux_dev_to_owner_pf(struct auxiliary_device *aux_dev)
  {
  	struct ice_ptp_port_owner *ports_owner;
-	struct auxiliary_driver *aux_drv;
+	const struct auxiliary_driver *aux_drv;
  	struct ice_ptp *owner_ptp;
 
  	if (!aux_dev->dev.driver)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +0 -0
index 47e7c2639774..9a79674d27f1 100644

drivers/net/ethernet/mellanox/mlx5/core/dev.c int mlx5_attach_device(struct mlx5_core_dev *dev) · line 352

Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/dev.c +1 -1
@@ -349,7 +349,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
  {
  	struct mlx5_priv *priv = &dev->priv;
  	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;

nit: in netdev we do maintain RCT order of initialization

Quoted 12 lines
drivers/net/ethernet/mellanox/mlx5/core/dev.c +1 -1
  	int ret = 0, i;
 
  	devl_assert_locked(priv_to_devlink(dev));
@@ -406,7 +406,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev, bool suspend)
  {
  	struct mlx5_priv *priv = &dev->priv;
  	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
  	pm_message_t pm = {};
  	int i;
 

[...]

author maintainer
#11 lore raw
Quoted 5 lines · Przemek Kitszel
Quoted 1 line · Greg Kroah-Hartman

In the quest to make struct device constant, start by making

just curious, how far it will go? eg. do you plan to convert get/put_device() to accept const?

Ugh, that should have said "in the quest to make struct device_driver const", not device. devices obviously can't be constant everywhere as they are dynamically created.

Quoted 2 lines

or convert devlink API to accept
consts?

Again, sorry, no, typo on my part.

Quoted 4 lines
Quoted 2 lines

to_auziliary_drv() return a constant pointer so that drivers that call

typo: s/auz/aux/

I'll fix this typo up, and the one above, when I commit it.

Quoted 28 lines
Quoted 8 lines

this can be fixed up before the driver core changes.

As the return type previously was not constant, also fix up all callers that were assuming that the pointer was not going to be a constant one in order to not break the build.

Cc Greg Kroah-Hartman <[email protected]>

[...]

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
index 0f17fc1181d2..7341e7c4ef24 100644
@@ -2784,7 +2784,7 @@ static struct ice_pf *
  ice_ptp_aux_dev_to_owner_pf(struct auxiliary_device *aux_dev)
  {
  	struct ice_ptp_port_owner *ports_owner;
-	struct auxiliary_driver *aux_drv;
+	const struct auxiliary_driver *aux_drv;
  	struct ice_ptp *owner_ptp;
  	if (!aux_dev->dev.driver)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +0 -0
index 47e7c2639774..9a79674d27f1 100644
Quoted 8 lines

drivers/net/ethernet/mellanox/mlx5/core/dev.c int mlx5_attach_device(struct mlx5_core_dev *dev) · line 352

Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/dev.c +1 -1
@@ -349,7 +349,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
  {
  	struct mlx5_priv *priv = &dev->priv;
  	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;

nit: in netdev we do maintain RCT order of initialization

what does that mean? Nothing is being initialized here.

thanks,

greg k-h

Reviewed-by on v1 1/6
#12 lore raw
In reply to Greg Kroah-Hartman
Quoted 36 lines · Greg Kroah-Hartman

In the quest to make struct device constant, start by making to_auziliary_drv() return a constant pointer so that drivers that call this can be fixed up before the driver core changes.

As the return type previously was not constant, also fix up all callers that were assuming that the pointer was not going to be a constant one in order to not break the build.

Cc Greg Kroah-Hartman <[email protected]>
Cc Dave Ertman <[email protected]>
Cc Ira Weiny <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Bingbu Cao <[email protected]>
Cc Tianshu Qiu <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Michael Chan <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Jesse Brandeburg <[email protected]>
Cc Tony Nguyen <[email protected]>
Cc Saeed Mahameed <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Tariq Toukan <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Peter Ujfalusi <[email protected]>
Cc Bard Liao <[email protected]>
Cc Ranjani Sridharan <[email protected]>
Cc Daniel Baluta <[email protected]>
Cc Kai Vehmanen <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Quoted 8 lines
Quoted 158 lines
---
 drivers/base/auxiliary.c                      | 8 ++++----
 drivers/media/pci/intel/ipu6/ipu6-bus.h       | 2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 4 ++--
 drivers/net/ethernet/intel/ice/ice_ptp.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/dev.c | 4 ++--
 include/linux/auxiliary_bus.h                 | 2 +-
 sound/soc/sof/sof-client.c                    | 4 ++--
 7 files changed, 13 insertions(+), 13 deletions(-)
drivers/base/auxiliary.c +4 -4
index d3a2c40c2f12..5832e31bb77b 100644
@@ -180,7 +180,7 @@ static const struct auxiliary_device_id *auxiliary_match_id(const struct auxilia
 static int auxiliary_match(struct device *dev, struct device_driver *drv)
 {
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
-	struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
+	const struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
 
 	return !!auxiliary_match_id(auxdrv->id_table, auxdev);
 }
@@ -203,7 +203,7 @@ static const struct dev_pm_ops auxiliary_dev_pm_ops = {
 
 static int auxiliary_bus_probe(struct device *dev)
 {
-	struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+	const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
 	int ret;
 
@@ -222,7 +222,7 @@ static int auxiliary_bus_probe(struct device *dev)
 
 static void auxiliary_bus_remove(struct device *dev)
 {
-	struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+	const struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
 
 	if (auxdrv->remove)
@@ -232,7 +232,7 @@ static void auxiliary_bus_remove(struct device *dev)
 
 static void auxiliary_bus_shutdown(struct device *dev)
 {
-	struct auxiliary_driver *auxdrv = NULL;
+	const struct auxiliary_driver *auxdrv = NULL;
 	struct auxiliary_device *auxdev;
 
 	if (dev->driver) {
drivers/media/pci/intel/ipu6/ipu6-bus.h +1 -1
index b26c6aee1621..bb4926dfdf08 100644
@@ -21,7 +21,7 @@ struct ipu6_buttress_ctrl;
 
 struct ipu6_bus_device {
 	struct auxiliary_device auxdev;
-	struct auxiliary_driver *auxdrv;
+	const struct auxiliary_driver *auxdrv;
 	const struct ipu6_auxdrv_data *auxdrv_data;
 	struct list_head list;
 	void *pdata;
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +2 -2
index ba3fa1c2e5d9..b9e7d3e7b15d 100644
@@ -239,7 +239,7 @@ void bnxt_ulp_stop(struct bnxt *bp)
 
 		adev = &aux_priv->aux_dev;
 		if (adev->dev.driver) {
-			struct auxiliary_driver *adrv;
+			const struct auxiliary_driver *adrv;
 			pm_message_t pm = {};
 
 			adrv = to_auxiliary_drv(adev->dev.driver);
@@ -277,7 +277,7 @@ void bnxt_ulp_start(struct bnxt *bp, int err)
 
 		adev = &aux_priv->aux_dev;
 		if (adev->dev.driver) {
-			struct auxiliary_driver *adrv;
+			const struct auxiliary_driver *adrv;
 
 			adrv = to_auxiliary_drv(adev->dev.driver);
 			edev->en_state = bp->state;
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
index 0f17fc1181d2..7341e7c4ef24 100644
@@ -2784,7 +2784,7 @@ static struct ice_pf *
 ice_ptp_aux_dev_to_owner_pf(struct auxiliary_device *aux_dev)
 {
 	struct ice_ptp_port_owner *ports_owner;
-	struct auxiliary_driver *aux_drv;
+	const struct auxiliary_driver *aux_drv;
 	struct ice_ptp *owner_ptp;
 
 	if (!aux_dev->dev.driver)
drivers/net/ethernet/mellanox/mlx5/core/dev.c +2 -2
index 47e7c2639774..9a79674d27f1 100644
@@ -349,7 +349,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
 {
 	struct mlx5_priv *priv = &dev->priv;
 	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	int ret = 0, i;
 
 	devl_assert_locked(priv_to_devlink(dev));
@@ -406,7 +406,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev, bool suspend)
 {
 	struct mlx5_priv *priv = &dev->priv;
 	struct auxiliary_device *adev;
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	pm_message_t pm = {};
 	int i;
 
include/linux/auxiliary_bus.h +1 -1
index de21d9d24a95..bdff7b85f2ae 100644
@@ -203,7 +203,7 @@ static inline struct auxiliary_device *to_auxiliary_dev(struct device *dev)
 	return container_of(dev, struct auxiliary_device, dev);
 }
 
-static inline struct auxiliary_driver *to_auxiliary_drv(struct device_driver *drv)
+static inline const struct auxiliary_driver *to_auxiliary_drv(const struct device_driver *drv)
 {
 	return container_of(drv, struct auxiliary_driver, driver);
 }
sound/soc/sof/sof-client.c +2 -2
index 99f74def4ab6..5d6005a88e79 100644
@@ -357,7 +357,7 @@ EXPORT_SYMBOL_NS_GPL(sof_client_ipc4_find_module, SND_SOC_SOF_CLIENT);
 
 int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state)
 {
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	struct sof_client_dev *cdev;
 
 	mutex_lock(&sdev->ipc_client_mutex);
@@ -380,7 +380,7 @@ EXPORT_SYMBOL_NS_GPL(sof_suspend_clients, SND_SOC_SOF_CLIENT);
 
 int sof_resume_clients(struct snd_sof_dev *sdev)
 {
-	struct auxiliary_driver *adrv;
+	const struct auxiliary_driver *adrv;
 	struct sof_client_dev *cdev;
 
 	mutex_lock(&sdev->ipc_client_mutex);
Signature · 1 line
2.45.2