summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-07-03 22:10:00 +0200
committerPaul Kocialkowski <contact@paulk.fr>2013-07-03 22:10:00 +0200
commit570caee37e13f0dcd266f7817b47ed9799f24f9e (patch)
treeacd2dcdb9663fa9622a256272333899e57cf17ab
parent9b543c7d0610d6db3cfe695f7928889436e8a191 (diff)
downloadhardware_ril_samsung-ril-570caee37e13f0dcd266f7817b47ed9799f24f9e.zip
hardware_ril_samsung-ril-570caee37e13f0dcd266f7817b47ed9799f24f9e.tar.gz
hardware_ril_samsung-ril-570caee37e13f0dcd266f7817b47ed9799f24f9e.tar.bz2
Follow changes in libsamsung-ipc API
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--gprs.c52
-rw-r--r--ipc.c231
-rw-r--r--ipc.h5
-rw-r--r--rfs.c16
-rw-r--r--samsung-ril.h2
5 files changed, 80 insertions, 226 deletions
diff --git a/gprs.c b/gprs.c
index 4da8969..ded89c7 100644
--- a/gprs.c
+++ b/gprs.c
@@ -173,7 +173,6 @@ struct ril_gprs_connection *ril_gprs_connection_start(void)
{
struct ipc_client_gprs_capabilities gprs_capabilities;
struct ril_gprs_connection *gprs_connection;
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
struct list_head *list;
int cid, cid_max;
@@ -183,12 +182,7 @@ struct ril_gprs_connection *ril_gprs_connection_start(void)
if (ril_data.ipc_fmt_client == NULL || ril_data.ipc_fmt_client->data == NULL)
return NULL;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_fmt_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return NULL;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_fmt_client->data;
ipc_client_gprs_get_capabilities(ipc_client, &gprs_capabilities);
cid_max = gprs_capabilities.cid_max;
@@ -369,7 +363,6 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length)
struct ril_gprs_connection *gprs_connection = NULL;
struct ipc_client_gprs_capabilities gprs_capabilities;
struct ipc_gprs_port_list port_list;
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
char *username = NULL;
@@ -382,12 +375,7 @@ void ril_request_setup_data_call(RIL_Token t, void *data, int length)
if (ril_data.ipc_fmt_client == NULL || ril_data.ipc_fmt_client->data == NULL)
goto error;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_fmt_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- goto error;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_fmt_client->data;
apn = ((char **) data)[2];
username = ((char **) data)[3];
@@ -552,7 +540,6 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection,
char **setup_data_call_response)
#endif
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
struct ipc_gprs_ip_configuration *ip_configuration;
@@ -574,12 +561,7 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection,
if (ril_data.ipc_fmt_client == NULL || ril_data.ipc_fmt_client->data == NULL)
return -EINVAL;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_fmt_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return -EINVAL;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_fmt_client->data;
ip_configuration = &(gprs_connection->ip_configuration);
@@ -610,12 +592,10 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection,
(ip_configuration->dns2)[2],
(ip_configuration->dns2)[3]);
- if (ipc_client_gprs_handlers_available(ipc_client)) {
- rc = ipc_client_gprs_activate(ipc_client, gprs_connection->cid);
- if (rc < 0) {
- // This is not a critical issue
- LOGE("Failed to activate interface!");
- }
+ rc = ipc_client_gprs_activate(ipc_client, gprs_connection->cid);
+ if (rc < 0) {
+ // This is not a critical issue
+ LOGE("Failed to activate interface!");
}
interface = ipc_client_gprs_get_iface(ipc_client, gprs_connection->cid);
@@ -690,7 +670,6 @@ int ipc_gprs_connection_enable(struct ril_gprs_connection *gprs_connection,
int ipc_gprs_connection_disable(struct ril_gprs_connection *gprs_connection)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
char *interface;
@@ -702,12 +681,7 @@ int ipc_gprs_connection_disable(struct ril_gprs_connection *gprs_connection)
if (ril_data.ipc_fmt_client == NULL || ril_data.ipc_fmt_client->data == NULL)
return -EINVAL;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_fmt_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return -EINVAL;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_fmt_client->data;
if (gprs_connection->interface == NULL) {
interface = ipc_client_gprs_get_iface(ipc_client, gprs_connection->cid);
@@ -731,12 +705,10 @@ int ipc_gprs_connection_disable(struct ril_gprs_connection *gprs_connection)
LOGE("ifc_down failed");
}
- if (ipc_client_gprs_handlers_available(ipc_client)) {
- rc = ipc_client_gprs_deactivate(ipc_client, gprs_connection->cid);
- if (rc < 0) {
- // This is not a critical issue
- LOGE("Failed to deactivate interface!");
- }
+ rc = ipc_client_gprs_deactivate(ipc_client, gprs_connection->cid);
+ if (rc < 0) {
+ // This is not a critical issue
+ LOGE("Could not deactivate interface!");
}
return 0;
diff --git a/ipc.c b/ipc.c
index 55a6cfe..b43e1c9 100644
--- a/ipc.c
+++ b/ipc.c
@@ -22,13 +22,12 @@
#include <utils/Log.h>
#include "samsung-ril.h"
-#include <radio.h>
/*
* IPC shared
*/
-void ipc_log_handler(const char *message, void *user_data)
+void ipc_log_handler(void *log_data, const char *message)
{
LOGD("ipc: %s", message);
}
@@ -39,18 +38,12 @@ void ipc_log_handler(const char *message, void *user_data)
void ipc_fmt_send(const unsigned short command, const char type, unsigned char *data, const int length, unsigned char mseq)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
if (ril_data.ipc_fmt_client == NULL || ril_data.ipc_fmt_client->data == NULL)
return;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_fmt_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_fmt_client->data;
RIL_CLIENT_LOCK(ril_data.ipc_fmt_client);
ipc_client_send(ipc_client, command, type, data, length, mseq);
@@ -59,51 +52,36 @@ void ipc_fmt_send(const unsigned short command, const char type, unsigned char *
int ipc_fmt_read_loop(struct ril_client *client)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
-
struct ipc_message_info info;
- int ipc_client_fd;
- fd_set fds;
-
- if (client == NULL || client->data == NULL)
- return -EINVAL;
- ipc_client_data = (struct ipc_client_data *) client->data;
+ int rc;
- if (ipc_client_data->ipc_client == NULL)
+ if (client == NULL || client->data == NULL)
return -EINVAL;
- ipc_client = ipc_client_data->ipc_client;
- ipc_client_fd = ipc_client_data->ipc_client_fd;
+ ipc_client = (struct ipc_client *) client->data;
while (1) {
- if (ipc_client_fd < 0) {
- LOGE("IPC FMT client fd is negative, aborting");
+ rc = ipc_client_poll(ipc_client, NULL);
+ if (rc < 0) {
+ LOGE("IPC FMT client poll failed, aborting");
return -1;
}
- FD_ZERO(&fds);
- FD_SET(ipc_client_fd, &fds);
+ memset(&info, 0, sizeof(info));
- select(FD_SETSIZE, &fds, NULL, NULL, NULL);
-
- if (FD_ISSET(ipc_client_fd, &fds)) {
- memset(&info, 0, sizeof(info));
-
- RIL_CLIENT_LOCK(client);
- if (ipc_client_recv(ipc_client, &info) < 0) {
- RIL_CLIENT_UNLOCK(client);
- LOGE("IPC FMT recv failed, aborting");
- return -1;
- }
+ RIL_CLIENT_LOCK(client);
+ if (ipc_client_recv(ipc_client, &info) < 0) {
RIL_CLIENT_UNLOCK(client);
+ LOGE("IPC FMT recv failed, aborting");
+ return -1;
+ }
+ RIL_CLIENT_UNLOCK(client);
- ipc_fmt_dispatch(&info);
+ ipc_fmt_dispatch(&info);
- if (info.data != NULL && info.length > 0)
- free(info.data);
- }
+ ipc_client_response_free(ipc_client, &info);
}
return 0;
@@ -111,10 +89,8 @@ int ipc_fmt_read_loop(struct ril_client *client)
int ipc_fmt_create(struct ril_client *client)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
- int ipc_client_fd;
int rc;
if (client == NULL)
@@ -122,40 +98,33 @@ int ipc_fmt_create(struct ril_client *client)
LOGD("Creating new FMT client");
- ipc_client_data = (struct ipc_client_data *) calloc(1, sizeof(struct ipc_client_data));
- ipc_client_data->ipc_client_fd = -1;
-
- client->data = (void *) ipc_client_data;
-
- ipc_client = ipc_client_new(IPC_CLIENT_TYPE_FMT);
+ ipc_client = ipc_client_create(IPC_CLIENT_TYPE_FMT);
if (ipc_client == NULL) {
LOGE("FMT client creation failed");
goto error_client_create;
}
- ipc_client_data->ipc_client = ipc_client;
+ client->data = (void *) ipc_client;
LOGD("Setting log handler");
- rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL);
+ rc = ipc_client_set_log_callback(ipc_client, ipc_log_handler, NULL);
if (rc < 0) {
LOGE("Setting log handler failed");
- goto error_log_handler;
+ goto error_log_callback;
}
- // ipc_client_set_handlers
-
- LOGD("Creating handlers common data");
+ LOGD("Creating data");
- rc = ipc_client_create_handlers_common_data(ipc_client);
+ rc = ipc_client_data_create(ipc_client);
if (rc < 0) {
- LOGE("Creating handlers common data failed");
- goto error_handlers_create;
+ LOGE("Creating data failed");
+ goto error_data_create;
}
- LOGD("Starting modem bootstrap");
+ LOGD("Starting bootstrap");
- rc = ipc_client_bootstrap_modem(ipc_client);
+ rc = ipc_client_bootstrap(ipc_client);
if (rc < 0) {
LOGE("Modem bootstrap failed");
goto error_bootstrap;
@@ -169,16 +138,6 @@ int ipc_fmt_create(struct ril_client *client)
goto error_open;
}
- LOGD("Obtaining ipc_client_fd");
-
- ipc_client_fd = ipc_client_get_handlers_common_data_fd(ipc_client);
- if (ipc_client_fd < 0) {
- LOGE("%s: client_fmt_fd is negative, aborting", __func__);
- goto error_get_fd;
- }
-
- ipc_client_data->ipc_client_fd = ipc_client_fd;
-
LOGD("Client power on...");
rc = ipc_client_power_on(ipc_client);
@@ -200,17 +159,13 @@ error_get_fd:
error_open:
error_bootstrap:
- ipc_client_destroy_handlers_common_data(ipc_client);
+ ipc_client_data_destroy(ipc_client);
-error_handlers_create:
-error_log_handler:
- ipc_client_free(ipc_client);
+error_data_create:
+error_log_callback:
+ ipc_client_destroy(ipc_client);
error_client_create:
- ipc_client_data->ipc_client = NULL;
- ipc_client_data->ipc_client_fd = -1;
-
- free(ipc_client_data);
client->data = NULL;
return -1;
@@ -218,7 +173,6 @@ error_client_create:
int ipc_fmt_destroy(struct ril_client *client)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
int rc;
@@ -228,22 +182,17 @@ int ipc_fmt_destroy(struct ril_client *client)
return 0;
}
- ipc_client_data = (struct ipc_client_data *) client->data;
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) client->data;
LOGD("Destroying ipc fmt client");
if (ipc_client != NULL) {
ipc_client_power_off(ipc_client);
ipc_client_close(ipc_client);
- ipc_client_destroy_handlers_common_data(ipc_client);
- ipc_client_free(ipc_client);
+ ipc_client_data_destroy(ipc_client);
+ ipc_client_destroy(ipc_client);
}
- ipc_client_data->ipc_client = NULL;
- ipc_client_data->ipc_client_fd = -1;
-
- free(ipc_client_data);
client->data = NULL;
return 0;
@@ -255,18 +204,12 @@ int ipc_fmt_destroy(struct ril_client *client)
void ipc_rfs_send(const unsigned short command, unsigned char *data, const int length, unsigned char mseq)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
if (ril_data.ipc_rfs_client == NULL || ril_data.ipc_rfs_client->data == NULL)
return;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_rfs_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_rfs_client->data;
RIL_CLIENT_LOCK(ril_data.ipc_rfs_client);
ipc_client_send(ipc_client, command, 0, data, length, mseq);
@@ -275,51 +218,36 @@ void ipc_rfs_send(const unsigned short command, unsigned char *data, const int l
int ipc_rfs_read_loop(struct ril_client *client)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
-
struct ipc_message_info info;
- int ipc_client_fd;
- fd_set fds;
-
- if (client == NULL || client->data == NULL)
- return -EINVAL;
- ipc_client_data = (struct ipc_client_data *) client->data;
+ int rc;
- if (ipc_client_data->ipc_client == NULL)
+ if (client == NULL || client->data == NULL)
return -EINVAL;
- ipc_client = ipc_client_data->ipc_client;
- ipc_client_fd = ipc_client_data->ipc_client_fd;
+ ipc_client = (struct ipc_client *) client->data;
while (1) {
- if (ipc_client_fd < 0) {
- LOGE("IPC RFS client fd is negative, aborting");
+ rc = ipc_client_poll(ipc_client, NULL);
+ if (rc < 0) {
+ LOGE("IPC RFS client poll failed, aborting");
return -1;
}
- FD_ZERO(&fds);
- FD_SET(ipc_client_fd, &fds);
+ memset(&info, 0, sizeof(info));
- select(FD_SETSIZE, &fds, NULL, NULL, NULL);
-
- if (FD_ISSET(ipc_client_fd, &fds)) {
- memset(&info, 0, sizeof(info));
-
- RIL_CLIENT_LOCK(client);
- if (ipc_client_recv(ipc_client, &info) < 0) {
- RIL_CLIENT_UNLOCK(client);
- LOGE("IPC RFS recv failed, aborting");
- return -1;
- }
+ RIL_CLIENT_LOCK(client);
+ if (ipc_client_recv(ipc_client, &info) < 0) {
RIL_CLIENT_UNLOCK(client);
+ LOGE("IPC RFS recv failed, aborting");
+ return -1;
+ }
+ RIL_CLIENT_UNLOCK(client);
- ipc_rfs_dispatch(&info);
+ ipc_rfs_dispatch(&info);
- if (info.data != NULL && info.length > 0)
- free(info.data);
- }
+ ipc_client_response_free(ipc_client, &info);
}
return 0;
@@ -327,10 +255,8 @@ int ipc_rfs_read_loop(struct ril_client *client)
int ipc_rfs_create(struct ril_client *client)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
- int ipc_client_fd;
int rc;
if (client == NULL)
@@ -338,35 +264,28 @@ int ipc_rfs_create(struct ril_client *client)
LOGD("Creating new RFS client");
- ipc_client_data = (struct ipc_client_data *) calloc(1, sizeof(struct ipc_client_data));
- ipc_client_data->ipc_client_fd = -1;
-
- client->data = (void *) ipc_client_data;
-
- ipc_client = ipc_client_new(IPC_CLIENT_TYPE_RFS);
+ ipc_client = ipc_client_create(IPC_CLIENT_TYPE_RFS);
if (ipc_client == NULL) {
LOGE("RFS client creation failed");
goto error_client_create;
}
- ipc_client_data->ipc_client = ipc_client;
+ client->data = (void *) ipc_client;
LOGD("Setting log handler");
- rc = ipc_client_set_log_handler(ipc_client, ipc_log_handler, NULL);
+ rc = ipc_client_set_log_callback(ipc_client, ipc_log_handler, NULL);
if (rc < 0) {
LOGE("Setting log handler failed");
- goto error_log_handler;
+ goto error_log_callback;
}
- // ipc_client_set_handlers
-
- LOGD("Creating handlers common data");
+ LOGD("Creating data");
- rc = ipc_client_create_handlers_common_data(ipc_client);
+ rc = ipc_client_data_create(ipc_client);
if (rc < 0) {
- LOGE("Creating handlers common data failed");
- goto error_handlers_create;
+ LOGE("Creating data failed");
+ goto error_data_create;
}
LOGD("Client open...");
@@ -377,16 +296,6 @@ int ipc_rfs_create(struct ril_client *client)
goto error_open;
}
- LOGD("Obtaining ipc_client_fd");
-
- ipc_client_fd = ipc_client_get_handlers_common_data_fd(ipc_client);
- if (ipc_client_fd < 0) {
- LOGE("%s: client_rfs_fd is negative, aborting", __func__);
- goto error_get_fd;
- }
-
- ipc_client_data->ipc_client_fd = ipc_client_fd;
-
LOGD("IPC RFS client done");
return 0;
@@ -396,17 +305,13 @@ error_get_fd:
ipc_client_close(ipc_client);
error_open:
- ipc_client_destroy_handlers_common_data(ipc_client);
+ ipc_client_data_destroy(ipc_client);
-error_handlers_create:
-error_log_handler:
- ipc_client_free(ipc_client);
+error_data_create:
+error_log_callback:
+ ipc_client_destroy(ipc_client);
error_client_create:
- ipc_client_data->ipc_client = NULL;
- ipc_client_data->ipc_client_fd = -1;
-
- free(ipc_client_data);
client->data = NULL;
return -1;
@@ -415,7 +320,6 @@ error_client_create:
int ipc_rfs_destroy(struct ril_client *client)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
int rc;
@@ -425,21 +329,16 @@ int ipc_rfs_destroy(struct ril_client *client)
return 0;
}
- ipc_client_data = (struct ipc_client_data *) client->data;
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) client->data;
LOGD("Destroying ipc rfs client");
if (ipc_client != NULL) {
ipc_client_close(ipc_client);
- ipc_client_destroy_handlers_common_data(ipc_client);
- ipc_client_free(ipc_client);
+ ipc_client_data_destroy(ipc_client);
+ ipc_client_destroy(ipc_client);
}
- ipc_client_data->ipc_client = NULL;
- ipc_client_data->ipc_client_fd = -1;
-
- free(ipc_client_data);
client->data = NULL;
return 0;
diff --git a/ipc.h b/ipc.h
index f8044d0..3ede416 100644
--- a/ipc.h
+++ b/ipc.h
@@ -32,11 +32,6 @@
#define ipc_fmt_send_exec(command, mseq) \
ipc_fmt_send(command, IPC_TYPE_EXEC, NULL, 0, mseq)
-struct ipc_client_data {
- struct ipc_client *ipc_client;
- int ipc_client_fd;
-};
-
extern struct ril_client_funcs ipc_fmt_client_funcs;
extern struct ril_client_funcs ipc_rfs_client_funcs;
diff --git a/rfs.c b/rfs.c
index adbf787..0e287d0 100644
--- a/rfs.c
+++ b/rfs.c
@@ -25,7 +25,6 @@
void ipc_rfs_nv_read_item(struct ipc_message_info *info)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
struct ipc_rfs_io *rfs_io;
@@ -42,12 +41,7 @@ void ipc_rfs_nv_read_item(struct ipc_message_info *info)
if (ril_data.ipc_rfs_client == NULL || ril_data.ipc_rfs_client->data == NULL)
return;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_rfs_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_rfs_client->data;
rfs_io_conf = calloc(1, rfs_io->length + sizeof(struct ipc_rfs_io_confirm));
rfs_data = rfs_io_conf + sizeof(struct ipc_rfs_io_confirm);
@@ -70,7 +64,6 @@ void ipc_rfs_nv_read_item(struct ipc_message_info *info)
void ipc_rfs_nv_write_item(struct ipc_message_info *info)
{
- struct ipc_client_data *ipc_client_data;
struct ipc_client *ipc_client;
struct ipc_rfs_io *rfs_io;
@@ -87,12 +80,7 @@ void ipc_rfs_nv_write_item(struct ipc_message_info *info)
if (ril_data.ipc_rfs_client == NULL || ril_data.ipc_rfs_client->data == NULL)
return;
- ipc_client_data = (struct ipc_client_data *) ril_data.ipc_rfs_client->data;
-
- if (ipc_client_data->ipc_client == NULL)
- return;
-
- ipc_client = ipc_client_data->ipc_client;
+ ipc_client = (struct ipc_client *) ril_data.ipc_rfs_client->data;
memset(&rfs_io_conf, 0, sizeof(rfs_io_conf));
rfs_data = info->data + sizeof(struct ipc_rfs_io);
diff --git a/samsung-ril.h b/samsung-ril.h
index 2f8b850..f5d94b1 100644
--- a/samsung-ril.h
+++ b/samsung-ril.h
@@ -28,7 +28,7 @@
#include <utils/Log.h>
#include <telephony/ril.h>
-#include <radio.h>
+#include <samsung-ipc.h>
#include "ipc.h"
#include "srs.h"