static void gb_connection_release(struct device *dev) { struct gb_connection *connection = to_gb_connection(dev); destroy_workqueue(connection->wq); kfree(connection); }
static ssize_t protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf) { struct gb_connection *connection = to_gb_connection(dev); if (connection->protocol) return sprintf(buf, "%d\n", connection->protocol->id); else return -EINVAL; }
static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf) { struct gb_connection *connection = to_gb_connection(dev); enum gb_connection_state state; spin_lock_irq(&connection->lock); state = connection->state; spin_unlock_irq(&connection->lock); return sprintf(buf, "%d\n", state); }
static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct gb_module *module = NULL; struct gb_interface *intf = NULL; struct gb_bundle *bundle = NULL; struct gb_connection *connection = NULL; if (is_gb_endo(dev)) { /* * Not much to do for an endo, just fall through, as the * "default" attributes are good enough for us. */ return 0; } if (is_gb_module(dev)) { module = to_gb_module(dev); } else if (is_gb_interface(dev)) { intf = to_gb_interface(dev); } else if (is_gb_bundle(dev)) { bundle = to_gb_bundle(dev); intf = bundle->intf; } else if (is_gb_connection(dev)) { connection = to_gb_connection(dev); bundle = connection->bundle; intf = bundle->intf; } else { dev_WARN(dev, "uevent for unknown greybus device \"type\"!\n"); return -EINVAL; } if (connection) { // FIXME // add a uevent that can "load" a connection type return 0; } if (bundle) { // FIXME // add a uevent that can "load" a bundle type // This is what we need to bind a driver to so use the info // in gmod here as well return 0; } // FIXME // "just" a module, be vague here, nothing binds to a module except // the greybus core, so there's not much, if anything, we need to // advertise. return 0; }
static ssize_t ap_cport_id_show(struct device *dev, struct device_attribute *attr, char *buf) { struct gb_connection *connection = to_gb_connection(dev); return sprintf(buf, "%hu\n", connection->hd_cport_id); }