public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
@ 2024-06-11 13:01 Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 2/6] driver core: platform: fix ups for constant struct device_driver Greg Kroah-Hartman
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab,
	Michael Chan, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jesse Brandeburg, Tony Nguyen, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan, Pierre-Louis Bossart,
	Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
	Daniel Baluta, Kai Vehmanen, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Richard Cochran, linux-media, netdev,
	intel-wired-lan, linux-rdma, sound-open-firmware, linux-sound

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 <gregkh@linuxfoundation.org>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Bingbu Cao <bingbu.cao@intel.com>
Cc: Tianshu Qiu <tian.shu.qiu@intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Michael Chan <michael.chan@broadcom.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Tariq Toukan <tariqt@nvidia.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: linux-media@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: intel-wired-lan@lists.osuosl.org
Cc: linux-rdma@vger.kernel.org
Cc: sound-open-firmware@alsa-project.org
Cc: linux-sound@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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(-)

diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index d3a2c40c2f12..5832e31bb77b 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -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) {
diff --git a/drivers/media/pci/intel/ipu6/ipu6-bus.h b/drivers/media/pci/intel/ipu6/ipu6-bus.h
index b26c6aee1621..bb4926dfdf08 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-bus.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-bus.h
@@ -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;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
index ba3fa1c2e5d9..b9e7d3e7b15d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
@@ -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;
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 0f17fc1181d2..7341e7c4ef24 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -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)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
index 47e7c2639774..9a79674d27f1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
@@ -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;
 
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index de21d9d24a95..bdff7b85f2ae 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -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);
 }
diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c
index 99f74def4ab6..5d6005a88e79 100644
--- a/sound/soc/sof/sof-client.c
+++ b/sound/soc/sof/sof-client.c
@@ -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);
-- 
2.45.2


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

* [PATCH 2/6] driver core: platform: fix ups for constant struct device_driver
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
@ 2024-06-11 13:01 ` Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 3/6] driver core: driver: mark driver_add/remove_groups constant Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki

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" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/platform.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index c8aa1be70526..a6884479f4ac 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -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)
-- 
2.45.2


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

* [PATCH 3/6] driver core: driver: mark driver_add/remove_groups constant
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 2/6] driver core: platform: fix ups for constant struct device_driver Greg Kroah-Hartman
@ 2024-06-11 13:01 ` Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 4/6] driver core: make device_release_driver_internal() take a const * Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki

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" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/base.h   | 4 ++--
 drivers/base/driver.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index db4f910e8e36..cba8307908c7 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -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);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index c8436c26ed6a..85b4c00df078 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -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);
-- 
2.45.2


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

* [PATCH 4/6] driver core: make device_release_driver_internal() take a const *
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 2/6] driver core: platform: fix ups for constant struct device_driver Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 3/6] driver core: driver: mark driver_add/remove_groups constant Greg Kroah-Hartman
@ 2024-06-11 13:01 ` Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 5/6] driver core: make driver_detach() " Greg Kroah-Hartman
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki

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

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/base.h | 2 +-
 drivers/base/dd.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index cba8307908c7..d332b87cde9e 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -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);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 83d352394fdf..c24eca917d41 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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);
-- 
2.45.2


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

* [PATCH 5/6] driver core: make driver_detach() take a const *
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2024-06-11 13:01 ` [PATCH 4/6] driver core: make device_release_driver_internal() take a const * Greg Kroah-Hartman
@ 2024-06-11 13:01 ` Greg Kroah-Hartman
  2024-06-11 13:01 ` [PATCH 6/6] driver core: mark async_driver as " Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki

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" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/base.h | 2 +-
 drivers/base/dd.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index d332b87cde9e..9df8028c3201 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -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,
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index c24eca917d41..76b26096b033 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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;
-- 
2.45.2


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

