From 2bb7eae8be12e8510fdb00aca6886b91ce72cb25 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 Oct 2014 15:24:57 +0800 Subject: [PATCH] greybus: battery: some hooking up to the greybus core Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/battery-gb.c | 13 ++++++++----- drivers/staging/greybus/connection.c | 6 ++++-- drivers/staging/greybus/greybus.h | 1 + drivers/staging/greybus/greybus_manifest.h | 1 + drivers/staging/greybus/operation.c | 1 + 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/staging/greybus/battery-gb.c b/drivers/staging/greybus/battery-gb.c index 685cff5ff9e8..3288101c6319 100644 --- a/drivers/staging/greybus/battery-gb.c +++ b/drivers/staging/greybus/battery-gb.c @@ -18,7 +18,10 @@ struct gb_battery { // we will want to keep the battery stats in here as we will be getting // updates from the SVC "on the fly" so we don't have to always go ask // the battery for some information. Hopefully... - struct gb_module *gmod; + struct gb_connection *connection; + u8 version_major; + u8 version_minor; + }; #define to_gb_battery(x) container_of(x, struct gb_battery, bat) @@ -111,8 +114,7 @@ static enum power_supply_property battery_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, }; -int gb_battery_probe(struct gb_module *gmod, - const struct greybus_module_id *id) +int gb_battery_device_init(struct gb_connection *connection) { struct gb_battery *gb; struct power_supply *b; @@ -122,6 +124,8 @@ int gb_battery_probe(struct gb_module *gmod, if (!gb) return -ENOMEM; + gb->connection = connection; // FIXME refcount! + b = &gb->bat; // FIXME - get a better (i.e. unique) name // FIXME - anything else needs to be set? @@ -131,12 +135,11 @@ int gb_battery_probe(struct gb_module *gmod, b->num_properties = ARRAY_SIZE(battery_props), b->get_property = get_property, - retval = power_supply_register(&gmod->dev, b); + retval = power_supply_register(&connection->interface->gmod->dev, b); if (retval) { kfree(gb); return retval; } - gmod->gb_battery = gb; return 0; } diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index a51b4781a2b6..c9d524b8274b 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -203,10 +203,12 @@ int gb_connection_init(struct gb_connection *connection) switch (connection->protocol) { case GREYBUS_PROTOCOL_I2C: return gb_i2c_device_init(connection); - case GREYBUS_PROTOCOL_CONTROL: - case GREYBUS_PROTOCOL_AP: case GREYBUS_PROTOCOL_GPIO: return gb_gpio_controller_init(connection); + case GREYBUS_PROTOCOL_BATTERY: + return gb_battery_device_init(connection); + case GREYBUS_PROTOCOL_CONTROL: + case GREYBUS_PROTOCOL_AP: case GREYBUS_PROTOCOL_UART: case GREYBUS_PROTOCOL_HID: case GREYBUS_PROTOCOL_VENDOR: diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index d4f5d940eeb1..c09572c70392 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -265,6 +265,7 @@ void gb_deregister_cport_complete(u16 cport_id); extern const struct attribute_group *greybus_module_groups[]; int gb_i2c_device_init(struct gb_connection *connection); +int gb_battery_device_init(struct gb_connection *connection); int gb_gpio_controller_init(struct gb_connection *connection); int gb_tty_init(void); diff --git a/drivers/staging/greybus/greybus_manifest.h b/drivers/staging/greybus/greybus_manifest.h index 2f1249a63abd..62023f8cfb09 100644 --- a/drivers/staging/greybus/greybus_manifest.h +++ b/drivers/staging/greybus/greybus_manifest.h @@ -30,6 +30,7 @@ enum greybus_protocol { GREYBUS_PROTOCOL_I2C = 0x03, GREYBUS_PROTOCOL_UART = 0x04, GREYBUS_PROTOCOL_HID = 0x05, + GREYBUS_PROTOCOL_BATTERY = 0x08, /* ... */ GREYBUS_PROTOCOL_VENDOR = 0xff, }; diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 4cbe33e21254..4639212a96da 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -165,6 +165,7 @@ static gb_operation_recv_handler gb_operation_recv_handlers[] = { [GREYBUS_PROTOCOL_I2C] = gb_operation_recv_none, [GREYBUS_PROTOCOL_UART] = NULL, [GREYBUS_PROTOCOL_HID] = NULL, + [GREYBUS_PROTOCOL_BATTERY] = gb_operation_recv_none, [GREYBUS_PROTOCOL_VENDOR] = NULL, }; -- 2.20.1