of: device: make of_device_uevent_modalias() take a const device *
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Jan 2023 11:30:03 +0000 (12:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jan 2023 12:45:28 +0000 (13:45 +0100)
of_device_uevent_modalias() does not modify the device pointer passed to
it, so mark it constant.  In order to properly do this, a number of
busses need to have a modalias function added as they were attempting to
just point to of_device_uevent_modalias instead of their bus-specific
modalias function.  This is fine except if the prototype for a bus and
device type modalias function diverges and then problems could happen.  To
prevent all of that, just wrap the call to of_device_uevent_modalias()
directly for each bus and device type individually.

Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Liang He <windhl@126.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Corentin Labbe <clabbe@baylibre.com>
Cc: Zou Wei <zou_wei@huawei.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: dri-devel@lists.freedesktop.org
Cc: devicetree@vger.kernel.org
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-2-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/platforms/pseries/ibmebus.c
drivers/bus/sunxi-rsb.c
drivers/gpu/drm/display/drm_dp_aux_bus.c
drivers/macintosh/macio_asic.c
drivers/of/device.c
include/linux/of_device.h

index a870cada7acd2313ec8c0d134a39a27a529507fe..58b798a0e87984300d6e1dcbb0926ceb20a934e8 100644 (file)
@@ -426,9 +426,14 @@ static struct attribute *ibmebus_bus_device_attrs[] = {
 };
 ATTRIBUTE_GROUPS(ibmebus_bus_device);
 
+static int ibmebus_bus_modalias(struct device *dev, struct kobj_uevent_env *env)
+{
+       return of_device_uevent_modalias(dev, env);
+}
+
 struct bus_type ibmebus_bus_type = {
        .name      = "ibmebus",
-       .uevent    = of_device_uevent_modalias,
+       .uevent    = ibmebus_bus_modalias,
        .bus_groups = ibmbus_bus_groups,
        .match     = ibmebus_bus_bus_match,
        .probe     = ibmebus_bus_device_probe,
index 3aa91aed3bf733a4876e5d36c8badf13150a771b..a180af11e03432f4f79718f4b323207327496f88 100644 (file)
@@ -172,12 +172,17 @@ static void sunxi_rsb_device_remove(struct device *dev)
        drv->remove(to_sunxi_rsb_device(dev));
 }
 
+static int sunxi_rsb_device_modalias(struct device *dev, struct kobj_uevent_env *env)
+{
+       return of_device_uevent_modalias(dev, env);
+}
+
 static struct bus_type sunxi_rsb_bus = {
        .name           = RSB_CTRL_NAME,
        .match          = sunxi_rsb_device_match,
        .probe          = sunxi_rsb_device_probe,
        .remove         = sunxi_rsb_device_remove,
-       .uevent         = of_device_uevent_modalias,
+       .uevent         = sunxi_rsb_device_modalias,
 };
 
 static void sunxi_rsb_dev_release(struct device *dev)
index f5741b45ca077fa84930bd2b2f0ba74a4509072b..e31a0261c53e52ac639a242c6a1b1831e8ffd01a 100644 (file)
@@ -161,9 +161,14 @@ static void dp_aux_ep_dev_release(struct device *dev)
        kfree(aux_ep_with_data);
 }
 
+static int dp_aux_ep_dev_modalias(struct device *dev, struct kobj_uevent_env *env)
+{
+       return of_device_uevent_modalias(dev, env);
+}
+
 static struct device_type dp_aux_device_type_type = {
        .groups         = dp_aux_ep_dev_groups,
-       .uevent         = of_device_uevent_modalias,
+       .uevent         = dp_aux_ep_dev_modalias,
        .release        = dp_aux_ep_dev_release,
 };
 
index 3bc1f374e65770af2e57ab9fa7f68c264531fa33..7f2b0107c73359cffe2a257d43deef1876314b58 100644 (file)
@@ -128,12 +128,17 @@ static int macio_device_resume(struct device * dev)
        return 0;
 }
 
+static int macio_device_modalias(struct device *dev, struct kobj_uevent_env *env)
+{
+       return of_device_uevent_modalias(dev, env);
+}
+
 extern const struct attribute_group *macio_dev_groups[];
 
 struct bus_type macio_bus_type = {
        .name   = "macio",
        .match  = macio_bus_match,
-       .uevent = of_device_uevent_modalias,
+       .uevent = macio_device_modalias,
        .probe  = macio_device_probe,
        .remove = macio_device_remove,
        .shutdown = macio_device_shutdown,
index c674a13c305587ee5584618e69f2fe3d15d13b22..dda51b7ce5970dd7f57cd84362cc209cf7c0f8ec 100644 (file)
@@ -248,7 +248,7 @@ const void *of_device_get_match_data(const struct device *dev)
 }
 EXPORT_SYMBOL(of_device_get_match_data);
 
-static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
+static ssize_t of_device_get_modalias(const struct device *dev, char *str, ssize_t len)
 {
        const char *compat;
        char *c;
@@ -372,7 +372,7 @@ void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
        mutex_unlock(&of_mutex);
 }
 
-int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
+int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env)
 {
        int sl;
 
index ab7d557d541d5c92af793b986bc184312c29125b..f4b57614979de87b83b60de61427bd290919e39a 100644 (file)
@@ -36,7 +36,7 @@ extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);
 extern int of_device_request_module(struct device *dev);
 
 extern void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
-extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
+extern int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env);
 
 static inline struct device_node *of_cpu_device_node_get(int cpu)
 {
@@ -83,7 +83,7 @@ static inline int of_device_request_module(struct device *dev)
        return -ENODEV;
 }
 
-static inline int of_device_uevent_modalias(struct device *dev,
+static inline int of_device_uevent_modalias(const struct device *dev,
                                   struct kobj_uevent_env *env)
 {
        return -ENODEV;