Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / staging / greybus / bundle.h
blobffcfd43802ccbcfefd2c97fade9c12eb592cc005
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Greybus bundles
5 * Copyright 2014 Google Inc.
6 * Copyright 2014 Linaro Ltd.
7 */
9 #ifndef __BUNDLE_H
10 #define __BUNDLE_H
12 #include <linux/list.h>
14 #define BUNDLE_ID_NONE U8_MAX
16 /* Greybus "public" definitions" */
17 struct gb_bundle {
18 struct device dev;
19 struct gb_interface *intf;
21 u8 id;
22 u8 class;
23 u8 class_major;
24 u8 class_minor;
26 size_t num_cports;
27 struct greybus_descriptor_cport *cport_desc;
29 struct list_head connections;
30 u8 *state;
32 struct list_head links; /* interface->bundles */
34 #define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
36 /* Greybus "private" definitions" */
37 struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
38 u8 class);
39 int gb_bundle_add(struct gb_bundle *bundle);
40 void gb_bundle_destroy(struct gb_bundle *bundle);
42 /* Bundle Runtime PM wrappers */
43 #ifdef CONFIG_PM
44 static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
46 int retval;
48 retval = pm_runtime_get_sync(&bundle->dev);
49 if (retval < 0) {
50 dev_err(&bundle->dev,
51 "pm_runtime_get_sync failed: %d\n", retval);
52 pm_runtime_put_noidle(&bundle->dev);
53 return retval;
56 return 0;
59 static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
61 int retval;
63 pm_runtime_mark_last_busy(&bundle->dev);
64 retval = pm_runtime_put_autosuspend(&bundle->dev);
66 return retval;
69 static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle)
71 pm_runtime_get_noresume(&bundle->dev);
74 static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle)
76 pm_runtime_put_noidle(&bundle->dev);
79 #else
80 static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
81 { return 0; }
82 static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
83 { return 0; }
85 static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {}
86 static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {}
87 #endif
89 #endif /* __BUNDLE_H */