0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __BUNDLE_H
0010 #define __BUNDLE_H
0011
0012 #include <linux/types.h>
0013 #include <linux/list.h>
0014 #include <linux/pm_runtime.h>
0015 #include <linux/device.h>
0016
0017 #define BUNDLE_ID_NONE U8_MAX
0018
0019
0020 struct gb_bundle {
0021 struct device dev;
0022 struct gb_interface *intf;
0023
0024 u8 id;
0025 u8 class;
0026 u8 class_major;
0027 u8 class_minor;
0028
0029 size_t num_cports;
0030 struct greybus_descriptor_cport *cport_desc;
0031
0032 struct list_head connections;
0033 u8 *state;
0034
0035 struct list_head links;
0036 };
0037 #define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
0038
0039
0040 struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
0041 u8 class);
0042 int gb_bundle_add(struct gb_bundle *bundle);
0043 void gb_bundle_destroy(struct gb_bundle *bundle);
0044
0045
0046 #ifdef CONFIG_PM
0047 static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
0048 {
0049 int retval;
0050
0051 retval = pm_runtime_get_sync(&bundle->dev);
0052 if (retval < 0) {
0053 dev_err(&bundle->dev,
0054 "pm_runtime_get_sync failed: %d\n", retval);
0055 pm_runtime_put_noidle(&bundle->dev);
0056 return retval;
0057 }
0058
0059 return 0;
0060 }
0061
0062 static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
0063 {
0064 int retval;
0065
0066 pm_runtime_mark_last_busy(&bundle->dev);
0067 retval = pm_runtime_put_autosuspend(&bundle->dev);
0068
0069 return retval;
0070 }
0071
0072 static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle)
0073 {
0074 pm_runtime_get_noresume(&bundle->dev);
0075 }
0076
0077 static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle)
0078 {
0079 pm_runtime_put_noidle(&bundle->dev);
0080 }
0081
0082 #else
0083 static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
0084 { return 0; }
0085 static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
0086 { return 0; }
0087
0088 static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {}
0089 static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {}
0090 #endif
0091
0092 #endif