mirror of https://gitee.com/openkylin/linux.git
staging: fieldbus: anybus: Refuse registering drivers without .probe()
A driver without .probe() callback could never bind to a device because anybus_bus_probe() returned an error for such a driver. So refuse to register such a useless driver. Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20210505202923.198607-2-u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
32dcd07242
commit
a3417158b9
|
@ -1183,8 +1183,6 @@ static int anybus_bus_probe(struct device *dev)
|
||||||
struct anybuss_client *adev =
|
struct anybuss_client *adev =
|
||||||
to_anybuss_client(dev);
|
to_anybuss_client(dev);
|
||||||
|
|
||||||
if (!adrv->probe)
|
|
||||||
return -ENODEV;
|
|
||||||
return adrv->probe(adev);
|
return adrv->probe(adev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1208,6 +1206,9 @@ static struct bus_type anybus_bus = {
|
||||||
|
|
||||||
int anybuss_client_driver_register(struct anybuss_client_driver *drv)
|
int anybuss_client_driver_register(struct anybuss_client_driver *drv)
|
||||||
{
|
{
|
||||||
|
if (!drv->probe)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
drv->driver.bus = &anybus_bus;
|
drv->driver.bus = &anybus_bus;
|
||||||
return driver_register(&drv->driver);
|
return driver_register(&drv->driver);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue