Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: vio: move device attributes into a new ifdef

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

authored by

Ricardo B. Marliere and committed by
Michael Ellerman
e15d0127 c5aebb53

+34 -25
+34 -25
arch/powerpc/platforms/pseries/vio.c
··· 991 991 static DEVICE_ATTR_RW(cmo_desired); 992 992 static DEVICE_ATTR_RW(cmo_allocs_failed); 993 993 994 - static struct attribute *vio_cmo_dev_attrs[] = { 995 - &dev_attr_name.attr, 996 - &dev_attr_devspec.attr, 997 - &dev_attr_modalias.attr, 998 - &dev_attr_cmo_entitled.attr, 999 - &dev_attr_cmo_allocated.attr, 1000 - &dev_attr_cmo_desired.attr, 1001 - &dev_attr_cmo_allocs_failed.attr, 1002 - NULL, 1003 - }; 1004 - ATTRIBUTE_GROUPS(vio_cmo_dev); 1005 - 1006 994 /* sysfs bus functions and data structures for CMO */ 1007 995 1008 996 #define viobus_cmo_rd_attr(name) \ ··· 1050 1062 }; 1051 1063 ATTRIBUTE_GROUPS(vio_bus); 1052 1064 1053 - static void __init vio_cmo_sysfs_init(void) 1054 - { 1055 - vio_bus_type.dev_groups = vio_cmo_dev_groups; 1056 - vio_bus_type.bus_groups = vio_bus_groups; 1057 - } 1065 + static void __init vio_cmo_sysfs_init(void) { } 1058 1066 #else /* CONFIG_PPC_SMLPAR */ 1059 1067 int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; } 1060 1068 void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {} ··· 1568 1584 } 1569 1585 static DEVICE_ATTR_RO(modalias); 1570 1586 1571 - static struct attribute *vio_dev_attrs[] = { 1572 - &dev_attr_name.attr, 1573 - &dev_attr_devspec.attr, 1574 - &dev_attr_modalias.attr, 1575 - NULL, 1576 - }; 1577 - ATTRIBUTE_GROUPS(vio_dev); 1578 - 1579 1587 void vio_unregister_device(struct vio_dev *viodev) 1580 1588 { 1581 1589 device_unregister(&viodev->dev); ··· 1602 1626 return 0; 1603 1627 } 1604 1628 1629 + #ifdef CONFIG_PPC_SMLPAR 1630 + static struct attribute *vio_cmo_dev_attrs[] = { 1631 + &dev_attr_name.attr, 1632 + &dev_attr_devspec.attr, 1633 + &dev_attr_modalias.attr, 1634 + &dev_attr_cmo_entitled.attr, 1635 + &dev_attr_cmo_allocated.attr, 1636 + &dev_attr_cmo_desired.attr, 1637 + &dev_attr_cmo_allocs_failed.attr, 1638 + NULL, 1639 + }; 1640 + ATTRIBUTE_GROUPS(vio_cmo_dev); 1641 + 1642 + struct bus_type vio_bus_type = { 1643 + .name = "vio", 1644 + .dev_groups = vio_cmo_dev_groups, 1645 + .bus_groups = vio_bus_groups, 1646 + .uevent = vio_hotplug, 1647 + .match = vio_bus_match, 1648 + .probe = vio_bus_probe, 1649 + .remove = vio_bus_remove, 1650 + .shutdown = vio_bus_shutdown, 1651 + }; 1652 + #else /* CONFIG_PPC_SMLPAR */ 1653 + static struct attribute *vio_dev_attrs[] = { 1654 + &dev_attr_name.attr, 1655 + &dev_attr_devspec.attr, 1656 + &dev_attr_modalias.attr, 1657 + NULL, 1658 + }; 1659 + ATTRIBUTE_GROUPS(vio_dev); 1660 + 1605 1661 struct bus_type vio_bus_type = { 1606 1662 .name = "vio", 1607 1663 .dev_groups = vio_dev_groups, ··· 1643 1635 .remove = vio_bus_remove, 1644 1636 .shutdown = vio_bus_shutdown, 1645 1637 }; 1638 + #endif /* CONFIG_PPC_SMLPAR */ 1646 1639 1647 1640 /** 1648 1641 * vio_get_attribute: - get attribute for virtual device