* [PATCH 6/6] driver core: mark async_driver as a const *
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2024-06-11 13:01 ` [PATCH 5/6] driver core: make driver_detach() " Greg Kroah-Hartman
@ 2024-06-11 13:01 ` Greg Kroah-Hartman
  2024-06-11 13:22 ` [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Mark Brown
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki

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" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/base.h |  2 +-
 drivers/base/dd.c   | 15 ++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index 9df8028c3201..50151e7db796 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -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;
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 76b26096b033..8ec22229e259 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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);
-- 
2.45.2


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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2024-06-11 13:01 ` [PATCH 6/6] driver core: mark async_driver as " Greg Kroah-Hartman
@ 2024-06-11 13:22 ` Mark Brown
  2024-06-11 13:56   ` Greg Kroah-Hartman
  2024-06-11 13:44 ` Sakari Ailus
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2024-06-11 13:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab,
	Michael Chan, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jesse Brandeburg, Tony Nguyen, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan, Pierre-Louis Bossart,
	Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
	Daniel Baluta, Kai Vehmanen, Jaroslav Kysela, Takashi Iwai,
	Richard Cochran, linux-media, netdev, intel-wired-lan, linux-rdma,
	sound-open-firmware, linux-sound

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

On Tue, Jun 11, 2024 at 03:01:04PM +0200, Greg Kroah-Hartman wrote:
> 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.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2024-06-11 13:22 ` [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Mark Brown
@ 2024-06-11 13:44 ` Sakari Ailus
  2024-06-11 13:56   ` Greg Kroah-Hartman
  2024-06-11 13:50 ` Przemek Kitszel
  2024-06-12  8:15 ` Martin Habets
  8 siblings, 1 reply; 13+ messages in thread
From: Sakari Ailus @ 2024-06-11 13:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab, Michael Chan,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jesse Brandeburg, Tony Nguyen, Saeed Mahameed, Leon Romanovsky,
	Tariq Toukan, Pierre-Louis Bossart, Liam Girdwood, Peter Ujfalusi,
	Bard Liao, Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Richard Cochran,
	linux-media, netdev, intel-wired-lan, linux-rdma,
	sound-open-firmware, linux-sound

Hi Greg,

On Tue, Jun 11, 2024 at 03:01:04PM +0200, Greg Kroah-Hartman wrote:
> 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/

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> # drivers/media/pci/intel/ipu6

> 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.

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2024-06-11 13:44 ` Sakari Ailus
@ 2024-06-11 13:50 ` Przemek Kitszel
  2024-06-12  8:20   ` Greg Kroah-Hartman
  2024-06-12  8:15 ` Martin Habets
  8 siblings, 1 reply; 13+ messages in thread
From: Przemek Kitszel @ 2024-06-11 13:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Sakari Ailus,
	Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab, Michael Chan,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jesse Brandeburg, Tony Nguyen, Saeed Mahameed, Leon Romanovsky,
	Tariq Toukan, Pierre-Louis Bossart, Liam Girdwood, Peter Ujfalusi,
	Bard Liao, Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Richard Cochran,
	linux-media, netdev, intel-wired-lan, linux-rdma,
	sound-open-firmware, linux-sound

On 6/11/24 15:01, Greg Kroah-Hartman wrote:
> 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?

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

typo: s/auz/aux/

> 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 <gregkh@linuxfoundation.org>


[...]

> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 0f17fc1181d2..7341e7c4ef24 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -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)
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> index 47e7c2639774..9a79674d27f1 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> @@ -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

>   	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;
>   

