[PATCH] memstick: Constify the driver id_table

Krzysztof Kozlowski posted 1 patch 1 month, 1 week ago
drivers/memstick/host/tifm_ms.c | 2 +-
drivers/misc/tifm_core.c        | 4 ++--
drivers/mmc/host/tifm_sd.c      | 2 +-
include/linux/tifm.h            | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
[PATCH] memstick: Constify the driver id_table
Posted by Krzysztof Kozlowski 1 month, 1 week ago
Just like all other driver structures, the id_table should never be
modified by core subsystem parts.  Constify this member and actual data
structures for increased code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

---

This should probably go via memstick tree with mmc ack. Or other way
around.
---
 drivers/memstick/host/tifm_ms.c | 2 +-
 drivers/misc/tifm_core.c        | 4 ++--
 drivers/mmc/host/tifm_sd.c      | 2 +-
 include/linux/tifm.h            | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index 0b6a90661eee..0a54586aa54e 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -647,7 +647,7 @@ static int tifm_ms_resume(struct tifm_dev *sock)
 
 #endif /* CONFIG_PM */
 
-static struct tifm_device_id tifm_ms_id_tbl[] = {
+static const struct tifm_device_id tifm_ms_id_tbl[] = {
 	{ TIFM_TYPE_MS }, { 0 }
 };
 
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index da0827724a61..aac8f0933e43 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -31,7 +31,7 @@ static const char *tifm_media_type_name(unsigned char type, unsigned char nt)
 	return card_type_name[nt][type - 1];
 }
 
-static int tifm_dev_match(struct tifm_dev *sock, struct tifm_device_id *id)
+static int tifm_dev_match(struct tifm_dev *sock, const struct tifm_device_id *id)
 {
 	if (sock->type == id->type)
 		return 1;
@@ -43,7 +43,7 @@ static int tifm_bus_match(struct device *dev, const struct device_driver *drv)
 	struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
 	const struct tifm_driver *fm_drv = container_of_const(drv, struct tifm_driver,
 							      driver);
-	struct tifm_device_id *ids = fm_drv->id_table;
+	const struct tifm_device_id *ids = fm_drv->id_table;
 
 	if (ids) {
 		while (ids->type) {
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index aebffd3ebf60..28ab2526dab1 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -1041,7 +1041,7 @@ static int tifm_sd_resume(struct tifm_dev *sock)
 
 #endif /* CONFIG_PM */
 
-static struct tifm_device_id tifm_sd_id_tbl[] = {
+static const struct tifm_device_id tifm_sd_id_tbl[] = {
 	{ TIFM_TYPE_SD }, { }
 };
 MODULE_DEVICE_TABLE(tifm, tifm_sd_id_tbl);
diff --git a/include/linux/tifm.h b/include/linux/tifm.h
index 44073d06710f..752fcfae27fe 100644
--- a/include/linux/tifm.h
+++ b/include/linux/tifm.h
@@ -97,7 +97,7 @@ struct tifm_dev {
 };
 
 struct tifm_driver {
-	struct tifm_device_id *id_table;
+	const struct tifm_device_id *id_table;
 	int                   (*probe)(struct tifm_dev *dev);
 	void                  (*remove)(struct tifm_dev *dev);
 	int                   (*suspend)(struct tifm_dev *dev,
-- 
2.51.0
Re: [PATCH] memstick: Constify the driver id_table
Posted by Ulf Hansson 1 month ago
On Tue, 5 May 2026 at 12:39, Krzysztof Kozlowski
<krzysztof.kozlowski@oss.qualcomm.com> wrote:
>
> Just like all other driver structures, the id_table should never be
> modified by core subsystem parts.  Constify this member and actual data
> structures for increased code safety.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Applied for next, thanks!

Kind regards
Uffe


>
> ---
>
> This should probably go via memstick tree with mmc ack. Or other way
> around.
> ---
>  drivers/memstick/host/tifm_ms.c | 2 +-
>  drivers/misc/tifm_core.c        | 4 ++--
>  drivers/mmc/host/tifm_sd.c      | 2 +-
>  include/linux/tifm.h            | 2 +-
>  4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
> index 0b6a90661eee..0a54586aa54e 100644
> --- a/drivers/memstick/host/tifm_ms.c
> +++ b/drivers/memstick/host/tifm_ms.c
> @@ -647,7 +647,7 @@ static int tifm_ms_resume(struct tifm_dev *sock)
>
>  #endif /* CONFIG_PM */
>
> -static struct tifm_device_id tifm_ms_id_tbl[] = {
> +static const struct tifm_device_id tifm_ms_id_tbl[] = {
>         { TIFM_TYPE_MS }, { 0 }
>  };
>
> diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
> index da0827724a61..aac8f0933e43 100644
> --- a/drivers/misc/tifm_core.c
> +++ b/drivers/misc/tifm_core.c
> @@ -31,7 +31,7 @@ static const char *tifm_media_type_name(unsigned char type, unsigned char nt)
>         return card_type_name[nt][type - 1];
>  }
>
> -static int tifm_dev_match(struct tifm_dev *sock, struct tifm_device_id *id)
> +static int tifm_dev_match(struct tifm_dev *sock, const struct tifm_device_id *id)
>  {
>         if (sock->type == id->type)
>                 return 1;
> @@ -43,7 +43,7 @@ static int tifm_bus_match(struct device *dev, const struct device_driver *drv)
>         struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
>         const struct tifm_driver *fm_drv = container_of_const(drv, struct tifm_driver,
>                                                               driver);
> -       struct tifm_device_id *ids = fm_drv->id_table;
> +       const struct tifm_device_id *ids = fm_drv->id_table;
>
>         if (ids) {
>                 while (ids->type) {
> diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
> index aebffd3ebf60..28ab2526dab1 100644
> --- a/drivers/mmc/host/tifm_sd.c
> +++ b/drivers/mmc/host/tifm_sd.c
> @@ -1041,7 +1041,7 @@ static int tifm_sd_resume(struct tifm_dev *sock)
>
>  #endif /* CONFIG_PM */
>
> -static struct tifm_device_id tifm_sd_id_tbl[] = {
> +static const struct tifm_device_id tifm_sd_id_tbl[] = {
>         { TIFM_TYPE_SD }, { }
>  };
>  MODULE_DEVICE_TABLE(tifm, tifm_sd_id_tbl);
> diff --git a/include/linux/tifm.h b/include/linux/tifm.h
> index 44073d06710f..752fcfae27fe 100644
> --- a/include/linux/tifm.h
> +++ b/include/linux/tifm.h
> @@ -97,7 +97,7 @@ struct tifm_dev {
>  };
>
>  struct tifm_driver {
> -       struct tifm_device_id *id_table;
> +       const struct tifm_device_id *id_table;
>         int                   (*probe)(struct tifm_dev *dev);
>         void                  (*remove)(struct tifm_dev *dev);
>         int                   (*suspend)(struct tifm_dev *dev,
> --
> 2.51.0
>
Re: [PATCH] memstick: Constify the driver id_table
Posted by Greg Kroah-Hartman 1 month, 1 week ago
On Tue, May 05, 2026 at 12:39:28PM +0200, Krzysztof Kozlowski wrote:
> Just like all other driver structures, the id_table should never be
> modified by core subsystem parts.  Constify this member and actual data
> structures for increased code safety.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> 
> ---
> 
> This should probably go via memstick tree with mmc ack. Or other way
> around.
> ---
>  drivers/memstick/host/tifm_ms.c | 2 +-
>  drivers/misc/tifm_core.c        | 4 ++--

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>