mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] spmi: Drop struct spmi_device_id
@ 2026-11-26 14:48 Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 1/3] spmi: Don't limit device name matchin driver name on SPMI_NAME_SIZE chars Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-11-26 14:48 UTC (permalink / raw)
  To: Stephen Boyd, Abel Vesa; +Cc: linux-kernel, Pawel Zalewski

Hello,

my v1 patch
(https://lore.kernel.org/all/20261125112158.938835-2-u.kleine-koenig@baylibre.com/)
is the same as patch #2 here, but without the first patch of this series
this results in a build failure. I kept Pawel's R-b tag I got in v1.

I'm not 100% sure, I grokked the spmi situation completely. As pointed
out in the commit description of patch #1 both driver name and device
name are proper \0-terminated strings with no theoretical length limit.
So only comparing SPMI_NAME_SIZE chars is at least strange. I think
there is no device/driver combo that needs that string comparison to
match.

All spmi devices seem to be instantiated via drivers/spmi/spmi.c from
dtb with the exception of drivers/regulator/mt6363-regulator.c.
spmi_device_add() enforces a device name in the form format("%d-%02x",
sdev->ctrl->nr, sdev->usid) and I didn't find a driver with that name.
mt6363-regulator.c does

	sdev = spmi_device_alloc(sparent->ctrl);
	dev_set_name(&sdev->dev, "%d-%02x-regulator", sdev->ctrl->nr, sdev->usid);
	device_add(&sdev->dev);

but there doesn't seem to be a matching driver for that either.

I discovered the opportunity for the 3rd patch while researching the
above details. I'm not sure about that either as
drivers/regulator/mt6363-regulator.c uses spmi_device_remove() so maybe
it should use spmi_device_add(), too? Also I didn't find the
device_put() that is needed to undo spmi_device_alloc() when the
mt6363-regulator device gets unbound.

Best regards
Uwe

Uwe Kleine-König (3):
  spmi: Don't limit device name matchin driver name on SPMI_NAME_SIZE
    chars
  spmi: Drop struct spmi_device_id
  spmi: Don't export locally used function spmi_device_add()

 drivers/spmi/spmi.c             |  6 ++----
 include/linux/device-id/spmi.h  | 17 -----------------
 include/linux/mod_devicetable.h |  1 -
 include/linux/spmi.h            |  2 --
 4 files changed, 2 insertions(+), 24 deletions(-)
 delete mode 100644 include/linux/device-id/spmi.h


base-commit: 9437046953b2fb3bf55b36582450ea0267df82a7
-- 
2.47.3


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

* [PATCH v2 1/3] spmi: Don't limit device name matchin driver name on SPMI_NAME_SIZE chars
  2026-11-26 14:48 [PATCH v2 0/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
@ 2026-11-26 14:48 ` Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 2/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 3/3] spmi: Don't export locally used function spmi_device_add() Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-11-26 14:48 UTC (permalink / raw)
  To: Stephen Boyd, Abel Vesa; +Cc: linux-kernel, Pawel Zalewski

Both device name and driver name are not limited to SPMI_NAME_SIZE
chars and both are always properly \0-terminated. So it doesn't make
sense to use strncmp() here. Use strcmp() instead.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/spmi/spmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
index ec97f12046f5..6d6805a5ae69 100644
--- a/drivers/spmi/spmi.c
+++ b/drivers/spmi/spmi.c
@@ -64,8 +64,7 @@ static int spmi_device_match(struct device *dev, const struct device_driver *drv
 		return 1;
 
 	if (drv->name)
-		return strncmp(dev_name(dev), drv->name,
-			       SPMI_NAME_SIZE) == 0;
+		return strcmp(dev_name(dev), drv->name) == 0;
 
 	return 0;
 }
-- 
2.47.3


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

* [PATCH v2 2/3] spmi: Drop struct spmi_device_id
  2026-11-26 14:48 [PATCH v2 0/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 1/3] spmi: Don't limit device name matchin driver name on SPMI_NAME_SIZE chars Uwe Kleine-König
@ 2026-11-26 14:48 ` Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 3/3] spmi: Don't export locally used function spmi_device_add() Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-11-26 14:48 UTC (permalink / raw)
  To: Stephen Boyd, Abel Vesa; +Cc: linux-kernel, Pawel Zalewski

This was introduced by commit 5a86bf343976 ("spmi: Linux driver
framework for SPMI") in 2014 for Linux 3.15 and already then was unused
and no user was added since then. The only exception was a usage of
SPMI_NAME_SIZE that was dropped in the previous commit.

Reviewed-by: Pawel Zalewski <pzalewski@thegoodpenguin.co.uk>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 include/linux/device-id/spmi.h  | 17 -----------------
 include/linux/mod_devicetable.h |  1 -
 2 files changed, 18 deletions(-)
 delete mode 100644 include/linux/device-id/spmi.h

diff --git a/include/linux/device-id/spmi.h b/include/linux/device-id/spmi.h
deleted file mode 100644
index a821c42cfc9a..000000000000
--- a/include/linux/device-id/spmi.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef LINUX_DEVICE_ID_SPMI_H
-#define LINUX_DEVICE_ID_SPMI_H
-
-#ifdef __KERNEL__
-typedef unsigned long kernel_ulong_t;
-#endif
-
-#define SPMI_NAME_SIZE	32
-#define SPMI_MODULE_PREFIX "spmi:"
-
-struct spmi_device_id {
-	char name[SPMI_NAME_SIZE];
-	kernel_ulong_t driver_data;	/* Data private to the driver */
-};
-
-#endif /* ifndef LINUX_DEVICE_ID_SPMI_H */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index a69947f2c1dc..fd21238c99f5 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -51,7 +51,6 @@
 #include "device-id/serio.h"
 #include "device-id/slim.h"
 #include "device-id/spi.h"
-#include "device-id/spmi.h"
 #include "device-id/ssam.h"
 #include "device-id/ssb.h"
 #include "device-id/tb.h"
-- 
2.47.3


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

* [PATCH v2 3/3] spmi: Don't export locally used function spmi_device_add()
  2026-11-26 14:48 [PATCH v2 0/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 1/3] spmi: Don't limit device name matchin driver name on SPMI_NAME_SIZE chars Uwe Kleine-König
  2026-11-26 14:48 ` [PATCH v2 2/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
@ 2026-11-26 14:48 ` Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2026-11-26 14:48 UTC (permalink / raw)
  To: Stephen Boyd, Abel Vesa; +Cc: linux-kernel, Pawel Zalewski

drivers/spmi/spmi.c is the only user of spmi_device_add(). So there is
no need to export this function for module usage.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/spmi/spmi.c  | 3 +--
 include/linux/spmi.h | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
index 6d6805a5ae69..c8b3e236db83 100644
--- a/drivers/spmi/spmi.c
+++ b/drivers/spmi/spmi.c
@@ -73,7 +73,7 @@ static int spmi_device_match(struct device *dev, const struct device_driver *drv
  * spmi_device_add() - add a device previously constructed via spmi_device_alloc()
  * @sdev:	spmi_device to be added
  */
-int spmi_device_add(struct spmi_device *sdev)
+static int spmi_device_add(struct spmi_device *sdev)
 {
 	struct spmi_controller *ctrl = sdev->ctrl;
 	int err;
@@ -89,7 +89,6 @@ int spmi_device_add(struct spmi_device *sdev)
 	dev_dbg(&sdev->dev, "device registered\n");
 	return 0;
 }
-EXPORT_SYMBOL_GPL(spmi_device_add);
 
 /**
  * spmi_device_remove(): remove an SPMI device
diff --git a/include/linux/spmi.h b/include/linux/spmi.h
index 4daebc980501..c81ff3eb8cbe 100644
--- a/include/linux/spmi.h
+++ b/include/linux/spmi.h
@@ -65,8 +65,6 @@ static inline void spmi_device_put(struct spmi_device *sdev)
 		put_device(&sdev->dev);
 }
 
-int spmi_device_add(struct spmi_device *sdev);
-
 void spmi_device_remove(struct spmi_device *sdev);
 
 /**
-- 
2.47.3


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

end of thread, other threads:[~2026-11-26 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 14:48 [PATCH v2 0/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
2026-11-26 14:48 ` [PATCH v2 1/3] spmi: Don't limit device name matchin driver name on SPMI_NAME_SIZE chars Uwe Kleine-König
2026-11-26 14:48 ` [PATCH v2 2/3] spmi: Drop struct spmi_device_id Uwe Kleine-König
2026-11-26 14:48 ` [PATCH v2 3/3] spmi: Don't export locally used function spmi_device_add() Uwe Kleine-König

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

all inboxes | Powered by JetHome®