aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-02-16 22:13:49 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-03-03 19:25:18 +0100
commit65d8fa618c20b77eca6efbd5f3badf1591ee10ae (patch)
treef96061053a875a3f7b92b7aaac2c19c7dc7d1da3
parentf858507a19843d5e825eea378ea415f092e33042 (diff)
downloadhardware_replicant_libsamsung-ipc-65d8fa618c20b77eca6efbd5f3badf1591ee10ae.tar.gz
hardware_replicant_libsamsung-ipc-65d8fa618c20b77eca6efbd5f3badf1591ee10ae.tar.bz2
hardware_replicant_libsamsung-ipc-65d8fa618c20b77eca6efbd5f3badf1591ee10ae.zip
samsung-ipc: move Android partition handling in its own directory
This code could also be useful for other devices and in any cases it's not device specific. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--Android.mk1
-rw-r--r--samsung-ipc/devices/herolte/herolte.c27
-rw-r--r--samsung-ipc/partitions/Makefile.am2
-rw-r--r--samsung-ipc/partitions/android/android.c56
-rw-r--r--samsung-ipc/partitions/android/android.h27
5 files changed, 88 insertions, 25 deletions
diff --git a/Android.mk b/Android.mk
index 0521db6..c0a5d35 100644
--- a/Android.mk
+++ b/Android.mk
@@ -81,6 +81,7 @@ libsamsung_ipc_local_src_files := \
samsung-ipc/modems/xmm626/xmm626_hsic.c \
samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c \
samsung-ipc/modems/xmm626/xmm626_mipi.c \
+ samsung-ipc/partitions/android/android.c \
samsung-ipc/partitions/toc/toc.c
libsamsung_ipc_local_export_headers := \
diff --git a/samsung-ipc/devices/herolte/herolte.c b/samsung-ipc/devices/herolte/herolte.c
index c02557f..c5d15ef 100644
--- a/samsung-ipc/devices/herolte/herolte.c
+++ b/samsung-ipc/devices/herolte/herolte.c
@@ -35,6 +35,7 @@
#include "modems/xmm626/xmm626.h"
#include "modems/xmm626/xmm626_kernel_smdk4412.h"
#include "modems/xmm626/xmm626_modem_prj.h"
+#include "partitions/android/android.h"
#include "partitions/toc/toc.h"
struct __attribute__((__packed__)) security_req {
@@ -189,30 +190,6 @@ static char const * const modem_image_devices[] = {
NULL
};
-static int open_image_device(struct ipc_client *client)
-{
- int i;
-
- for (i = 0; modem_image_devices[i] != NULL; i++) {
- char const * const path = modem_image_devices[i];
- int fd;
-
- ipc_client_log(client, "Trying device path %s", path);
-
- fd = open(path, O_RDONLY);
- if (fd == -1) {
- if (errno == ENOENT)
- continue;
- /* Normally errno should be passed to the caller here */
- return -1;
- }
- return fd;
- }
-
- errno = ENOENT;
- return -1;
-}
-
int herolte_boot(struct ipc_client *client)
{
struct firmware_toc_entry toc[N_TOC_ENTRIES];
@@ -225,7 +202,7 @@ int herolte_boot(struct ipc_client *client)
ipc_client_log(client, "Loading firmware TOC");
- imagefd = open_image_device(client);
+ imagefd = open_android_modem_partition(client, modem_image_devices);
if (imagefd == -1) {
rc = errno;
if (rc == ENOENT)
diff --git a/samsung-ipc/partitions/Makefile.am b/samsung-ipc/partitions/Makefile.am
index c3c6197..5248869 100644
--- a/samsung-ipc/partitions/Makefile.am
+++ b/samsung-ipc/partitions/Makefile.am
@@ -1,4 +1,6 @@
libsamsung_ipc_la_SOURCES += \
+ partitions/android/android.c \
+ partitions/android/android.h \
partitions/toc/toc.c \
partitions/toc/toc.h \
$(NULL)
diff --git a/samsung-ipc/partitions/android/android.c b/samsung-ipc/partitions/android/android.c
new file mode 100644
index 0000000..fb922c5
--- /dev/null
+++ b/samsung-ipc/partitions/android/android.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2013-2014 Paul Kocialkowski <contact@paulk.fr>
+ * Copyright (C) 2017 Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
+ * Copyright (C) 2020 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
+ * Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+ *
+ * libsamsung-ipc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <samsung-ipc.h>
+
+int open_android_modem_partition(struct ipc_client *client,
+ char const * const *path_names)
+{
+ int i;
+
+ for (i = 0; path_names[i] != NULL; i++) {
+ char const * const path = path_names[i];
+ int fd;
+
+ ipc_client_log(client, "%s: Trying to open %s",
+ __func__, path);
+
+ fd = open(path, O_RDONLY);
+ if (fd == -1) {
+ if (errno == ENOENT)
+ continue;
+ /* Normally errno should be passed to the caller here */
+ return -1;
+ }
+ return fd;
+ }
+
+ errno = ENOENT;
+ return -1;
+}
diff --git a/samsung-ipc/partitions/android/android.h b/samsung-ipc/partitions/android/android.h
new file mode 100644
index 0000000..4d7700c
--- /dev/null
+++ b/samsung-ipc/partitions/android/android.h
@@ -0,0 +1,27 @@
+/*
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2013-2014 Paul Kocialkowski <contact@paulk.fr>
+ * Copyright (C) 2017 Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
+ * Copyright (C) 2020 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
+ * Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+ *
+ * libsamsung-ipc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __ANDROID_PARTITIONS_H__
+#define __ANDROID_PARTITIONS_H__
+int open_android_modem_partition(struct ipc_client *client,
+ char const * const *path_names);
+#endif /* __ANDROID_PARTITIONS_H__ */