Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 542f27a1 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

greybus: Merge branch 'master' into branch 'svc'.



This required some hand-tweaking in connection.c, hopefully I got it all
correct...

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parents 067906f6 bf814547
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -12,37 +12,9 @@
#include "greybus.h"
#include "audio.h"

#define GB_I2S_MGMT_VERSION_MAJOR		0x00
#define GB_I2S_MGMT_VERSION_MINOR		0x01

#define GB_I2S_DATA_VERSION_MAJOR		0x00
#define GB_I2S_DATA_VERSION_MINOR		0x01

/***********************************
 * GB I2S helper functions
 ***********************************/
int gb_i2s_mgmt_get_version(struct gb_connection *connection)
{
	struct gb_protocol_version_response response;

	memset(&response, 0, sizeof(response));
	return gb_protocol_get_version(connection,
				       GB_I2S_MGMT_TYPE_PROTOCOL_VERSION,
				       NULL, 0, &response,
				       GB_I2S_MGMT_VERSION_MAJOR);
}

int gb_i2s_data_get_version(struct gb_connection *connection)
{
	struct gb_protocol_version_response response;

	memset(&response, 0, sizeof(response));
	return gb_protocol_get_version(connection,
				       GB_I2S_DATA_TYPE_PROTOCOL_VERSION,
				       NULL, 0, &response,
				       GB_I2S_DATA_VERSION_MAJOR);
}

int gb_i2s_mgmt_activate_cport(struct gb_connection *connection,
				      uint16_t cport)
{
+3 −13
Original line number Diff line number Diff line
@@ -225,12 +225,6 @@ static int gb_i2s_transmitter_connection_init(struct gb_connection *connection)
		goto out_card;
	}

	ret = gb_i2s_data_get_version(connection);
	if (ret) {
		pr_err("i2s data get_version() failed: %d\n", ret);
		goto out_get_ver;
	}

#if USE_RT5645
	rt5647_info.addr = RT5647_I2C_ADDR;
	strlcpy(rt5647_info.type, "rt5647", I2C_NAME_SIZE);
@@ -251,8 +245,10 @@ static int gb_i2s_transmitter_connection_init(struct gb_connection *connection)

	return 0;

#if USE_RT5645
out_get_ver:
	platform_device_unregister(&snd_dev->card);
#endif
out_card:
	platform_device_unregister(&snd_dev->cpu_dai);
