From a3417158b9321bbaf21d967f85cdd049ff2f5685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 5 May 2021 22:29:23 +0200 Subject: [PATCH] staging: fieldbus: anybus: Refuse registering drivers without .probe() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20210505202923.198607-2-u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/anybuss/host.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c index de6c287efa03..0f730efe9a6d 100644 --- a/drivers/staging/fieldbus/anybuss/host.c +++ b/drivers/staging/fieldbus/anybuss/host.c @@ -1183,8 +1183,6 @@ static int anybus_bus_probe(struct device *dev) struct anybuss_client *adev = to_anybuss_client(dev); - if (!adrv->probe) - return -ENODEV; return adrv->probe(adev); } @@ -1208,6 +1206,9 @@ static struct bus_type anybus_bus = { int anybuss_client_driver_register(struct anybuss_client_driver *drv) { + if (!drv->probe) + return -ENODEV; + drv->driver.bus = &anybus_bus; return driver_register(&drv->driver); }