Files

93 lines
2.0 KiB
C
Raw Permalink Normal View History

/* SPDX-License-Identifier: GPL-2.0 */
/*
2014-12-12 17:10:17 -05:00
* Greybus bundles
*
* Copyright 2014 Google Inc.
2014-12-12 12:08:42 -06:00
* Copyright 2014 Linaro Ltd.
*/
2014-12-12 17:10:17 -05:00
#ifndef __BUNDLE_H
#define __BUNDLE_H
2019-08-27 16:53:02 +01:00
#include <linux/types.h>
#include <linux/list.h>
2019-08-27 16:53:02 +01:00
#include <linux/pm_runtime.h>
#include <linux/device.h>
2016-06-03 15:55:30 -05:00
#define BUNDLE_ID_NONE U8_MAX
2014-12-12 17:10:17 -05:00
/* Greybus "public" definitions" */
struct gb_bundle {
struct device dev;
struct gb_interface *intf;
2014-10-02 12:30:02 -05:00
u8 id;
2015-04-06 15:49:36 +05:30
u8 class;
u8 class_major;
u8 class_minor;
size_t num_cports;
struct greybus_descriptor_cport *cport_desc;
2014-10-03 14:14:22 -05:00
struct list_head connections;
2015-04-13 19:48:37 +02:00
u8 *state;
2014-12-12 17:10:17 -05:00
struct list_head links; /* interface->bundles */
};
2014-12-12 17:10:17 -05:00
#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
2014-12-12 17:10:17 -05:00
/* Greybus "private" definitions" */
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
2015-04-06 15:49:36 +05:30
u8 class);
int gb_bundle_add(struct gb_bundle *bundle);
2015-06-12 10:21:11 -05:00
void gb_bundle_destroy(struct gb_bundle *bundle);
2016-07-14 15:13:00 -05:00
/* Bundle Runtime PM wrappers */
#ifdef CONFIG_PM
2016-07-14 15:13:00 -05:00
static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
{
int retval;
retval = pm_runtime_get_sync(&bundle->dev);
if (retval < 0) {
dev_err(&bundle->dev,
"pm_runtime_get_sync failed: %d\n", retval);
pm_runtime_put_noidle(&bundle->dev);
return retval;
}
return 0;
}
static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
{
int retval;
pm_runtime_mark_last_busy(&bundle->dev);
retval = pm_runtime_put_autosuspend(&bundle->dev);
return retval;
}
static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle)
{
pm_runtime_get_noresume(&bundle->dev);
}
static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle)
{
pm_runtime_put_noidle(&bundle->dev);
}
#else
static inline int gb_pm_runtime_get_sync(struct gb_bundle *bundle)
{ return 0; }
static inline int gb_pm_runtime_put_autosuspend(struct gb_bundle *bundle)
{ return 0; }
static inline void gb_pm_runtime_get_noresume(struct gb_bundle *bundle) {}
static inline void gb_pm_runtime_put_noidle(struct gb_bundle *bundle) {}
#endif
2014-12-12 17:10:17 -05:00
#endif /* __BUNDLE_H */