diff options
| author | Paul Kocialkowski <contact@paulk.fr> | 2014-10-04 23:19:23 +0200 | 
|---|---|---|
| committer | Paul Kocialkowski <contact@paulk.fr> | 2014-10-04 23:22:20 +0200 | 
| commit | 73cde24d9690e2b9d4fb588fa8cc54fa50ef0b3e (patch) | |
| tree | 64cbbe20ecc5493a924b6b26abc79f4bab53118c | |
| parent | eaecd30476c718c432f6cc3be065b16a311e49a3 (diff) | |
| download | hardware_ril_samsung-ril-73cde24d9690e2b9d4fb588fa8cc54fa50ef0b3e.zip hardware_ril_samsung-ril-73cde24d9690e2b9d4fb588fa8cc54fa50ef0b3e.tar.gz hardware_ril_samsung-ril-73cde24d9690e2b9d4fb588fa8cc54fa50ef0b3e.tar.bz2  | |
client: RIL state update delegation, no client destroy, IPC client boot in openreplicant-4.2-0004replicant-4.2-0003
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
| -rw-r--r-- | client.c | 31 | ||||
| -rw-r--r-- | ipc.c | 46 | ||||
| -rw-r--r-- | samsung-ril.h | 1 | ||||
| -rw-r--r-- | srs.c | 1 | 
4 files changed, 42 insertions, 37 deletions
@@ -146,35 +146,26 @@ void *ril_client_thread(void *data)  		if (client->failures) {  			usleep(RIL_CLIENT_RETRY_DELAY); +			RIL_LOCK(); +  			rc = ril_client_close(client); -			if (rc < 0) +			if (rc < 0) { +				RIL_UNLOCK();  				goto failure; - -			if (client->failures > 1) { -				rc = ril_client_destroy(client); -				if (rc < 0) -					goto failure; - -				rc = ril_client_create(client); -				if (rc < 0) -					goto failure;  			}  			rc = ril_client_open(client); -			if (rc < 0) +			if (rc < 0) { +				RIL_UNLOCK();  				goto failure; +			} + +			RIL_UNLOCK();  		}  		rc = client->handlers->loop(client);  		if (rc < 0) {  			RIL_LOGE("%s client loop failed", client->name); - -			if (client->critical) { -				RIL_LOCK(); -				ril_radio_state_update(RADIO_STATE_UNAVAILABLE); -				RIL_UNLOCK(); -			} -  			goto failure;  		} else {  			RIL_LOGE("%s client loop terminated", client->name); @@ -185,9 +176,13 @@ failure:  		client->failures++;  	} while (client->failures < RIL_CLIENT_RETRY_COUNT); +	RIL_LOCK(); +  	ril_client_close(client);  	ril_client_destroy(client); +	RIL_UNLOCK(); +  	RIL_LOGD("Stopped %s client loop", client->name);  	return NULL; @@ -153,7 +153,6 @@ int ipc_fmt_create(struct ril_client *client)  	if (client == NULL)  		return -1; -  	RIL_CLIENT_LOCK(client);  	client->available = 0; @@ -186,12 +185,6 @@ int ipc_fmt_create(struct ril_client *client)  		goto error;  	} -	rc = ipc_client_boot(ipc_client); -	if (rc < 0) { -		RIL_LOGE("Booting %s client failed", client->name); -		goto error; -	} -  	data->ipc_client = ipc_client;  	client->data = (void *) data; @@ -273,6 +266,12 @@ int ipc_fmt_open(struct ril_client *client)  	RIL_CLIENT_LOCK(client);  	if (client->failures != 1) { +		rc = ipc_client_boot(data->ipc_client); +		if (rc < 0) { +			RIL_LOGE("Booting %s client failed", client->name); +			goto error; +		} +  		rc = ipc_client_power_on(data->ipc_client);  		if (rc < 0) {  			RIL_LOGE("Powering on %s client failed", client->name); @@ -286,6 +285,9 @@ int ipc_fmt_open(struct ril_client *client)  		goto error;  	} +	if (client->failures == 1) +		ril_radio_state_update(RADIO_STATE_OFF); +  	eventfd_flush(data->event_fd);  	client->available = 1; @@ -413,7 +415,7 @@ int ipc_fmt_loop(struct ril_client *client)  	while (1) {  		if (!client->available) {  			RIL_LOGE("%s client is not available", client->name); -			return -1; +			goto error;  		}  		fds_array[0] = data->event_fd; @@ -422,19 +424,20 @@ int ipc_fmt_loop(struct ril_client *client)  		rc = ipc_client_poll(data->ipc_client, &fds, NULL);  		if (rc < 0) {  			RIL_LOGE("Polling %s client failed", client->name); -			return -1; +			goto error;  		}  		if (fds.fds[0] == data->event_fd && fds.count > 0) {  			rc = eventfd_recv(data->event_fd, &event);  			if (rc < 0) -				return -1; +				goto error;  			switch (event) {  				case IPC_CLIENT_CLOSE: -					return 0; +					rc = 0; +					goto complete;  				case IPC_CLIENT_IO_ERROR: -					return -1; +					goto error;  			}  		} @@ -455,7 +458,7 @@ int ipc_fmt_loop(struct ril_client *client)  			RIL_CLIENT_UNLOCK(client);  			RIL_UNLOCK(); -			return -1; +			goto error;  		}  		release_wake_lock(RIL_VERSION_STRING); @@ -469,7 +472,7 @@ int ipc_fmt_loop(struct ril_client *client)  			if (message.data != NULL && message.size > 0)  				free(message.data); -			return -1; +			goto error;  		}  		if (client->failures) @@ -479,7 +482,18 @@ int ipc_fmt_loop(struct ril_client *client)  			free(message.data);  	} -	return 0; +	rc = 0; +	goto complete; + +error: +	rc = -1; + +	RIL_LOCK(); +	ril_radio_state_update(RADIO_STATE_UNAVAILABLE); +	RIL_UNLOCK(); + +complete: +	return rc;  }  int ipc_fmt_request_register(struct ril_client *client, int request, @@ -1095,7 +1109,6 @@ struct ril_client_callbacks ipc_rfs_callbacks = {  struct ril_client ipc_fmt_client = {  	.id = RIL_CLIENT_IPC_FMT,  	.name = "IPC FMT", -	.critical = 1,  	.handlers = &ipc_fmt_handlers,  	.callbacks = &ipc_fmt_callbacks,  }; @@ -1103,7 +1116,6 @@ struct ril_client ipc_fmt_client = {  struct ril_client ipc_rfs_client = {  	.id = RIL_CLIENT_IPC_RFS,  	.name = "IPC RFS", -	.critical = 0,  	.handlers = &ipc_rfs_handlers,  	.callbacks = &ipc_rfs_callbacks,  }; diff --git a/samsung-ril.h b/samsung-ril.h index 2879782..7c60449 100644 --- a/samsung-ril.h +++ b/samsung-ril.h @@ -103,7 +103,6 @@ struct ril_client_callbacks {  struct ril_client {  	int id;  	char *name; -	int critical;  	struct ril_client_handlers *handlers;  	struct ril_client_callbacks *callbacks; @@ -1172,7 +1172,6 @@ struct ril_client_callbacks srs_callbacks = {  struct ril_client srs_client = {  	.id = RIL_CLIENT_SRS,  	.name = "SRS", -	.critical = 0,  	.handlers = &srs_handlers,  	.callbacks = &srs_callbacks,  };  | 
