struct gb_module *module = NULL;
struct gb_interface *intf = NULL;
struct gb_bundle *bundle = NULL;
+ struct gb_svc *svc = NULL;
if (is_gb_endo(dev)) {
/*
} else if (is_gb_bundle(dev)) {
bundle = to_gb_bundle(dev);
intf = bundle->intf;
+ } else if (is_gb_svc(dev)) {
+ svc = to_gb_svc(dev);
} else {
dev_WARN(dev, "uevent for unknown greybus device \"type\"!\n");
return -EINVAL;
extern struct device_type greybus_module_type;
extern struct device_type greybus_interface_type;
extern struct device_type greybus_bundle_type;
+extern struct device_type greybus_svc_type;
static inline int is_gb_host_device(const struct device *dev)
{
return dev->type == &greybus_bundle_type;
}
+static inline int is_gb_svc(const struct device *dev)
+{
+ return dev->type == &greybus_svc_type;
+}
+
static inline bool cport_id_valid(struct gb_host_device *hd, u16 cport_id)
{
return cport_id != CPORT_ID_BAD && cport_id < hd->num_cports;
#define CPORT_FLAGS_CSD_N BIT(1)
#define CPORT_FLAGS_CSV_N BIT(2)
-enum gb_svc_state {
- GB_SVC_STATE_RESET,
- GB_SVC_STATE_PROTOCOL_VERSION,
- GB_SVC_STATE_SVC_HELLO,
-};
-
-struct gb_svc {
- struct device dev;
-
- struct gb_connection *connection;
- enum gb_svc_state state;
- struct ida device_id_map;
-};
struct svc_hotplug {
struct work_struct work;
static int gb_svc_hello(struct gb_operation *op)
{
struct gb_connection *connection = op->connection;
+ struct gb_svc *svc = connection->private;
struct gb_host_device *hd = connection->hd;
struct gb_svc_hello_request *hello_request;
struct gb_interface *intf;
endo_id = le16_to_cpu(hello_request->endo_id);
interface_id = hello_request->interface_id;
+ ret = device_add(&svc->dev);
+ if (ret) {
+ dev_err(&svc->dev, "failed to register svc device: %d\n", ret);
+ return ret;
+ }
+
/* Setup Endo */
ret = greybus_endo_setup(hd, endo_id, interface_id);
if (ret)
static void gb_svc_release(struct device *dev)
{
- struct gb_svc *svc = container_of(dev, struct gb_svc, dev);
+ struct gb_svc *svc = to_gb_svc(dev);
ida_destroy(&svc->device_id_map);
kfree(svc);
{
struct gb_svc *svc = connection->private;
+ if (device_is_registered(&svc->dev))
+ device_del(&svc->dev);
+
connection->hd->svc = NULL;
connection->private = NULL;
#ifndef __SVC_H
#define __SVC_H
-struct gb_svc;
+enum gb_svc_state {
+ GB_SVC_STATE_RESET,
+ GB_SVC_STATE_PROTOCOL_VERSION,
+ GB_SVC_STATE_SVC_HELLO,
+};
+
+struct gb_svc {
+ struct device dev;
+
+ struct gb_connection *connection;
+ enum gb_svc_state state;
+ struct ida device_id_map;
+};
+#define to_gb_svc(d) container_of(d, struct gb_svc, d)
int gb_svc_intf_reset(struct gb_svc *svc, u8 intf_id);
int gb_svc_connection_create(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,