Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Greybus bundles
4 *
5 * Copyright 2014 Google Inc.
6 * Copyright 2014 Linaro Ltd.
7 */
8
9#ifndef __BUNDLE_H
10#define __BUNDLE_H
11
12#include <linux/list.h>
13
14#define BUNDLE_ID_NONE U8_MAX
15
16/* Greybus "public" definitions" */
17struct gb_bundle {
18 struct device dev;
19 struct gb_interface *intf;
20
21 u8 id;
22 u8 class;
23 u8 class_major;
24 u8 class_minor;
25
26 size_t num_cports;
27 struct greybus_descriptor_cport *cport_desc;
28
29 struct list_head connections;
30 u8 *state;
31
32 struct list_head links; /* interface->bundles */
33};
34#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
35
36/* Greybus "private" definitions" */
37struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
38 u8 class);
39int gb_bundle_add(struct gb_bundle *bundle);
40void gb_bundle_destroy(struct gb_bundle *bundle);
41
42/* Bundle Runtime PM wrappers */
43#ifdef CONFIG_PM
44static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
45{
46 int retval;
47
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;
54 }
55
56 return 0;
57}
58
59static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
60{
61 int retval;
62
63 pm_runtime_mark_last_busy(&bundle->dev);
64 retval = pm_runtime_put_autosuspend(&bundle->dev);
65
66 return retval;
67}
68
69static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle)
70{
71 pm_runtime_get_noresume(&bundle->dev);
72}
73
74static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle)
75{
76 pm_runtime_put_noidle(&bundle->dev);
77}
78
79#else
80static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
81{ return 0; }
82static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
83{ return 0; }
84
85static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {}
86static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {}
87#endif
88
89#endif /* __BUNDLE_H */