aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2012-09-21 16:57:01 +0200
committerSimon Busch <morphis@gravedo.de>2012-09-21 16:57:01 +0200
commitb33a9e16243034197480b5374d93a209d9600b06 (patch)
treed87ef60d83b9b94de326f128af25074a4a9127e3 /samsung-ipc
parent51280f748e5c61202b45ffb2f074c4d99789b82a (diff)
downloadexternal_libsamsung-ipc-b33a9e16243034197480b5374d93a209d9600b06.zip
external_libsamsung-ipc-b33a9e16243034197480b5374d93a209d9600b06.tar.gz
external_libsamsung-ipc-b33a9e16243034197480b5374d93a209d9600b06.tar.bz2
xmm6260: cleanup code a bit to match common code style
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.c20
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.h6
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_loader.c38
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_modemctl.c52
4 files changed, 53 insertions, 63 deletions
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
index 23db495..b19b021 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
@@ -56,12 +56,12 @@ int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_in
unsigned char *frame;
unsigned char *payload;
size_t frame_length;
-
+
wake_lock(FMT_LOCK_NAME);
/* Frame IPC header + payload length */
frame_length = (sizeof(*hdr) + request->length);
-
+
frame = (unsigned char*)malloc(frame_length);
hdr = (struct ipc_header*)frame;
@@ -97,6 +97,7 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
struct ipc_header ipc = {
.length = 0,
};
+
int num_read = 0;
int left = 0;
@@ -117,11 +118,9 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
memcpy(&ipc, buf, sizeof(ipc));
left = ipc.length - num_read;
-
- if (left > 0) {
- num_read = client->handlers->read(buf + num_read, left,
- client->handlers->read_data);
- }
+
+ if (left > 0)
+ num_read = client->handlers->read(buf + num_read, left, client->handlers->read_data);
memcpy(&ipc, buf, sizeof(ipc));
@@ -132,7 +131,7 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
response->type = ipc.type;
response->cmd = IPC_COMMAND(response);
response->length = ipc.length - sizeof(ipc);
-
+
if (response->length > 0) {
response->data = (unsigned char*)malloc(response->length);
memcpy(response->data, buf + sizeof(ipc), response->length);
@@ -152,7 +151,6 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in
int header_recv = 0;
unsigned count=0;
int rc;
-
int ret = 0;
wake_lock(RFS_LOCK_NAME);
@@ -168,7 +166,7 @@ int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_in
// We didn't recieve the header yet
if (!header_recv) {
- if ((unsigned)rc < sizeof(struct rfs_hdr)) {
+ if ((unsigned) rc < sizeof(struct rfs_hdr)) {
ipc_client_log(client, "Failed to read RFS data.");
ret = -1;
goto done;
@@ -237,7 +235,7 @@ int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_in
ipc_client_log_send(client, request, __func__);
rc = client->handlers->write(data, data_length, client->handlers->write_data);
-
+
wake_unlock(RFS_LOCK_NAME);
return rc;
}
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.h b/samsung-ipc/device/xmm6260/xmm6260_ipc.h
index 04f32f2..b00f7db 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.h
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.h
@@ -31,9 +31,9 @@
#define GPRS_IFACE_COUNT 3
struct rfs_hdr {
- uint32_t size;
- uint8_t cmd;
- uint8_t id;
+ uint32_t size;
+ uint8_t cmd;
+ uint8_t id;
} __attribute__ ((packed));
int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request);
diff --git a/samsung-ipc/device/xmm6260/xmm6260_loader.c b/samsung-ipc/device/xmm6260/xmm6260_loader.c
index 1ba9c5b..49de352 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_loader.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_loader.c
@@ -31,10 +31,8 @@
#include <errno.h>
#include <sys/ioctl.h>
-//for timeval
#include <sys/time.h>
-//for mmap
#include <sys/mman.h>
#include <sys/stat.h>
@@ -47,22 +45,18 @@
unsigned char xmm6260_crc_calculate(void* data, size_t offset, size_t length)
{
unsigned char crc = 0;
- unsigned char *ptr = (unsigned char*)(data + offset);
+ unsigned char *ptr = (unsigned char*) (data + offset);
- while (length--) {
+ while (length--)
crc ^= *ptr++;
- }
return crc;
}
-/*
- * io helper functions
- */
-
-int expect(int fd, unsigned timeout) {
+int expect(int fd, unsigned timeout)
+{
int ret = 0;
-
+
struct timeval tv = {
tv.tv_sec = timeout / 1000,
tv.tv_usec = 1000 * (timeout % 1000),
@@ -74,38 +68,36 @@ int expect(int fd, unsigned timeout) {
ret = select(fd + 1, &read_set, 0, 0, &tv);
- if (ret < 0) {
- // _e("failed to select the fd %d ret=%d: %s", fd, ret, strerror(errno));
+ if (ret < 0)
goto fail;
- }
- if (ret < 1 || !FD_ISSET(fd, &read_set)) {
- // _d("fd %d not in fd set", fd);
+ if (ret < 1 || !FD_ISSET(fd, &read_set))
goto fail;
- }
fail:
return ret;
}
-int expect_read(int fd, void *buf, size_t size) {
+int expect_read(int fd, void *buf, size_t size)
+{
int ret;
- if ((ret = expect(fd, DEFAULT_TIMEOUT)) < 1) {
- // _e("failed to select the fd %d", fd);
+
+ if ((ret = expect(fd, DEFAULT_TIMEOUT)) < 1)
return ret;
- }
return read(fd, buf, size);
}
-int expect_data(int fd, void *data, size_t size) {
+int expect_data(int fd, void *data, size_t size)
+{
int ret;
char buf[size];
+
if ((ret = expect_read(fd, buf, size)) != size) {
ret = -1;
- // _e("failed to receive data");
return ret;
}
+
ret = memcmp(buf, data, size);
return ret;
diff --git a/samsung-ipc/device/xmm6260/xmm6260_modemctl.c b/samsung-ipc/device/xmm6260/xmm6260_modemctl.c
index d969fed..161a024 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_modemctl.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_modemctl.c
@@ -31,10 +31,8 @@
#include <errno.h>
#include <sys/ioctl.h>
-//for timeval
#include <sys/time.h>
-//for mmap
#include <sys/mman.h>
#include <sys/stat.h>
@@ -49,7 +47,8 @@
*/
int modemctl_link_set_active(struct ipc_client *client,
- struct modemctl_io_data *io_data, bool enabled) {
+ struct modemctl_io_data *io_data, bool enabled)
+{
unsigned status = enabled;
int ret;
unsigned long ioctl_code;
@@ -63,12 +62,14 @@ int modemctl_link_set_active(struct ipc_client *client,
}
return 0;
+
fail:
return ret;
}
int modemctl_link_set_enabled(struct ipc_client *client,
- struct modemctl_io_data *io_data, bool enabled) {
+ struct modemctl_io_data *io_data, bool enabled)
+{
unsigned status = enabled;
int ret;
unsigned long ioctl_code;
@@ -87,7 +88,8 @@ fail:
}
int modemctl_wait_link_ready(struct ipc_client *client,
- struct modemctl_io_data *io_data) {
+ struct modemctl_io_data *io_data)
+{
int ret;
struct timeval tv_start = {};
@@ -95,18 +97,17 @@ int modemctl_wait_link_ready(struct ipc_client *client,
gettimeofday(&tv_start, 0);;
- //link wakeup timeout in milliseconds
+ /* link wakeup timeout in milliseconds */
long diff = 0;
do {
ret = ioctl(io_data->link_fd, IOCTL_LINK_CONNECTED, 0);
- if (ret < 0) {
+
+ if (ret < 0)
goto fail;
- }
- if (ret == 1) {
+ if (ret == 1)
return 0;
- }
usleep(LINK_POLL_DELAY_US);
gettimeofday(&tv_end, 0);;
@@ -122,7 +123,8 @@ fail:
}
int modemctl_wait_modem_online(struct ipc_client *client,
- struct modemctl_io_data *io_data) {
+ struct modemctl_io_data *io_data)
+{
int ret;
struct timeval tv_start = {};
@@ -130,18 +132,16 @@ int modemctl_wait_modem_online(struct ipc_client *client,
gettimeofday(&tv_start, 0);;
- //link wakeup timeout in milliseconds
+ /* link wakeup timeout in milliseconds */
long diff = 0;
do {
ret = ioctl(io_data->boot_fd, IOCTL_MODEM_STATUS, 0);
- if (ret < 0) {
+ if (ret < 0)
goto fail;
- }
- if (ret == STATE_ONLINE) {
+ if (ret == STATE_ONLINE)
return 0;
- }
usleep(LINK_POLL_DELAY_US);
gettimeofday(&tv_end, 0);;
@@ -157,24 +157,24 @@ fail:
}
int modemctl_modem_power(struct ipc_client *client,
- struct modemctl_io_data *io_data, bool enabled) {
- if (enabled) {
+ struct modemctl_io_data *io_data, bool enabled)
+{
+ if (enabled)
return ioctl(io_data->boot_fd, IOCTL_MODEM_ON, 0);
- }
- else {
+ else
return ioctl(io_data->boot_fd, IOCTL_MODEM_OFF, 0);
- }
+
return -1;
}
int modemctl_modem_boot_power(struct ipc_client *client,
- struct modemctl_io_data *io_data, bool enabled) {
- if (enabled) {
+ struct modemctl_io_data *io_data, bool enabled)
+{
+ if (enabled)
return ioctl(io_data->boot_fd, IOCTL_MODEM_BOOT_ON, 0);
- }
- else {
+ else
return ioctl(io_data->boot_fd, IOCTL_MODEM_BOOT_OFF, 0);
- }
+
return -1;
}