Commit 7d81bafa authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: legacy: add private driver data

Allocate private data structure at probe and release at disconnect.

The private data will be used to track the connections managed by the
driver, but for now only holds a count of the number of cports the
bundle has.
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent b53e0c9e
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
#include "protocol.h" #include "protocol.h"
struct legacy_data {
size_t num_cports;
};
static int legacy_connection_get_version(struct gb_connection *connection) static int legacy_connection_get_version(struct gb_connection *connection)
{ {
int ret; int ret;
...@@ -123,11 +128,23 @@ static void legacy_connection_exit(struct gb_connection *connection) ...@@ -123,11 +128,23 @@ static void legacy_connection_exit(struct gb_connection *connection)
static int legacy_probe(struct gb_bundle *bundle, static int legacy_probe(struct gb_bundle *bundle,
const struct greybus_bundle_id *id) const struct greybus_bundle_id *id)
{ {
struct legacy_data *data;
struct gb_connection *connection; struct gb_connection *connection;
int ret; int ret;
dev_dbg(&bundle->dev, "%s - bundle class = 0x%02x\n", __func__, data = kzalloc(sizeof(*data), GFP_KERNEL);
bundle->class); if (!data)
return -ENOMEM;
data->num_cports = 0;
list_for_each_entry(connection, &bundle->connections, bundle_links)
data->num_cports++;
dev_dbg(&bundle->dev,
"%s - bundle class = 0x%02x, num_cports = %zu\n",
__func__, bundle->class, data->num_cports);
greybus_set_drvdata(bundle, data);
list_for_each_entry(connection, &bundle->connections, bundle_links) { list_for_each_entry(connection, &bundle->connections, bundle_links) {
dev_dbg(&bundle->dev, "enabling connection %s\n", dev_dbg(&bundle->dev, "enabling connection %s\n",
...@@ -145,12 +162,14 @@ static int legacy_probe(struct gb_bundle *bundle, ...@@ -145,12 +162,14 @@ static int legacy_probe(struct gb_bundle *bundle,
bundle_links) { bundle_links) {
legacy_connection_exit(connection); legacy_connection_exit(connection);
} }
kfree(data);
return ret; return ret;
} }
static void legacy_disconnect(struct gb_bundle *bundle) static void legacy_disconnect(struct gb_bundle *bundle)
{ {
struct legacy_data *data = greybus_get_drvdata(bundle);
struct gb_connection *connection; struct gb_connection *connection;
dev_dbg(&bundle->dev, "%s - bundle class = 0x%02x\n", __func__, dev_dbg(&bundle->dev, "%s - bundle class = 0x%02x\n", __func__,
...@@ -160,6 +179,8 @@ static void legacy_disconnect(struct gb_bundle *bundle) ...@@ -160,6 +179,8 @@ static void legacy_disconnect(struct gb_bundle *bundle)
bundle_links) { bundle_links) {
legacy_connection_exit(connection); legacy_connection_exit(connection);
} }
kfree(data);
} }
static const struct greybus_bundle_id legacy_id_table[] = { static const struct greybus_bundle_id legacy_id_table[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment