diff options
author | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2018-06-19 12:12:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-07 11:24:32 -0400 |
commit | e0772de8a48b69d39624cdf99fac8f4a3fcc387b (patch) | |
tree | 9676bcab57646f829e76bbb038998587677eaf52 /drivers/slimbus | |
parent | ba883d90b1c8eccf8e315bd2a79ce6b0b2420d3b (diff) |
slimbus: core: add of_slim_device_get() helper
On SLIMBus controllers like Qcom NGD(non ported device), controller
can request logical address once the remote side is powered, having a
helper function like this to explicitly enumerate the bus is helpful.
Also codec drivers which are taking to interface device would need
such a helper too.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/slimbus')
-rw-r--r-- | drivers/slimbus/core.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index 7ddfc675b131..88248a4ecad9 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c | |||
@@ -356,6 +356,45 @@ struct slim_device *slim_get_device(struct slim_controller *ctrl, | |||
356 | } | 356 | } |
357 | EXPORT_SYMBOL_GPL(slim_get_device); | 357 | EXPORT_SYMBOL_GPL(slim_get_device); |
358 | 358 | ||
359 | static int of_slim_match_dev(struct device *dev, void *data) | ||
360 | { | ||
361 | struct device_node *np = data; | ||
362 | struct slim_device *sbdev = to_slim_device(dev); | ||
363 | |||
364 | return (sbdev->dev.of_node == np); | ||
365 | } | ||
366 | |||
367 | static struct slim_device *of_find_slim_device(struct slim_controller *ctrl, | ||
368 | struct device_node *np) | ||
369 | { | ||
370 | struct slim_device *sbdev; | ||
371 | struct device *dev; | ||
372 | |||
373 | dev = device_find_child(ctrl->dev, np, of_slim_match_dev); | ||
374 | if (dev) { | ||
375 | sbdev = to_slim_device(dev); | ||
376 | return sbdev; | ||
377 | } | ||
378 | |||
379 | return NULL; | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * of_slim_get_device() - get handle to a device using dt node. | ||
384 | * | ||
385 | * @ctrl: Controller on which this device will be added/queried | ||
386 | * @np: node pointer to device | ||
387 | * | ||
388 | * Return: pointer to a device if it has already reported. Creates a new | ||
389 | * device and returns pointer to it if the device has not yet enumerated. | ||
390 | */ | ||
391 | struct slim_device *of_slim_get_device(struct slim_controller *ctrl, | ||
392 | struct device_node *np) | ||
393 | { | ||
394 | return of_find_slim_device(ctrl, np); | ||
395 | } | ||
396 | EXPORT_SYMBOL_GPL(of_slim_get_device); | ||
397 | |||
359 | static int slim_device_alloc_laddr(struct slim_device *sbdev, | 398 | static int slim_device_alloc_laddr(struct slim_device *sbdev, |
360 | bool report_present) | 399 | bool report_present) |
361 | { | 400 | { |