^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * RapidIO driver support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2005 MontaVista Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Matt Porter <mporter@kernel.crashing.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/rio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/rio_ids.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/rio_drv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "rio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * rio_match_device - Tell if a RIO device has a matching RIO device id structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * @id: the RIO device id structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * @rdev: the RIO device structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Used from driver probe and bus matching to check whether a RIO device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * matches a device id structure provided by a RIO driver. Returns the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * matching &struct rio_device_id or %NULL if there is no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static const struct rio_device_id *rio_match_device(const struct rio_device_id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) const struct rio_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) while (id->vid || id->asm_vid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) if (((id->vid == RIO_ANY_ID) || (id->vid == rdev->vid)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ((id->did == RIO_ANY_ID) || (id->did == rdev->did)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ((id->asm_vid == RIO_ANY_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) || (id->asm_vid == rdev->asm_vid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) && ((id->asm_did == RIO_ANY_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) || (id->asm_did == rdev->asm_did)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) return id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) id++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * rio_dev_get - Increments the reference count of the RIO device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @rdev: RIO device being referenced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * Each live reference to a device should be refcounted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * Drivers for RIO devices should normally record such references in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * their probe() methods, when they bind to a device, and release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * them by calling rio_dev_put(), in their disconnect() methods.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct rio_dev *rio_dev_get(struct rio_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if (rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) get_device(&rdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * rio_dev_put - Release a use of the RIO device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @rdev: RIO device being disconnected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * Must be called when a user of a device is finished with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * When the last user of the device calls this function, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * memory of the device is freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void rio_dev_put(struct rio_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) put_device(&rdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * rio_device_probe - Tell if a RIO device structure has a matching RIO device id structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * @dev: the RIO device structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * return 0 and set rio_dev->driver when drv claims rio_dev, else error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static int rio_device_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct rio_driver *rdrv = to_rio_driver(dev->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct rio_dev *rdev = to_rio_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) const struct rio_device_id *id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (!rdev->driver && rdrv->probe) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (!rdrv->id_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) id = rio_match_device(rdrv->id_table, rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) rio_dev_get(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) error = rdrv->probe(rdev, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (error >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) rdev->driver = rdrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) rio_dev_put(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * rio_device_remove - Remove a RIO device from the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * @dev: the RIO device structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * Remove a RIO device from the system. If it has an associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * driver, then run the driver remove() method. Then update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * the reference count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static int rio_device_remove(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct rio_dev *rdev = to_rio_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct rio_driver *rdrv = rdev->driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (rdrv) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (rdrv->remove)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) rdrv->remove(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) rdev->driver = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) rio_dev_put(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void rio_device_shutdown(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct rio_dev *rdev = to_rio_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct rio_driver *rdrv = rdev->driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) dev_dbg(dev, "RIO: %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (rdrv && rdrv->shutdown)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) rdrv->shutdown(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * rio_register_driver - register a new RIO driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * @rdrv: the RIO driver structure to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * Adds a &struct rio_driver to the list of registered drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * Returns a negative value on error, otherwise 0. If no error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * occurred, the driver remains registered even if no device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * was claimed during registration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) int rio_register_driver(struct rio_driver *rdrv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* initialize common driver fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) rdrv->driver.name = rdrv->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) rdrv->driver.bus = &rio_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* register with core */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return driver_register(&rdrv->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * rio_unregister_driver - unregister a RIO driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * @rdrv: the RIO driver structure to unregister
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * Deletes the &struct rio_driver from the list of registered RIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * drivers, gives it a chance to clean up by calling its remove()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * function for each device it was responsible for, and marks those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * devices as driverless.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) void rio_unregister_driver(struct rio_driver *rdrv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) driver_unregister(&rdrv->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) void rio_attach_device(struct rio_dev *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) rdev->dev.bus = &rio_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) EXPORT_SYMBOL_GPL(rio_attach_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * rio_match_bus - Tell if a RIO device structure has a matching RIO driver device id structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * @dev: the standard device structure to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * @drv: the standard driver structure containing the ids to match against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * Used by a driver to check whether a RIO device present in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * system is in its list of supported devices. Returns 1 if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * there is a matching &struct rio_device_id or 0 if there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * no match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static int rio_match_bus(struct device *dev, struct device_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct rio_dev *rdev = to_rio_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct rio_driver *rdrv = to_rio_driver(drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) const struct rio_device_id *id = rdrv->id_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) const struct rio_device_id *found_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (!id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) found_id = rio_match_device(id, rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (found_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) out:return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static int rio_uevent(struct device *dev, struct kobj_uevent_env *env)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct rio_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (!dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) rdev = to_rio_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (!rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (add_uevent_var(env, "MODALIAS=rapidio:v%04Xd%04Xav%04Xad%04X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct class rio_mport_class = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .name = "rapidio_port",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) .dev_groups = rio_mport_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) EXPORT_SYMBOL_GPL(rio_mport_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct bus_type rio_bus_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) .name = "rapidio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) .match = rio_match_bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) .dev_groups = rio_dev_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) .bus_groups = rio_bus_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) .probe = rio_device_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) .remove = rio_device_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .shutdown = rio_device_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .uevent = rio_uevent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * rio_bus_init - Register the RapidIO bus with the device model
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * Registers the RIO mport device class and RIO bus type with the Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * device model.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static int __init rio_bus_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) ret = class_register(&rio_mport_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) ret = bus_register(&rio_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) class_unregister(&rio_mport_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) postcore_initcall(rio_bus_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) EXPORT_SYMBOL_GPL(rio_register_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) EXPORT_SYMBOL_GPL(rio_unregister_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) EXPORT_SYMBOL_GPL(rio_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) EXPORT_SYMBOL_GPL(rio_dev_get);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) EXPORT_SYMBOL_GPL(rio_dev_put);