diff mbox series

mmc: core: constify the struct device_type usage

Message ID 20240219-device_cleanup-mmc-v1-1-1910e283cf5a@marliere.net (mailing list archive)
State New, archived
Headers show
Series mmc: core: constify the struct device_type usage | expand

Commit Message

Ricardo B. Marliere Feb. 19, 2024, 12:43 p.m. UTC
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the sdio_type,
sd_type and mmc_type variables to be constant structures as well, placing
it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 drivers/mmc/core/bus.c  | 2 +-
 drivers/mmc/core/bus.h  | 2 +-
 drivers/mmc/core/mmc.c  | 2 +-
 drivers/mmc/core/sd.c   | 2 +-
 drivers/mmc/core/sd.h   | 2 +-
 drivers/mmc/core/sdio.c | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)


---
base-commit: 25e69172db8a31ef8564ce1cf755ac5cb8374daa
change-id: 20240219-device_cleanup-mmc-04210bcc3d9a

Best regards,

Comments

Ulf Hansson Feb. 28, 2024, 1:03 p.m. UTC | #1
On Mon, 19 Feb 2024 at 13:43, Ricardo B. Marliere <ricardo@marliere.net> wrote:
>
> Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
> core can properly handle constant struct device_type. Move the sdio_type,
> sd_type and mmc_type variables to be constant structures as well, placing
> it into read-only memory which can not be modified at runtime.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/bus.c  | 2 +-
>  drivers/mmc/core/bus.h  | 2 +-
>  drivers/mmc/core/mmc.c  | 2 +-
>  drivers/mmc/core/sd.c   | 2 +-
>  drivers/mmc/core/sd.h   | 2 +-
>  drivers/mmc/core/sdio.c | 2 +-
>  6 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 48daeafdff7a..0ddaee0eae54 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -272,7 +272,7 @@ static void mmc_release_card(struct device *dev)
>  /*
>   * Allocate and initialise a new MMC card structure.
>   */
> -struct mmc_card *mmc_alloc_card(struct mmc_host *host, struct device_type *type)
> +struct mmc_card *mmc_alloc_card(struct mmc_host *host, const struct device_type *type)
>  {
>         struct mmc_card *card;
>
> diff --git a/drivers/mmc/core/bus.h b/drivers/mmc/core/bus.h
> index 3996b191b68d..cfd0d02d3420 100644
> --- a/drivers/mmc/core/bus.h
> +++ b/drivers/mmc/core/bus.h
> @@ -23,7 +23,7 @@ static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *a
>  static DEVICE_ATTR(name, S_IRUGO, mmc_##name##_show, NULL)
>
>  struct mmc_card *mmc_alloc_card(struct mmc_host *host,
> -       struct device_type *type);
> +                               const struct device_type *type);
>  int mmc_add_card(struct mmc_card *card);
>  void mmc_remove_card(struct mmc_card *card);
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 58ed7193a3ca..5b2f7c285461 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -883,7 +883,7 @@ static struct attribute *mmc_std_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(mmc_std);
>
> -static struct device_type mmc_type = {
> +static const struct device_type mmc_type = {
>         .groups = mmc_std_groups,
>  };
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index c3e554344c99..1c8148cdda50 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -805,7 +805,7 @@ static const struct attribute_group sd_std_group = {
>  };
>  __ATTRIBUTE_GROUPS(sd_std);
>
> -struct device_type sd_type = {
> +const struct device_type sd_type = {
>         .groups = sd_std_groups,
>  };
>
> diff --git a/drivers/mmc/core/sd.h b/drivers/mmc/core/sd.h
> index 1af5a038bae9..fe6dd46927a4 100644
> --- a/drivers/mmc/core/sd.h
> +++ b/drivers/mmc/core/sd.h
> @@ -4,7 +4,7 @@
>
>  #include <linux/types.h>
>
> -extern struct device_type sd_type;
> +extern const struct device_type sd_type;
>
>  struct mmc_host;
>  struct mmc_card;
> diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
> index 5914516df2f7..4fb247fde5c0 100644
> --- a/drivers/mmc/core/sdio.c
> +++ b/drivers/mmc/core/sdio.c
> @@ -66,7 +66,7 @@ static struct attribute *sdio_std_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(sdio_std);
>
> -static struct device_type sdio_type = {
> +static const struct device_type sdio_type = {
>         .groups = sdio_std_groups,
>  };
>
>
> ---
> base-commit: 25e69172db8a31ef8564ce1cf755ac5cb8374daa
> change-id: 20240219-device_cleanup-mmc-04210bcc3d9a
>
> Best regards,
> --
> Ricardo B. Marliere <ricardo@marliere.net>
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 48daeafdff7a..0ddaee0eae54 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -272,7 +272,7 @@  static void mmc_release_card(struct device *dev)
 /*
  * Allocate and initialise a new MMC card structure.
  */
-struct mmc_card *mmc_alloc_card(struct mmc_host *host, struct device_type *type)
+struct mmc_card *mmc_alloc_card(struct mmc_host *host, const struct device_type *type)
 {
 	struct mmc_card *card;
 
diff --git a/drivers/mmc/core/bus.h b/drivers/mmc/core/bus.h
index 3996b191b68d..cfd0d02d3420 100644
--- a/drivers/mmc/core/bus.h
+++ b/drivers/mmc/core/bus.h
@@ -23,7 +23,7 @@  static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *a
 static DEVICE_ATTR(name, S_IRUGO, mmc_##name##_show, NULL)
 
 struct mmc_card *mmc_alloc_card(struct mmc_host *host,
-	struct device_type *type);
+				const struct device_type *type);
 int mmc_add_card(struct mmc_card *card);
 void mmc_remove_card(struct mmc_card *card);
 
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 58ed7193a3ca..5b2f7c285461 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -883,7 +883,7 @@  static struct attribute *mmc_std_attrs[] = {
 };
 ATTRIBUTE_GROUPS(mmc_std);
 
-static struct device_type mmc_type = {
+static const struct device_type mmc_type = {
 	.groups = mmc_std_groups,
 };
 
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index c3e554344c99..1c8148cdda50 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -805,7 +805,7 @@  static const struct attribute_group sd_std_group = {
 };
 __ATTRIBUTE_GROUPS(sd_std);
 
-struct device_type sd_type = {
+const struct device_type sd_type = {
 	.groups = sd_std_groups,
 };
 
diff --git a/drivers/mmc/core/sd.h b/drivers/mmc/core/sd.h
index 1af5a038bae9..fe6dd46927a4 100644
--- a/drivers/mmc/core/sd.h
+++ b/drivers/mmc/core/sd.h
@@ -4,7 +4,7 @@ 
 
 #include <linux/types.h>
 
-extern struct device_type sd_type;
+extern const struct device_type sd_type;
 
 struct mmc_host;
 struct mmc_card;
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 5914516df2f7..4fb247fde5c0 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -66,7 +66,7 @@  static struct attribute *sdio_std_attrs[] = {
 };
 ATTRIBUTE_GROUPS(sdio_std);
 
-static struct device_type sdio_type = {
+static const struct device_type sdio_type = {
 	.groups = sdio_std_groups,
 };