out_dai:
@@ -296,12 +292,6 @@ static int gb_i2s_mgmt_connection_init(struct gb_connection *connection)
	connection->private = snd_dev;
	spin_unlock_irqrestore(&snd_dev->lock, flags);

	ret = gb_i2s_mgmt_get_version(connection);
	if (ret) {
		pr_err("i2s mgmt get_version() failed: %d\n", ret);
		goto err_free_snd_dev;
	}

	ret = gb_i2s_mgmt_get_cfgs(snd_dev, connection);
	if (ret) {
		pr_err("can't get i2s configurations: %d\n", ret);
@@ -357,7 +347,7 @@ static int gb_i2s_mgmt_report_event_recv(u8 type, struct gb_operation *op)
	}

	if (op->request->payload_size < sizeof(*req)) {
		dev_err(&connection->dev, "Short request received: %zu, %zu\n",
		dev_err(&connection->dev, "Short request received (%zu < %zu)\n",
			op->request->payload_size, sizeof(*req));
		return -EINVAL;
	}
+0 −2
Original line number Diff line number Diff line
@@ -75,8 +75,6 @@ struct gb_snd {
/*
 * GB I2S cmd functions
 */
int gb_i2s_mgmt_get_version(struct gb_connection *connection);
int gb_i2s_data_get_version(struct gb_connection *connection);
int gb_i2s_mgmt_activate_cport(struct gb_connection *connection,
				      uint16_t cport);
int gb_i2s_mgmt_deactivate_cport(struct gb_connection *connection,
+2 −14
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ struct gb_battery {
	// updates from the SVC "on the fly" so we don't have to always go ask
	// the battery for some information.  Hopefully...
	struct gb_connection *connection;
	u8 version_major;
	u8 version_minor;

};

@@ -42,8 +40,6 @@ struct gb_battery {
#define	GB_BATTERY_VERSION_MINOR		0x01

/* Greybus battery request types */
#define	GB_BATTERY_TYPE_INVALID			0x00
#define	GB_BATTERY_TYPE_PROTOCOL_VERSION	0x01
#define	GB_BATTERY_TYPE_TECHNOLOGY		0x02
#define	GB_BATTERY_TYPE_STATUS			0x03
#define	GB_BATTERY_TYPE_MAX_VOLTAGE		0x04
@@ -94,9 +90,6 @@ struct gb_battery_voltage_response {
	__le32	voltage;
};

/* Define get_version() routine */
define_get_version(gb_battery, BATTERY);

static int get_tech(struct gb_battery *gb)
{
	struct gb_battery_technology_response tech_response;
@@ -345,12 +338,7 @@ static int gb_battery_connection_init(struct gb_connection *connection)
	gb->connection = connection;
	connection->private = gb;

	/* Check the version */
	retval = get_version(gb);
	if (retval)
		goto out;
	retval = init_and_register(connection, gb);
out:
	if (retval)
		kfree(gb);

@@ -372,8 +360,8 @@ static void gb_battery_connection_exit(struct gb_connection *connection)
static struct gb_protocol battery_protocol = {
	.name			= "battery",
	.id			= GREYBUS_PROTOCOL_BATTERY,
	.major			= 0,
	.minor			= 1,
	.major			= GB_BATTERY_VERSION_MAJOR,
	.minor			= GB_BATTERY_VERSION_MINOR,
	.connection_init	= gb_battery_connection_init,
	.connection_exit	= gb_battery_connection_exit,
	.request_recv		= NULL,	/* no incoming requests */
+45 −23
Original line number Diff line number Diff line
@@ -335,6 +335,28 @@ void gb_connection_destroy(struct gb_connection *connection)
	device_unregister(&connection->dev);
}

static void gb_connection_disconnected(struct gb_connection *connection)
{
	struct gb_control *control;
	int cport_id = connection->intf_cport_id;
	int ret;

	/*
	 * Inform Interface about In-active CPorts. We don't need to do this
	 * operation for control cport.
	 */
	if ((cport_id == GB_CONTROL_CPORT_ID) ||
	    (connection->hd_cport_id == GB_SVC_CPORT_ID))
		return;

	control = connection->bundle->intf->control;

	ret = gb_control_disconnected_operation(control, cport_id);
	if (ret)
		dev_warn(&connection->dev,
			"Failed to disconnect CPort-%d (%d)\n", cport_id, ret);
}

int gb_connection_init(struct gb_connection *connection)
{
	int cport_id = connection->intf_cport_id;
@@ -367,20 +389,35 @@ int gb_connection_init(struct gb_connection *connection)
	connection->state = GB_CONNECTION_STATE_ENABLED;
	spin_unlock_irq(&connection->lock);

	ret = connection->protocol->connection_init(connection);
	/*
	 * Request protocol version supported by the module. We don't need to do
	 * this for SVC as that is initiated by the SVC.
	 */
	if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
		ret = gb_protocol_get_version(connection, NULL, 0);
		if (ret) {
			dev_err(&connection->dev,
				"Failed to get version CPort-%d (%d)\n",
				cport_id, ret);
			goto disconnect;
		}
	}

	ret = connection->protocol->connection_init(connection);
	if (!ret)
		return 0;

disconnect:
	spin_lock_irq(&connection->lock);
	connection->state = GB_CONNECTION_STATE_ERROR;
	spin_unlock_irq(&connection->lock);
	}

	gb_connection_disconnected(connection);
	return ret;
}

void gb_connection_exit(struct gb_connection *connection)
{
	int cport_id = connection->intf_cport_id;

	if (!connection->protocol) {
		dev_warn(&connection->dev, "exit without protocol.\n");
		return;
@@ -397,22 +434,7 @@ void gb_connection_exit(struct gb_connection *connection)
	gb_connection_cancel_operations(connection, -ESHUTDOWN);

	connection->protocol->connection_exit(connection);

	/*
	 * Inform Interface about In-active CPorts. We don't need to do this
	 * operation for control cport.
	 */
	if (cport_id != GB_CONTROL_CPORT_ID &&
	    connection->hd_cport_id != GB_SVC_CPORT_ID) {
		struct gb_control *control = connection->bundle->intf->control;
		int ret;

		ret = gb_control_disconnected_operation(control, cport_id);
		if (ret)
			dev_warn(&connection->dev,
				 "Failed to disconnect CPort-%d (%d)\n",
				 cport_id, ret);
	}
	gb_connection_disconnected(connection);
}

void gb_hd_connections_exit(struct greybus_host_device *hd)
Loading