mmc: core: constify the struct device_type usage
authorRicardo B. Marliere <ricardo@marliere.net>
Mon, 19 Feb 2024 12:43:57 +0000 (09:43 -0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 27 Feb 2024 12:48:36 +0000 (13:48 +0100)
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>
Link: https://lore.kernel.org/r/20240219-device_cleanup-mmc-v1-1-1910e283cf5a@marliere.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/bus.c
drivers/mmc/core/bus.h
drivers/mmc/core/mmc.c
drivers/mmc/core/sd.c
drivers/mmc/core/sd.h
drivers/mmc/core/sdio.c

index 48daeafdff7af2e7966c609c00aefb091b1f3fe6..0ddaee0eae54f0ccb5042fefd9ec8f5f87bc03ec 100644 (file)
@@ -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;
 
index 3996b191b68d1b913e67247ebe0aeb944ca3d4cd..cfd0d02d34205f070a36c4695cb7e12f0127b833 100644 (file)
@@ -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);
 
index 58ed7193a3ca460fe58a46427306b385a40a2d3e..5b2f7c2854619d552f4641e7fde2d2b8542ee7b1 100644 (file)
@@ -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,
 };
 
index c3e554344c99f9d7abe38e3ba20f312321246b4b..1c8148cdda505dfff57103a694c6a92462927fd0 100644 (file)
@@ -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,
 };
 
index 1af5a038bae970db02f5ccec3a553e1a03ff3b2b..fe6dd46927a423e9746c0a8b414d8c6a33c1d9c5 100644 (file)
@@ -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;
index 5914516df2f7fd93b90c31e287f4448d74f856fa..4fb247fde5c0801a4b9bdf5503737d36841e0fe8 100644 (file)
@@ -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,
 };