powerpc: vio: move device attributes into a new ifdef
authorRicardo B. Marliere <ricardo@marliere.net>
Mon, 12 Feb 2024 20:04:59 +0000 (17:04 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 14 Feb 2024 13:14:05 +0000 (00:14 +1100)
In order to make the distinction of the vio_bus_type variable based on
CONFIG_PPC_SMLPAR more explicit, move the required structs into a new
ifdef block. This is needed in order to make vio_bus_type const and
because the distinction is made explicit, there is no need to set the
fields within the vio_cmo_sysfs_init function.

Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240212-bus_cleanup-powerpc2-v2-1-8441b3f77827@marliere.net
arch/powerpc/platforms/pseries/vio.c

index 2dc9cbc4bcd8fea42fc12e19a93880dcde3edafb..6c58824190a2f0b0bae1beab31c2a95d751ea7e3 100644 (file)
@@ -991,18 +991,6 @@ static DEVICE_ATTR_RO(cmo_allocated);
 static DEVICE_ATTR_RW(cmo_desired);
 static DEVICE_ATTR_RW(cmo_allocs_failed);
 
-static struct attribute *vio_cmo_dev_attrs[] = {
-       &dev_attr_name.attr,
-       &dev_attr_devspec.attr,
-       &dev_attr_modalias.attr,
-       &dev_attr_cmo_entitled.attr,
-       &dev_attr_cmo_allocated.attr,
-       &dev_attr_cmo_desired.attr,
-       &dev_attr_cmo_allocs_failed.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(vio_cmo_dev);
-
 /* sysfs bus functions and data structures for CMO */
 
 #define viobus_cmo_rd_attr(name)                                        \
@@ -1062,11 +1050,7 @@ static struct attribute *vio_bus_attrs[] = {
 };
 ATTRIBUTE_GROUPS(vio_bus);
 
-static void __init vio_cmo_sysfs_init(void)
-{
-       vio_bus_type.dev_groups = vio_cmo_dev_groups;
-       vio_bus_type.bus_groups = vio_bus_groups;
-}
+static void __init vio_cmo_sysfs_init(void) { }
 #else /* CONFIG_PPC_SMLPAR */
 int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
 void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
@@ -1584,14 +1568,6 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(modalias);
 
-static struct attribute *vio_dev_attrs[] = {
-       &dev_attr_name.attr,
-       &dev_attr_devspec.attr,
-       &dev_attr_modalias.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(vio_dev);
-
 void vio_unregister_device(struct vio_dev *viodev)
 {
        device_unregister(&viodev->dev);
@@ -1626,6 +1602,38 @@ static int vio_hotplug(const struct device *dev, struct kobj_uevent_env *env)
        return 0;
 }
 
+#ifdef CONFIG_PPC_SMLPAR
+static struct attribute *vio_cmo_dev_attrs[] = {
+       &dev_attr_name.attr,
+       &dev_attr_devspec.attr,
+       &dev_attr_modalias.attr,
+       &dev_attr_cmo_entitled.attr,
+       &dev_attr_cmo_allocated.attr,
+       &dev_attr_cmo_desired.attr,
+       &dev_attr_cmo_allocs_failed.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(vio_cmo_dev);
+
+struct bus_type vio_bus_type = {
+       .name = "vio",
+       .dev_groups = vio_cmo_dev_groups,
+       .bus_groups = vio_bus_groups,
+       .uevent = vio_hotplug,
+       .match = vio_bus_match,
+       .probe = vio_bus_probe,
+       .remove = vio_bus_remove,
+       .shutdown = vio_bus_shutdown,
+};
+#else /* CONFIG_PPC_SMLPAR */
+static struct attribute *vio_dev_attrs[] = {
+       &dev_attr_name.attr,
+       &dev_attr_devspec.attr,
+       &dev_attr_modalias.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(vio_dev);
+
 struct bus_type vio_bus_type = {
        .name = "vio",
        .dev_groups = vio_dev_groups,
@@ -1635,6 +1643,7 @@ struct bus_type vio_bus_type = {
        .remove = vio_bus_remove,
        .shutdown = vio_bus_shutdown,
 };
+#endif /* CONFIG_PPC_SMLPAR */
 
 /**
  * vio_get_attribute: - get attribute for virtual device