Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / linux / greybus / bundle.h
blobdf8d88424cb7f177f6389ccb87cb20a21adc4bbc
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/types.h>
13 #include <linux/list.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/device.h>
17 #define BUNDLE_ID_NONE U8_MAX
19 /* Greybus "public" definitions" */
20 struct gb_bundle {
21 struct device dev;
22 struct gb_interface *intf;
24 u8 id;
25 u8 class;
26 u8 class_major;
27 u8 class_minor;
29 size_t num_cports;
30 struct greybus_descriptor_cport *cport_desc;
32 struct list_head connections;
33 u8 *state;
35 struct list_head links; /* interface->bundles */
37 #define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
39 /* Greybus "private" definitions" */
40 struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
41 u8 class);
42 int gb_bundle_add(struct gb_bundle *bundle);
43 void gb_bundle_destroy(struct gb_bundle *bundle);
45 /* Bundle Runtime PM wrappers */
46 #ifdef CONFIG_PM
47 static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
49 int retval;
51 retval = pm_runtime_get_sync(&bundle->dev);
52 if (retval < 0) {
53 dev_err(&bundle->dev,
54 "pm_runtime_get_sync failed: %d\n", retval);
55 pm_runtime_put_noidle(&bundle->dev);
56 return retval;
59 return 0;
62 static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
64 int retval;
66 pm_runtime_mark_last_busy(&bundle->dev);
67 retval = pm_runtime_put_autosuspend(&bundle->dev);
69 return retval;
72 static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle)
74 pm_runtime_get_noresume(&bundle->dev);
77 static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle)
79 pm_runtime_put_noidle(&bundle->dev);
82 #else
83 static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
84 { return 0; }
85 static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
86 { return 0; }
88 static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {}
89 static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {}
90 #endif
92 #endif /* __BUNDLE_H */