[...]

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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:44 ` Sakari Ailus
@ 2024-06-11 13:56   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:56 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-kernel, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab, Michael Chan,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jesse Brandeburg, Tony Nguyen, Saeed Mahameed, Leon Romanovsky,
	Tariq Toukan, Pierre-Louis Bossart, Liam Girdwood, Peter Ujfalusi,
	Bard Liao, Ranjani Sridharan, Daniel Baluta, Kai Vehmanen,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Richard Cochran,
	linux-media, netdev, intel-wired-lan, linux-rdma,
	sound-open-firmware, linux-sound

On Tue, Jun 11, 2024 at 01:44:07PM +0000, Sakari Ailus wrote:
> Hi Greg,
> 
> On Tue, Jun 11, 2024 at 03:01:04PM +0200, Greg Kroah-Hartman wrote:
> > 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/

Ah, good catch, I'll fix that up when applying it!

> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> # drivers/media/pci/intel/ipu6

thanks for the review.

greg k-h

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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:22 ` [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Mark Brown
@ 2024-06-11 13:56   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-11 13:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-kernel, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab,
	Michael Chan, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jesse Brandeburg, Tony Nguyen, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan, Pierre-Louis Bossart,
	Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
	Daniel Baluta, Kai Vehmanen, Jaroslav Kysela, Takashi Iwai,
	Richard Cochran, linux-media, netdev, intel-wired-lan, linux-rdma,
	sound-open-firmware, linux-sound

On Tue, Jun 11, 2024 at 02:22:37PM +0100, Mark Brown wrote:
> On Tue, Jun 11, 2024 at 03:01:04PM +0200, Greg Kroah-Hartman wrote:
> > 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.
> 
> Acked-by: Mark Brown <broonie@kernel.org>

thanks for the review.


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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2024-06-11 13:50 ` Przemek Kitszel
@ 2024-06-12  8:15 ` Martin Habets
  8 siblings, 0 replies; 13+ messages in thread
From: Martin Habets @ 2024-06-12  8:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab,
	Michael Chan, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jesse Brandeburg, Tony Nguyen, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan, Pierre-Louis Bossart,
	Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
	Daniel Baluta, Kai Vehmanen, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Richard Cochran, linux-media, netdev,
	intel-wired-lan, linux-rdma, sound-open-firmware, linux-sound

On Tue, Jun 11, 2024 at 03:01:04PM +0200, Greg Kroah-Hartman wrote:
> 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 <gregkh@linuxfoundation.org>
> Cc: Dave Ertman <david.m.ertman@intel.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Bingbu Cao <bingbu.cao@intel.com>
> Cc: Tianshu Qiu <tian.shu.qiu@intel.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Michael Chan <michael.chan@broadcom.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
> Cc: Saeed Mahameed <saeedm@nvidia.com>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Tariq Toukan <tariqt@nvidia.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
> Cc: Daniel Baluta <daniel.baluta@nxp.com>
> Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: linux-media@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Cc: intel-wired-lan@lists.osuosl.org
> Cc: linux-rdma@vger.kernel.org
> Cc: sound-open-firmware@alsa-project.org
> Cc: linux-sound@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: Martin Habets <habetsm.xilinx@gmail.com>

> ---
>  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(-)
> 
> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
> index d3a2c40c2f12..5832e31bb77b 100644
> --- a/drivers/base/auxiliary.c
> +++ b/drivers/base/auxiliary.c
> @@ -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) {
> diff --git a/drivers/media/pci/intel/ipu6/ipu6-bus.h b/drivers/media/pci/intel/ipu6/ipu6-bus.h
> index b26c6aee1621..bb4926dfdf08 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6-bus.h
> +++ b/drivers/media/pci/intel/ipu6/ipu6-bus.h
> @@ -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;
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> index ba3fa1c2e5d9..b9e7d3e7b15d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> @@ -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;
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 0f17fc1181d2..7341e7c4ef24 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -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)
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> index 47e7c2639774..9a79674d27f1 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> @@ -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;
>  
> diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
> index de21d9d24a95..bdff7b85f2ae 100644
> --- a/include/linux/auxiliary_bus.h
> +++ b/include/linux/auxiliary_bus.h
> @@ -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);
>  }
> diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c
> index 99f74def4ab6..5d6005a88e79 100644
> --- a/sound/soc/sof/sof-client.c
> +++ b/sound/soc/sof/sof-client.c
> @@ -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);
> -- 
> 2.45.2
> 

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

* Re: [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer
  2024-06-11 13:50 ` Przemek Kitszel
@ 2024-06-12  8:20   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-12  8:20 UTC (permalink / raw)
  To: Przemek Kitszel
  Cc: linux-kernel, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab,
	Michael Chan, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jesse Brandeburg, Tony Nguyen, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan, Pierre-Louis Bossart,
	Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
	Daniel Baluta, Kai Vehmanen, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Richard Cochran, linux-media, netdev,
	intel-wired-lan, linux-rdma, sound-open-firmware, linux-sound

On Tue, Jun 11, 2024 at 03:50:47PM +0200, Przemek Kitszel wrote:
> On 6/11/24 15:01, Greg Kroah-Hartman wrote:
> > 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.

> or convert devlink API to accept
> consts?

Again, sorry, no, typo on my part.

> 
> > 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.

> 
> > 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 <gregkh@linuxfoundation.org>
> 
> 
> [...]
> 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> > index 0f17fc1181d2..7341e7c4ef24 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> > @@ -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)
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> > index 47e7c2639774..9a79674d27f1 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c
> > @@ -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

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

end of thread, other threads:[~2024-06-12  8:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11 13:01 [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Greg Kroah-Hartman
2024-06-11 13:01 ` [PATCH 2/6] driver core: platform: fix ups for constant struct device_driver Greg Kroah-Hartman
2024-06-11 13:01 ` [PATCH 3/6] driver core: driver: mark driver_add/remove_groups constant Greg Kroah-Hartman
2024-06-11 13:01 ` [PATCH 4/6] driver core: make device_release_driver_internal() take a const * Greg Kroah-Hartman
2024-06-11 13:01 ` [PATCH 5/6] driver core: make driver_detach() " Greg Kroah-Hartman
2024-06-11 13:01 ` [PATCH 6/6] driver core: mark async_driver as " Greg Kroah-Hartman
2024-06-11 13:22 ` [PATCH 1/6] auxbus: make to_auxiliary_drv accept and return a constant pointer Mark Brown
2024-06-11 13:56   ` Greg Kroah-Hartman
2024-06-11 13:44 ` Sakari Ailus
2024-06-11 13:56   ` Greg Kroah-Hartman
2024-06-11 13:50 ` Przemek Kitszel
2024-06-12  8:20   ` Greg Kroah-Hartman
2024-06-12  8:15 ` Martin Habets

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