summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2019-01-14 08:44:48 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-22 07:34:35 -0500
commit380c62466d024cd478adef4a3cb6ad2091a8af15 (patch)
tree930603a4b689644dd1f2f71636068d6d53eba16d
parentcfb32101ba148ad772a2556fc5086069c59d882f (diff)
slimbus: core: use slim_device_update_status() to update status
use slim_device_update_status() instead of directly calling the device_status() callback. Move slim_device_update_status() before probe to avoid forward declaration too. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/slimbus/core.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c
index 1ba08b5f2e78..8ffdc9876223 100644
--- a/drivers/slimbus/core.c
+++ b/drivers/slimbus/core.c
@@ -42,6 +42,23 @@ static int slim_device_match(struct device *dev, struct device_driver *drv)
42 return !!slim_match(sbdrv->id_table, sbdev); 42 return !!slim_match(sbdrv->id_table, sbdev);
43} 43}
44 44
45static void slim_device_update_status(struct slim_device *sbdev,
46 enum slim_device_status status)
47{
48 struct slim_driver *sbdrv;
49
50 if (sbdev->status == status)
51 return;
52
53 sbdev->status = status;
54 if (!sbdev->dev.driver)
55 return;
56
57 sbdrv = to_slim_driver(sbdev->dev.driver);
58 if (sbdrv->device_status)
59 sbdrv->device_status(sbdev, sbdev->status);
60}
61
45static int slim_device_probe(struct device *dev) 62static int slim_device_probe(struct device *dev)
46{ 63{
47 struct slim_device *sbdev = to_slim_device(dev); 64 struct slim_device *sbdev = to_slim_device(dev);
@@ -55,8 +72,7 @@ static int slim_device_probe(struct device *dev)
55 /* try getting the logical address after probe */ 72 /* try getting the logical address after probe */
56 ret = slim_get_logical_addr(sbdev); 73 ret = slim_get_logical_addr(sbdev);
57 if (!ret) { 74 if (!ret) {
58 if (sbdrv->device_status) 75 slim_device_update_status(sbdev, SLIM_DEVICE_STATUS_UP);
59 sbdrv->device_status(sbdev, sbdev->status);
60 } else { 76 } else {
61 dev_err(&sbdev->dev, "Failed to get logical address\n"); 77 dev_err(&sbdev->dev, "Failed to get logical address\n");
62 ret = -EPROBE_DEFER; 78 ret = -EPROBE_DEFER;
@@ -297,23 +313,6 @@ int slim_unregister_controller(struct slim_controller *ctrl)
297} 313}
298EXPORT_SYMBOL_GPL(slim_unregister_controller); 314EXPORT_SYMBOL_GPL(slim_unregister_controller);
299 315
300static void slim_device_update_status(struct slim_device *sbdev,
301 enum slim_device_status status)
302{
303 struct slim_driver *sbdrv;
304
305 if (sbdev->status == status)
306 return;
307
308 sbdev->status = status;
309 if (!sbdev->dev.driver)
310 return;
311
312 sbdrv = to_slim_driver(sbdev->dev.driver);
313 if (sbdrv->device_status)
314 sbdrv->device_status(sbdev, sbdev->status);
315}
316
317/** 316/**
318 * slim_report_absent() - Controller calls this function when a device 317 * slim_report_absent() - Controller calls this function when a device
319 * reports absent, OR when the device cannot be communicated with 318 * reports absent, OR when the device cannot be communicated with