diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-05-11 10:18:01 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-05-13 15:30:05 +0200 |
commit | 050615076699e537b26ed0934e105e78e7f1e765 (patch) | |
tree | 0324727c7a2aaa47e76d5baea810c5872220891d /drivers/staging/greybus/hd.c | |
parent | greybus: es2: fix probe error handling (diff) | |
download | linux-dev-050615076699e537b26ed0934e105e78e7f1e765.tar.xz linux-dev-050615076699e537b26ed0934e105e78e7f1e765.zip |
greybus: es2: clean up CDSI CPort reservation
Clean up the CDSI CPort reservation by adding a host-device helper and
CPort defines.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/hd.c')
-rw-r--r-- | drivers/staging/greybus/hd.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c index f24e06b0d697..b87e086748b2 100644 --- a/drivers/staging/greybus/hd.c +++ b/drivers/staging/greybus/hd.c @@ -39,6 +39,21 @@ static struct attribute *bus_attrs[] = { }; ATTRIBUTE_GROUPS(bus); +int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id) +{ + struct ida *id_map = &hd->cport_id_map; + int ret; + + ret = ida_simple_get(id_map, cport_id, cport_id + 1, GFP_KERNEL); + if (ret < 0) { + dev_err(&hd->dev, "failed to reserve cport %u\n", cport_id); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(gb_hd_cport_reserve); + /* Locking: Caller guarantees serialisation */ int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id) { |