aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorDavid Kershner <david.kershner@unisys.com>2016-09-19 17:09:36 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-20 07:28:17 -0400
commit7a0ee694889694c49d4ebe99dce30e699f832396 (patch)
tree1af67e3a5ce22c3d715f0408c96f547ab776e3d9 /drivers/staging
parent7993b40cd772cae9890f81fb0ea809130a732c5e (diff)
staging: unisys: visorbus: remove fix_vbus_dev_info prototype
Move the visordriver_probe_device and visorbus_register_visor_driver functions lower in the file to get rid of the function prototype fix_vbus_dev_info. Signed-off-by: David Kershner <david.kershner@unisys.com> Reviewed-by: Tim Sell <Timothy.Sell@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/unisys/visorbus/visorbus_main.c256
1 files changed, 127 insertions, 129 deletions
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index d41e3d96f023..3918bb586b93 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -35,8 +35,6 @@ static int visorbus_forcenomatch;
35 35
36static int busreg_rc = -ENODEV; /* stores the result from bus registration */ 36static int busreg_rc = -ENODEV; /* stores the result from bus registration */
37 37
38static void fix_vbus_dev_info(struct visor_device *visordev);
39
40/* 38/*
41 * BUS type attributes 39 * BUS type attributes
42 * 40 *
@@ -531,48 +529,6 @@ dev_stop_periodic_work(struct visor_device *dev)
531} 529}
532 530
533/** 531/**
534 * visordriver_probe_device() - handle new visor device coming online
535 * @xdev: struct device for the visor device being probed
536 *
537 * This is called automatically upon adding a visor_device (device_add), or
538 * adding a visor_driver (visorbus_register_visor_driver), but only after
539 * visorbus_match() has returned 1 to indicate a successful match between
540 * driver and device.
541 *
542 * If successful, a reference to the device will be held onto via get_device().
543 *
544 * Return: 0 if successful, meaning the function driver's probe() function
545 * was successful with this device, otherwise a negative errno
546 * value indicating failure reason
547 */
548static int
549visordriver_probe_device(struct device *xdev)
550{
551 int res;
552 struct visor_driver *drv;
553 struct visor_device *dev;
554
555 drv = to_visor_driver(xdev->driver);
556 dev = to_visor_device(xdev);
557
558 if (!drv->probe)
559 return -ENODEV;
560
561 mutex_lock(&dev->visordriver_callback_lock);
562 dev->being_removed = false;
563
564 res = drv->probe(dev);
565 if (res >= 0) {
566 /* success: reference kept via unmatched get_device() */
567 get_device(&dev->device);
568 fix_vbus_dev_info(dev);
569 }
570
571 mutex_unlock(&dev->visordriver_callback_lock);
572 return res;
573}
574
575/**
576 * visordriver_remove_device() - handle visor device going away 532 * visordriver_remove_device() - handle visor device going away
577 * @xdev: struct device for the visor device being removed 533 * @xdev: struct device for the visor device being removed
578 * 534 *
@@ -602,91 +558,6 @@ visordriver_remove_device(struct device *xdev)
602} 558}
603 559
604/** 560/**
605 * visorbus_register_visor_driver() - registers the provided visor driver
606 * for handling one or more visor device
607 * types (channel_types)
608 * @drv: the driver to register
609 *
610 * A visor function driver calls this function to register
611 * the driver. The caller MUST fill in the following fields within the
612 * #drv structure:
613 * name, version, owner, channel_types, probe, remove
614 *
615 * Here's how the whole Linux bus / driver / device model works.
616 *
617 * At system start-up, the visorbus kernel module is loaded, which registers
618 * visorbus_type as a bus type, using bus_register().
619 *
620 * All kernel modules that support particular device types on a
621 * visorbus bus are loaded. Each of these kernel modules calls
622 * visorbus_register_visor_driver() in their init functions, passing a
623 * visor_driver struct. visorbus_register_visor_driver() in turn calls
624 * register_driver(&visor_driver.driver). This .driver member is
625 * initialized with generic methods (like probe), whose sole responsibility
626 * is to act as a broker for the real methods, which are within the
627 * visor_driver struct. (This is the way the subclass behavior is
628 * implemented, since visor_driver is essentially a subclass of the
629 * generic driver.) Whenever a driver_register() happens, core bus code in
630 * the kernel does (see device_attach() in drivers/base/dd.c):
631 *
632 * for each dev associated with the bus (the bus that driver is on) that
633 * does not yet have a driver
634 * if bus.match(dev,newdriver) == yes_matched ** .match specified
635 * ** during bus_register().
636 * newdriver.probe(dev) ** for visor drivers, this will call
637 * ** the generic driver.probe implemented in visorbus.c,
638 * ** which in turn calls the probe specified within the
639 * ** struct visor_driver (which was specified by the
640 * ** actual device driver as part of
641 * ** visorbus_register_visor_driver()).
642 *
643 * The above dance also happens when a new device appears.
644 * So the question is, how are devices created within the system?
645 * Basically, just call device_add(dev). See pci_bus_add_devices().
646 * pci_scan_device() shows an example of how to build a device struct. It
647 * returns the newly-created struct to pci_scan_single_device(), who adds it
648 * to the list of devices at PCIBUS.devices. That list of devices is what
649 * is traversed by pci_bus_add_devices().
650 *
651 * Return: integer indicating success (zero) or failure (non-zero)
652 */
653int visorbus_register_visor_driver(struct visor_driver *drv)
654{
655 int rc = 0;
656
657 if (busreg_rc < 0)
658 return -ENODEV; /*can't register on a nonexistent bus*/
659
660 drv->driver.name = drv->name;
661 drv->driver.bus = &visorbus_type;
662 drv->driver.probe = visordriver_probe_device;
663 drv->driver.remove = visordriver_remove_device;
664 drv->driver.owner = drv->owner;
665
666 /*
667 * driver_register does this:
668 * bus_add_driver(drv)
669 * ->if (drv.bus) ** (bus_type) **
670 * driver_attach(drv)
671 * for each dev with bus type of drv.bus
672 * if (!dev.drv) ** no driver assigned yet **
673 * if (bus.match(dev,drv)) [visorbus_match]
674 * dev.drv = drv
675 * if (!drv.probe(dev)) [visordriver_probe_device]
676 * dev.drv = NULL
677 */
678
679 rc = driver_register(&drv->driver);
680 if (rc < 0)
681 return rc;
682 rc = register_driver_attributes(drv);
683 if (rc < 0)
684 driver_unregister(&drv->driver);
685 return rc;
686}
687EXPORT_SYMBOL_GPL(visorbus_register_visor_driver);
688
689/**
690 * visorbus_unregister_visor_driver() - unregisters the provided driver 561 * visorbus_unregister_visor_driver() - unregisters the provided driver
691 * @drv: the driver to unregister 562 * @drv: the driver to unregister
692 * 563 *
@@ -1026,6 +897,133 @@ fix_vbus_dev_info(struct visor_device *visordev)
1026} 897}
1027 898
1028/** 899/**
900 * visordriver_probe_device() - handle new visor device coming online
901 * @xdev: struct device for the visor device being probed
902 *
903 * This is called automatically upon adding a visor_device (device_add), or
904 * adding a visor_driver (visorbus_register_visor_driver), but only after
905 * visorbus_match() has returned 1 to indicate a successful match between
906 * driver and device.
907 *
908 * If successful, a reference to the device will be held onto via get_device().
909 *
910 * Return: 0 if successful, meaning the function driver's probe() function
911 * was successful with this device, otherwise a negative errno
912 * value indicating failure reason
913 */
914static int
915visordriver_probe_device(struct device *xdev)
916{
917 int res;
918 struct visor_driver *drv;
919 struct visor_device *dev;
920
921 drv = to_visor_driver(xdev->driver);
922 dev = to_visor_device(xdev);
923
924 if (!drv->probe)
925 return -ENODEV;
926
927 mutex_lock(&dev->visordriver_callback_lock);
928 dev->being_removed = false;
929
930 res = drv->probe(dev);
931 if (res >= 0) {
932 /* success: reference kept via unmatched get_device() */
933 get_device(&dev->device);
934 fix_vbus_dev_info(dev);
935 }
936
937 mutex_unlock(&dev->visordriver_callback_lock);
938 return res;
939}
940
941/**
942 * visorbus_register_visor_driver() - registers the provided visor driver
943 * for handling one or more visor device
944 * types (channel_types)
945 * @drv: the driver to register
946 *
947 * A visor function driver calls this function to register
948 * the driver. The caller MUST fill in the following fields within the
949 * #drv structure:
950 * name, version, owner, channel_types, probe, remove
951 *
952 * Here's how the whole Linux bus / driver / device model works.
953 *
954 * At system start-up, the visorbus kernel module is loaded, which registers
955 * visorbus_type as a bus type, using bus_register().
956 *
957 * All kernel modules that support particular device types on a
958 * visorbus bus are loaded. Each of these kernel modules calls
959 * visorbus_register_visor_driver() in their init functions, passing a
960 * visor_driver struct. visorbus_register_visor_driver() in turn calls
961 * register_driver(&visor_driver.driver). This .driver member is
962 * initialized with generic methods (like probe), whose sole responsibility
963 * is to act as a broker for the real methods, which are within the
964 * visor_driver struct. (This is the way the subclass behavior is
965 * implemented, since visor_driver is essentially a subclass of the
966 * generic driver.) Whenever a driver_register() happens, core bus code in
967 * the kernel does (see device_attach() in drivers/base/dd.c):
968 *
969 * for each dev associated with the bus (the bus that driver is on) that
970 * does not yet have a driver
971 * if bus.match(dev,newdriver) == yes_matched ** .match specified
972 * ** during bus_register().
973 * newdriver.probe(dev) ** for visor drivers, this will call
974 * ** the generic driver.probe implemented in visorbus.c,
975 * ** which in turn calls the probe specified within the
976 * ** struct visor_driver (which was specified by the
977 * ** actual device driver as part of
978 * ** visorbus_register_visor_driver()).
979 *
980 * The above dance also happens when a new device appears.
981 * So the question is, how are devices created within the system?
982 * Basically, just call device_add(dev). See pci_bus_add_devices().
983 * pci_scan_device() shows an example of how to build a device struct. It
984 * returns the newly-created struct to pci_scan_single_device(), who adds it
985 * to the list of devices at PCIBUS.devices. That list of devices is what
986 * is traversed by pci_bus_add_devices().
987 *
988 * Return: integer indicating success (zero) or failure (non-zero)
989 */
990int visorbus_register_visor_driver(struct visor_driver *drv)
991{
992 int rc = 0;
993
994 if (busreg_rc < 0)
995 return -ENODEV; /*can't register on a nonexistent bus*/
996
997 drv->driver.name = drv->name;
998 drv->driver.bus = &visorbus_type;
999 drv->driver.probe = visordriver_probe_device;
1000 drv->driver.remove = visordriver_remove_device;
1001 drv->driver.owner = drv->owner;
1002
1003 /*
1004 * driver_register does this:
1005 * bus_add_driver(drv)
1006 * ->if (drv.bus) ** (bus_type) **
1007 * driver_attach(drv)
1008 * for each dev with bus type of drv.bus
1009 * if (!dev.drv) ** no driver assigned yet **
1010 * if (bus.match(dev,drv)) [visorbus_match]
1011 * dev.drv = drv
1012 * if (!drv.probe(dev)) [visordriver_probe_device]
1013 * dev.drv = NULL
1014 */
1015
1016 rc = driver_register(&drv->driver);
1017 if (rc < 0)
1018 return rc;
1019 rc = register_driver_attributes(drv);
1020 if (rc < 0)
1021 driver_unregister(&drv->driver);
1022 return rc;
1023}
1024EXPORT_SYMBOL_GPL(visorbus_register_visor_driver);
1025
1026/**
1029 * create_bus_instance() - create a device instance for the visor bus itself 1027 * create_bus_instance() - create a device instance for the visor bus itself
1030 * @dev: struct visor_device indicating the bus instance 1028 * @dev: struct visor_device indicating the bus instance
1031 * 1029 *