* @brief Probe a device, and return this status. * * This function is the core of the device autoconfiguration * system. Its purpose is to select a suitable driver for a device and * then call that driver to initialise the hardware appropriately. The * driver is selected by calling the DEVICE_PROBE() method of a set of * candidate drivers and then choosing the driver which returned the * be
| 2859 | * @retval -1 Device already attached |
| 2860 | */ |
| 2861 | int |
| 2862 | device_probe(device_t dev) |
| 2863 | { |
| 2864 | int error; |
| 2865 | |
| 2866 | GIANT_REQUIRED; |
| 2867 | |
| 2868 | if (dev->state >= DS_ALIVE && (dev->flags & DF_REBID) == 0) |
| 2869 | return (-1); |
| 2870 | |
| 2871 | if (!(dev->flags & DF_ENABLED)) { |
| 2872 | if (bootverbose && device_get_name(dev) != NULL) { |
| 2873 | device_print_prettyname(dev); |
| 2874 | printf("not probed (disabled)\n"); |
| 2875 | } |
| 2876 | return (-1); |
| 2877 | } |
| 2878 | if ((error = device_probe_child(dev->parent, dev)) != 0) { |
| 2879 | if (bus_current_pass == BUS_PASS_DEFAULT && |
| 2880 | !(dev->flags & DF_DONENOMATCH)) { |
| 2881 | BUS_PROBE_NOMATCH(dev->parent, dev); |
| 2882 | devnomatch(dev); |
| 2883 | dev->flags |= DF_DONENOMATCH; |
| 2884 | } |
| 2885 | return (error); |
| 2886 | } |
| 2887 | return (0); |
| 2888 | } |
| 2889 | |
| 2890 | /** |
| 2891 | * @brief Probe a device and attach a driver if possible |
no test coverage detected