From 6a2699967cc3e45df2be1a5df13f6df8b1c03016 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Thu, 29 Jun 2017 10:46:47 +0200 Subject: [PATCH] ccardimx28js removal: delete recipes not used by other platforms https://jira.digi.com/browse/DEL-4771 Signed-off-by: Javier Viguera --- .../0001-makefile.am.patch | 29 - .../0002-fix-mtd-defines.patch | 84 - ...ion-detection-code-and-add-cpx2-supp.patch | 170 -- ...ot-ROM-version-from-FDT-if-available.patch | 128 -- .../0005-dump-v1-boot-structures.patch | 195 -- ...tion-to-verify-data-written-to-flash.patch | 454 ----- .../0007-disable-use-of-nfc_geometry.patch | 24 - ...-bit-ECC-for-4K-page-NAND-with-224-b.patch | 23 - .../kobs-ng/kobs-ng_3.0.35-4.1.0.bb | 25 - meta-digi-arm/recipes-bsp/libdigi/libdigi.bb | 39 - .../recipes-bsp/libdigi/libdigi/cmdopt.c | 366 ---- .../recipes-bsp/libdigi/libdigi/cmdopt.h | 54 - .../recipes-bsp/libdigi/libdigi/crc32.c | 86 - .../recipes-bsp/libdigi/libdigi/crc32.h | 24 - .../libdigi/libdigi/digi-platforms.h | 116 -- .../recipes-bsp/libdigi/libdigi/log.c | 129 -- .../recipes-bsp/libdigi/libdigi/log.h | 34 - .../recipes-bsp/libdigi/libdigi/mem.c | 90 - .../recipes-bsp/libdigi/libdigi/mem.h | 23 - .../recipes-bsp/libdigi/libdigi/misc_helper.h | 51 - .../recipes-bsp/libdigi/libdigi/platform.c | 110 - meta-digi-arm/recipes-bsp/nvram/nvram.inc | 46 - meta-digi-arm/recipes-bsp/nvram/nvram/main.c | 266 --- .../nvram/nvram/nvram_priv_linux.c | 302 --- .../recipes-bsp/nvram/nvram_2013.01.bb | 5 - .../u-boot-dey-2013.01/ccardimx28/boot.txt | 16 - .../u-boot/u-boot-dey-rev_2013.01.inc | 11 - .../recipes-bsp/u-boot/u-boot-dey_2013.01.bb | 26 - .../recipes-bsp/ubootenv/ubootenv.bb | 34 - .../recipes-bsp/ubootenv/ubootenv/env_funcs.c | 183 -- .../recipes-bsp/ubootenv/ubootenv/env_funcs.h | 29 - .../ubootenv/ubootenv/environment.h | 26 - .../recipes-bsp/ubootenv/ubootenv/main_env.c | 561 ------ .../recipes-bsp/update-flash/update-flash.bb | 26 - .../update-flash/update-flash/jffs2-user.h | 33 - .../update-flash/update-flash/update_flash.c | 1770 ----------------- .../kernel-module-atheros.bb | 50 - .../0001-atheros-convert-NLA_PUT-macros.patch | 1761 ---------------- ...theros-update-renamed-struct-members.patch | 235 --- .../kernel-module-atheros/Makefile | 42 - .../kernel-module-atheros/atheros-pre-up | 139 -- .../linux-dey-3.10/ccardimx28js/defconfig | 212 -- .../recipes-kernel/linux/linux-dey_3.10.bb | 61 - .../0001-enable-libnl3.patch | 74 - .../0002-cross-compile.patch | 85 - ...ilt_wan-Rewrite-the-netlink-listener.patch | 127 -- .../0004-add-fgnu89-flag-for-gcc5.patch | 29 - .../btfilter-v3.4p4-b3.4.0.158/btfilter-init | 33 - .../btfilter/btfilter_v3.4p4-b3.4.0.158.bb | 34 - 49 files changed, 8470 deletions(-) delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0001-makefile.am.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0002-fix-mtd-defines.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0003-cleanup-ROM-version-detection-code-and-add-cpx2-supp.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0004-discover-boot-ROM-version-from-FDT-if-available.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0005-dump-v1-boot-structures.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0006-added-option-to-verify-data-written-to-flash.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0007-disable-use-of-nfc_geometry.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0008-mtd-configure-16-bit-ECC-for-4K-page-NAND-with-224-b.patch delete mode 100644 meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng_3.0.35-4.1.0.bb delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi.bb delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.c delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.h delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.c delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.h delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/digi-platforms.h delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/log.c delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/log.h delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.c delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.h delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/misc_helper.h delete mode 100644 meta-digi-arm/recipes-bsp/libdigi/libdigi/platform.c delete mode 100644 meta-digi-arm/recipes-bsp/nvram/nvram.inc delete mode 100644 meta-digi-arm/recipes-bsp/nvram/nvram/main.c delete mode 100644 meta-digi-arm/recipes-bsp/nvram/nvram/nvram_priv_linux.c delete mode 100644 meta-digi-arm/recipes-bsp/nvram/nvram_2013.01.bb delete mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-2013.01/ccardimx28/boot.txt delete mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-rev_2013.01.inc delete mode 100644 meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2013.01.bb delete mode 100644 meta-digi-arm/recipes-bsp/ubootenv/ubootenv.bb delete mode 100644 meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.c delete mode 100644 meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.h delete mode 100644 meta-digi-arm/recipes-bsp/ubootenv/ubootenv/environment.h delete mode 100644 meta-digi-arm/recipes-bsp/ubootenv/ubootenv/main_env.c delete mode 100644 meta-digi-arm/recipes-bsp/update-flash/update-flash.bb delete mode 100644 meta-digi-arm/recipes-bsp/update-flash/update-flash/jffs2-user.h delete mode 100644 meta-digi-arm/recipes-bsp/update-flash/update-flash/update_flash.c delete mode 100644 meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb delete mode 100644 meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0001-atheros-convert-NLA_PUT-macros.patch delete mode 100644 meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0002-atheros-update-renamed-struct-members.patch delete mode 100644 meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/Makefile delete mode 100644 meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/atheros-pre-up delete mode 100644 meta-digi-arm/recipes-kernel/linux/linux-dey-3.10/ccardimx28js/defconfig delete mode 100644 meta-digi-arm/recipes-kernel/linux/linux-dey_3.10.bb delete mode 100644 meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0001-enable-libnl3.patch delete mode 100644 meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0002-cross-compile.patch delete mode 100644 meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0003-abtfilt_wan-Rewrite-the-netlink-listener.patch delete mode 100644 meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0004-add-fgnu89-flag-for-gcc5.patch delete mode 100755 meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/btfilter-init delete mode 100644 meta-digi-dey/recipes-connectivity/btfilter/btfilter_v3.4p4-b3.4.0.158.bb diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0001-makefile.am.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0001-makefile.am.patch deleted file mode 100644 index d5981d7bc..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0001-makefile.am.patch +++ /dev/null @@ -1,29 +0,0 @@ -From: Javier Viguera -Date: Fri, 11 Oct 2013 18:56:04 +0200 -Subject: [PATCH] makefile.am - -Yocto build system does not use the makefile.in directly. Instead it -uses autotools to regenerate it using the source makefile.am. - -But the makefile.in distributed in the package has some rules changed -that are not generated from the makefile.am, so adapt the makefile.am to -generate an equivalent makefile.in. - -Signed-off-by: Javier Viguera ---- - include/Makefile.am | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/include/Makefile.am b/include/Makefile.am -index 17d4d2c..dc3a466 100644 ---- a/include/Makefile.am -+++ b/include/Makefile.am -@@ -1,5 +1,8 @@ - noinst_HEADERS=version.h - -+all-local: -+ echo "const char *git_sha = \""`git rev-parse HEAD`"\";" > ../include/autoversion.h -+ - version.h: stamp-vh - @: - diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0002-fix-mtd-defines.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0002-fix-mtd-defines.patch deleted file mode 100644 index eeef870e3..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0002-fix-mtd-defines.patch +++ /dev/null @@ -1,84 +0,0 @@ -From: "Paul B. Henson" -Date: Fri, 11 Oct 2013 17:23:44 +0200 -Subject: [PATCH] fix-mtd-defines - -Newer kernel headers renamed mtd mode defines and no longer support -MEMSETOOBSEL. Allow code to work with both older and newer kernel -versions. - -Signed-off-by: Paul B. Henson -Signed-off-by: Javier Viguera ---- - src/mtd.c | 9 +++++++++ - src/mtd.h | 8 ++++++++ - 2 files changed, 17 insertions(+) - -diff --git a/src/mtd.c b/src/mtd.c -index 2974814..f9e60a3 100644 ---- a/src/mtd.c -+++ b/src/mtd.c -@@ -852,8 +852,11 @@ void mtd_close(struct mtd_data *md) - mp = &md->part[i]; - - if (mp->fd != -1) { -+/* Newer kernels dropped MEMSETOOBSEL */ -+#ifdef MEMSETOOBSEL - (void)ioctl(mp->fd, MEMSETOOBSEL, - &mp->old_oobinfo); -+#endif - close(mp->fd); - } - -@@ -896,6 +899,8 @@ int mtd_set_ecc_mode(struct mtd_data *md, int ecc) - continue; - } - -+/* Newer kernels dropped MEMSETOOBSEL */ -+#ifdef MEMSETOOBSEL - if (r == -ENOTTY) { - r = ioctl(mp->fd, MEMSETOOBSEL, &mp->old_oobinfo); - if (r != 0) { -@@ -904,6 +909,7 @@ int mtd_set_ecc_mode(struct mtd_data *md, int ecc) - } - mp->oobinfochanged = 0; - } -+#endif - } else { - r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_RAW); - if (r != 0 && r != -ENOTTY) { -@@ -911,6 +917,8 @@ int mtd_set_ecc_mode(struct mtd_data *md, int ecc) - continue; - } - -+/* Newer kernels dropped MEMSETOOBSEL */ -+#ifdef MEMSETOOBSEL - if (r == -ENOTTY) { - r = ioctl(mp->fd, MEMSETOOBSEL, &none_oobinfo); - if (r != 0) { -@@ -920,6 +928,7 @@ int mtd_set_ecc_mode(struct mtd_data *md, int ecc) - mp->oobinfochanged = 1; - } else - mp->oobinfochanged = 2; -+#endif - } - - mp->ecc = ecc; -diff --git a/src/mtd.h b/src/mtd.h -index 99d7887..bf6e53d 100644 ---- a/src/mtd.h -+++ b/src/mtd.h -@@ -31,6 +31,14 @@ - #include "BootControlBlocks.h" - #include "rom_nand_hamming_code_ecc.h" - -+// Newer kernel headers renamed define -+#ifndef MTD_MODE_NORMAL -+#define MTD_MODE_NORMAL MTD_FILE_MODE_NORMAL -+#endif -+#ifndef MTD_MODE_RAW -+#define MTD_MODE_RAW MTD_FILE_MODE_RAW -+#endif -+ - //------------------------------------------------------------------------------ - // Re-definitions of true and false, because the standard ones aren't good - // enough? diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0003-cleanup-ROM-version-detection-code-and-add-cpx2-supp.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0003-cleanup-ROM-version-detection-code-and-add-cpx2-supp.patch deleted file mode 100644 index d70fe428f..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0003-cleanup-ROM-version-detection-code-and-add-cpx2-supp.patch +++ /dev/null @@ -1,170 +0,0 @@ -From: Hector Palacios -Date: Fri, 18 Oct 2013 10:10:37 +0200 -Subject: cleanup ROM version detection code and add cpx2 support - -The original code flow was difficult to understand. -Now there is a main if-elseif to check for 'Hardware' or 'Revision' -strings from cpuinfo. -On the 'Hardware' section we first check if it is a CPX2, or else we -will parse the MX-- number to get the CPU model. -On the 'Revision' section we base on the revision number to get the -CPU model or, if unset (like when Linux is booted directly), we'll -rely on the previous hw_system_rev calculated before. - -Signed-off-by: Hector Palacios -Reviewed-by: Robert Hodaszi ---- - src/plat_boot_config.c | 119 ++++++++++++++++++++++++++----------------------- - 1 file changed, 63 insertions(+), 56 deletions(-) - -diff --git a/src/plat_boot_config.c b/src/plat_boot_config.c -index 76e65c8..e3bf242 100644 ---- a/src/plat_boot_config.c -+++ b/src/plat_boot_config.c -@@ -109,10 +109,11 @@ int discover_boot_rom_version(void) - { - FILE *cpuinfo; - char line_buffer[100]; -- static char *banner = "Revision"; -+ static char *banner_rev = "Revision"; - static char *banner_hw = "Hardware"; -+ static char *banner_digi_x2 = "Hardware\t: Digi ConnectPort X2"; - char *rev; -- int system_rev, hw_system_rev = 0; -+ int system_rev = 0, hw_system_rev = 0; - - cpuinfo = fopen("/proc/cpuinfo", "r"); - if (!cpuinfo) { -@@ -125,15 +126,20 @@ int discover_boot_rom_version(void) - if (!fgets(line_buffer, sizeof(line_buffer), cpuinfo)) - break; - -- /* Check if it's revision line */ -- if (strncmp(line_buffer, banner, strlen(banner))) { -- /* -- * Why use the `Hardware` to parse the system type ? -- * [1] If boot linux kernel directly from SD card not by uboot, -- * the `Revision` will be zero. -- * [2] The code does not change the old logic. -- */ -- if (!strncmp(line_buffer, banner_hw, strlen(banner))) { -+ /* Check if it's hardware line... */ -+ /* -+ * Why use the `Hardware` to parse the system type ? -+ * [1] If boot linux kernel directly from SD card not by uboot, -+ * the `Revision` will be zero. -+ * [2] The code does not change the old logic. -+ */ -+ if (!strncmp(line_buffer, banner_hw, strlen(banner_hw))) { -+ if (!strncmp(line_buffer, banner_digi_x2, -+ strlen(banner_digi_x2))) { -+ /* The cpx2 is an i.MX28 */ -+ hw_system_rev = MX28; -+ } -+ else { - rev = strstr(line_buffer, "MX"); - if (rev) { - char tmp[3] = {}; -@@ -143,56 +149,57 @@ int discover_boot_rom_version(void) - hw_system_rev = strtoul(tmp, NULL, 16); - } - } -- continue; - } -+ /* ... or Revision line */ -+ else if (!strncmp(line_buffer, banner_rev, strlen(banner_rev))) { -+ rev = index(line_buffer, ':'); -+ if (rev != NULL) { -+ rev++; -+ system_rev = strtoul(rev, NULL, 16); -+ system_rev = mxc_cpu(system_rev); -+ if (!system_rev) -+ system_rev = hw_system_rev; -+ -+ switch (system_rev) { -+ case MX23: -+ plat_config_data = &mx23_boot_config; -+ break; -+ -+ case MX28: -+ plat_config_data = &mx28_boot_config; -+ break; -+ -+ case MX53: -+ if (mxc_cpu_is_rev(system_rev, CHIP_REV_2_0) < 0) -+ plat_config_data = &mx53to1_boot_config; -+ else -+ plat_config_data = &mx53to2_boot_config; -+ break; -+ -+ case MX50: -+ plat_config_data = &mx50_boot_config; -+ break; -+ -+ case MX6: -+ case MX6Q: -+ case MX6DL: -+ plat_config_data = &mx6q_boot_config; -+ break; -+ -+ default: -+ fprintf(stderr, "Couldn't find Boot ROM version\n"); -+ break; -+ } - -- rev = index(line_buffer, ':'); -- if (rev != NULL) { -- rev++; -- system_rev = strtoul(rev, NULL, 16); -- system_rev = mxc_cpu(system_rev); -- if (!system_rev) -- system_rev = hw_system_rev; -- -- switch (system_rev) { -- case MX23: -- plat_config_data = &mx23_boot_config; -- break; -- -- case MX28: -- plat_config_data = &mx28_boot_config; -- break; -- -- case MX53: -- if (mxc_cpu_is_rev(system_rev, CHIP_REV_2_0) < 0) -- plat_config_data = &mx53to1_boot_config; -- else -- plat_config_data = &mx53to2_boot_config; -- break; -- -- case MX50: -- plat_config_data = &mx50_boot_config; -- break; -- -- case MX6: -- case MX6Q: -- case MX6DL: -- plat_config_data = &mx6q_boot_config; -- break; -- -- default: -- fprintf(stderr, "Couldn't find Boot ROM version\n"); -- break; -- } -- -- fclose(cpuinfo); -- if (plat_config_data) { -- plat_config_data->m_u32Arm_type = system_rev; -- return 0; -+ break; /* quit for loop */ - } -- return -1; - } - } -+ - fclose(cpuinfo); -+ if (plat_config_data) { -+ plat_config_data->m_u32Arm_type = system_rev; -+ return 0; -+ } - return -1; - } diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0004-discover-boot-ROM-version-from-FDT-if-available.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0004-discover-boot-ROM-version-from-FDT-if-available.patch deleted file mode 100644 index ce5954700..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0004-discover-boot-ROM-version-from-FDT-if-available.patch +++ /dev/null @@ -1,128 +0,0 @@ -From: Hector Palacios -Date: Fri, 18 Oct 2013 10:11:29 +0200 -Subject: discover boot ROM version from FDT if available - -New kernels don't get CPU information from U-Boot ATAGS and -so the /proc/cpuinfo file does not have the Hardware/Revision -lines filled in. -This patch gets the CPU model from the device tree information -at /proc/device-tree/compatible. -For backwards compatibility, if the CPU model cannot be retrieved -from this file, we try to get it from /proc/cpuinfo. - -Signed-off-by: Hector Palacios -Reviewed-by: Robert Hodaszi ---- - src/plat_boot_config.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 94 insertions(+), 1 deletion(-) - -diff --git a/src/plat_boot_config.c b/src/plat_boot_config.c -index e3bf242..af7e03a 100644 ---- a/src/plat_boot_config.c -+++ b/src/plat_boot_config.c -@@ -105,7 +105,91 @@ static platform_config mx6q_boot_config = { - .rom_mtd_commit_structures = v4_rom_mtd_commit_structures, - }; - --int discover_boot_rom_version(void) -+#define MAX_STRLEN 256 -+int get_rom_version_from_fdt(void) -+{ -+ FILE *fd; -+ char line_buffer[MAX_STRLEN]; -+ char *p; -+ static char *compatible = "fsl,imx"; -+ char *rev; -+ int system_rev; -+ -+ fd = fopen("/proc/device-tree/compatible", "r"); -+ if (!fd) -+ return -1; -+ -+ p = &line_buffer[0]; -+ if (fgets(p, MAX_STRLEN, fd)) { -+ /* -+ * The compatible string can contain more than one string. -+ * Each string value is separated from the next one by a -+ * NULL char. We must check all values one by one until -+ * we find two consecutive NULL chars. -+ */ -+ while (p[0] != 0) { -+ if (!strncmp(p, compatible, strlen(compatible))) { -+ rev = p + strlen(compatible); -+ /* -+ * check if it's an imx6 CPU series, or -+ * a parsable number. -+ */ -+ if (!strncmp(rev, "6q", 2)) -+ system_rev = MX6Q; -+ else if (!strncmp(rev, "6d", 2)) -+ system_rev = MX6DL; -+ else if (!strncmp(rev, "6s", 2)) -+ system_rev = MX6; -+ else -+ system_rev = strtoul(rev, NULL, 16); -+ -+ switch (system_rev) { -+ case MX23: -+ plat_config_data = &mx23_boot_config; -+ break; -+ -+ case MX28: -+ plat_config_data = &mx28_boot_config; -+ break; -+ -+ case MX53: -+ /* -+ * TODO: check CPU revision -+ * Consider it is a TO2 for the -+ * moment -+ */ -+ plat_config_data = &mx53to2_boot_config; -+ break; -+ -+ case MX50: -+ plat_config_data = &mx50_boot_config; -+ break; -+ -+ case MX6: -+ case MX6Q: -+ case MX6DL: -+ plat_config_data = &mx6q_boot_config; -+ break; -+ -+ default: -+ break; -+ } -+ -+ if (plat_config_data) { -+ plat_config_data->m_u32Arm_type = system_rev; -+ return 0; -+ } -+ } -+ /* Move string pointer to next possible value */ -+ p += strlen(p) + 1; -+ } -+ } -+ -+ fclose(fd); -+ return -1; -+} -+ -+int get_rom_version_from_cpuinfo(void) - { - FILE *cpuinfo; - char line_buffer[100]; -@@ -203,3 +287,12 @@ int discover_boot_rom_version(void) - } - return -1; - } -+ -+int discover_boot_rom_version(void) -+{ -+ /* First, try to get ROM version from FDT */ -+ if (get_rom_version_from_fdt()) -+ return (get_rom_version_from_cpuinfo()); -+ -+ return 0; -+} diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0005-dump-v1-boot-structures.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0005-dump-v1-boot-structures.patch deleted file mode 100644 index 62c786998..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0005-dump-v1-boot-structures.patch +++ /dev/null @@ -1,195 +0,0 @@ -From: Hector Palacios -Date: Tue, 15 Oct 2013 18:58:11 +0200 -Subject: dump v1 boot structures - -The kobs-ng that we received from Freescale did not support reading the -boot structures on the mx28. It could write them, but the function that -reads them was never updated to handle the updated structures used by -the mx28. This change adds basic support for reading these structures, -enough so that the dump command works. - -(forward ported from kobs-ng-10.12.01 to kobs-ng-3.0.35_4.1.0) - -Signed-off-by: Hector Palacios -Reviewed-by: Robert Hodaszi ---- - src/main.c | 5 ++- - src/mtd.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - src/mtd.h | 1 + - 3 files changed, 131 insertions(+), 4 deletions(-) - -diff --git a/src/main.c b/src/main.c -index 82b6f9e..70517b0 100644 ---- a/src/main.c -+++ b/src/main.c -@@ -152,7 +152,10 @@ int dump_main(int argc, char **argv) - if (flags & F_VERBOSE) - mtd_dump(md); - -- r = mtd_load_all_boot_structures(md); -+ if (ROM_Version_1 == plat_config_data->m_u32RomVer) -+ r = mtd_load_v1_boot_structures(md); -+ else -+ r = mtd_load_all_boot_structures(md); - if (r != 0) { - fprintf(stderr, "Unable to load boot structures\n"); - exit(5); -diff --git a/src/mtd.c b/src/mtd.c -index f9e60a3..9ea92ad 100644 ---- a/src/mtd.c -+++ b/src/mtd.c -@@ -975,6 +975,130 @@ void dump(const void *data, int size) - printf("\n"); - } - -+/* -+ * This function is a hack written by Digi because the original code from -+ * Freescale did not supporting reading the bootlet structures at all. -+ * This function reads the search areas for a given BCB. It will read the first -+ * search area and use it if the read succeeds. If the read fails, then it will -+ * try again with the second search area. -+ * -+ * md A pointer to the current struct mtd_data. -+ * bcb_name A pointer to a human-readable string that indicates what kind of -+ * BCB we're reading. This string will only be used in log messages. -+ * ofs1 If there is one chips, the index of the search area to read -+ * ofs2 -+ * ofs_mchip If there are multiple chips, the index of the search area to read -+ * on both chips. -+ * end The number of consecutive search areas to be read. -+ * size The size of the BCB data to be read. -+ * ecc Indicates whether or not to use hardware ECC. -+ */ -+int mtd_read_bcb(struct mtd_data *md, char *bcb_name, -+ loff_t ofs1, loff_t ofs2, loff_t ofs_mchip, -+ loff_t end, size_t size, int ecc) -+{ -+ int chip; -+ loff_t end_index, search_area_indices[2], o; -+ int r; -+ int i; -+ int j; -+ unsigned stride_size_in_bytes; -+ unsigned search_area_size_in_strides; -+ unsigned search_area_size_in_bytes; -+ -+ /* Compute some important facts about geometry */ -+ if (plat_config_data->m_u32RomVer == ROM_Version_2) { -+ stride_size_in_bytes = mtd_erasesize(md); -+ search_area_size_in_strides = 4; -+ search_area_size_in_bytes = search_area_size_in_strides * stride_size_in_bytes; -+ } else { -+ stride_size_in_bytes = PAGES_PER_STRIDE * mtd_writesize(md); -+ search_area_size_in_strides = 1 << md->cfg.search_exponent; -+ search_area_size_in_bytes = search_area_size_in_strides * stride_size_in_bytes; -+ } -+ -+ /* -+ * Check whether there are multiple chips and set up the two search area -+ * indices accordingly. -+ */ -+ if (multichip(md)) -+ search_area_indices[0] = search_area_indices[1] = ofs_mchip; -+ else { -+ search_area_indices[0] = ofs1; -+ search_area_indices[1] = ofs2; -+ } -+ -+ /* Loop over search areas for this BCB. */ -+ for (i = 0; i < 2; i++) { -+ /* -+ * Compute the search area index that marks the end of the -+ * writing on this chip. -+ */ -+ end_index = search_area_indices[i] + end; -+ -+ /* Figure out which chip we're writing */ -+ chip = multichip(md) ? i : 0; -+ -+ /* Loop over consecutive search areas to write. */ -+ for (; search_area_indices[i] < end_index; search_area_indices[i]++) { -+ /* -+ * Compute the byte offset of the beginning of this -+ * search area -+ */ -+ o = search_area_indices[i] * search_area_size_in_bytes; -+ -+ /* Loop over strides in this search area. */ -+ for (j = 0; j < search_area_size_in_strides; j++, o += stride_size_in_bytes) { -+ /* -+ * If we're crossing into a new block, erase it -+ * first. -+ */ -+ -+ /* Write the page */ -+ vp(md, "mtd: Reading %s%d @%d:0x%llx(%x)\n", -+ bcb_name, j, chip, o, size); -+ -+ r = mtd_read_page(md, chip, o, ecc); -+ if (r != size) { -+ fprintf(stderr, "\n%s r = 0x%8.8X, size = 0x%8.8X\n", __func__, r, size); -+ fprintf(stderr, "mtd: Failed to read %s @%d: 0x%llx (%d)\n", -+ bcb_name, chip, o, r); -+ } else -+ break; -+ } -+ } -+ } -+ -+ return !(r == size); -+} -+ -+/* -+ * This function is a hack by Digi, written because the original code from -+ * Freescale did not support reading the v1 boot structures at all. Do not -+ * use the results from this function for anything other than browsing the -+ * boot structures. -+ */ -+int mtd_load_v1_boot_structures(struct mtd_data *md) -+{ -+ int err = 0; -+ -+ /* read the FCB search area */ -+ err = mtd_read_bcb(md, "FCB", 0, 0, 0, 1, -+ mtd_writesize(md) + mtd_oobsize(md), false); -+ memcpy(&md->fcb, md->buf, sizeof(md->fcb)); -+ -+ /* read the DBBT search area */ -+ err |= mtd_read_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true); -+ memcpy(&md->dbbt28, md->buf, sizeof(md->dbbt28)); -+ -+ if ((err != 0) || -+ (md->dbbt28.m_u32FingerPrint != DBBT_FINGERPRINT2)) { -+ err = -1; -+ } -+ -+ return err; -+} -+ - void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_t end, - uint32_t magic1, uint32_t magic2, uint32_t magic3, int use_ecc, - int magic_offset) -@@ -1083,9 +1207,8 @@ int mtd_load_all_boot_structures(struct mtd_data *md) - md->curr_ncb = NULL; - md->ncb_version = ncb_get_version(buf, &md->curr_ncb); - -- if (md->flags & F_VERBOSE) -- printf("mtd: found NCB%d candidate version %d @%d:0x%llx\n", -- i, md->ncb_version, chip, ofs); -+ vp(md, "mtd: found NCB%d candidate version %d @%d:0x%llx\n", -+ i, md->ncb_version, chip, ofs); - - if (md->ncb_version >= 0) - break; -diff --git a/src/mtd.h b/src/mtd.h -index bf6e53d..18e4d70 100644 ---- a/src/mtd.h -+++ b/src/mtd.h -@@ -276,6 +276,7 @@ void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_ - uint32_t magic1, uint32_t magic2, uint32_t magic3, int use_ecc, - int magic_offset); - int mtd_load_all_boot_structures(struct mtd_data *md); -+int mtd_load_v1_boot_structures(struct mtd_data *md); - int mtd_dump_structure(struct mtd_data *md); - - int v0_rom_mtd_init(struct mtd_data *md, FILE *fp); diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0006-added-option-to-verify-data-written-to-flash.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0006-added-option-to-verify-data-written-to-flash.patch deleted file mode 100644 index 945f30ecf..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0006-added-option-to-verify-data-written-to-flash.patch +++ /dev/null @@ -1,454 +0,0 @@ -From: Hector Palacios -Date: Wed, 16 Oct 2013 10:30:14 +0200 -Subject: added option to verify data written to flash - -This patch adds a -c (check) option to the update command. -This option will read back the data written to the flash and -compare to the original contents in RAM, to verify the write -operation was successful. - -Signed-off-by: Hector Palacios -Reviewed-by: Robert Hodaszi ---- - src/main.c | 22 ++++++-- - src/mtd.c | 138 +++++++++++++++++++++++++++++++++++++++---------- - src/mtd.h | 10 ++-- - src/plat_boot_config.h | 2 +- - 4 files changed, 136 insertions(+), 36 deletions(-) - -diff --git a/src/main.c b/src/main.c -index 70517b0..8774045 100644 ---- a/src/main.c -+++ b/src/main.c -@@ -82,10 +82,12 @@ void usage(void) - " -x .................................... Add 1k-padding in the head\n" - " -n .................................... Dry run (don't commit to flash)\n" - " -w .................................... Commit to flash\n" -+ " -c .................................... Check committed data in flash\n" - "\n" - " update [-v] [KEY] [KOBS] [-0|1] .. Update a single bootstream\n" - " -v .................................... Verbose mode\n" - " -0|1 .................................. Update specified bootstream #\n" -+ " -c .................................... Check committed data in flash\n" - "\n" - " extract [-v] [KEY] [KOBS] [-0|1] . Extract a bootstream from flash\n" - " -v .................................... Verbose mode\n" -@@ -390,7 +392,8 @@ int extract_main(int argc, char **argv) - return 0; - } - --static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_mask) -+static int perform_bootstream_update(struct mtd_data *md, FILE *infp, -+ int image_mask, int check) - { - int i, r; - unsigned int size, start, avail, end, update; -@@ -435,7 +438,8 @@ static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_ - update |= UPDATE_BS(i); - } - -- r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_LDLB | update); -+ r = plat_config_data->rom_mtd_commit_structures(md, infp, -+ UPDATE_LDLB | update, check); - if (r < 0) { - fprintf(stderr, "FAILED to commit structures\n"); - return -1; -@@ -457,6 +461,7 @@ int update_main(int argc, char **argv) - char ascii[20 * 2 + 1]; - int device_key; - uint8_t *keyp; -+ int check; - - memset(key, 0, sizeof(key)); - device_key = 0; -@@ -473,6 +478,7 @@ int update_main(int argc, char **argv) - image_mask = 0; /* no image */ - flags = 0; - j = 0; -+ check = 0; - for (i = 1; i < argc; i++) { - - if (argv[i][0] != '-') { -@@ -500,6 +506,9 @@ int update_main(int argc, char **argv) - exit(5); - } - break; -+ case 'c': -+ check = 1; -+ break; - case 'v': - flags |= F_VERBOSE; - break; -@@ -545,7 +554,7 @@ int update_main(int argc, char **argv) - if (flags & F_VERBOSE) - mtd_dump(md); - -- r = perform_bootstream_update(md, infp, image_mask); -+ r = perform_bootstream_update(md, infp, image_mask, check); - if (r != 0) { - fprintf(stderr, "Unable to perform bootstream update\n"); - usage(); -@@ -597,6 +606,7 @@ int init_main(int argc, char **argv) - FILE *infp; - loff_t ofs; - int dryrun; -+ int check; - int padding = 0; - struct mtd_config cfg; - uint8_t key[16]; -@@ -619,6 +629,7 @@ int init_main(int argc, char **argv) - image = 0; /* first image */ - flags = 0; - dryrun = 0; -+ check = 0; - j = 0; - for (i = 1; i < argc; i++) { - -@@ -640,6 +651,9 @@ int init_main(int argc, char **argv) - case 'w': - dryrun = 0; - break; -+ case 'c': -+ check = 1; -+ break; - case 'n': - dryrun = 1; - break; -@@ -738,7 +752,7 @@ int init_main(int argc, char **argv) - mtd_dump_structure(md); - - if (!dryrun) { -- r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL); -+ r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL, check); - if (r < 0) { - fprintf(stderr, "FAILED to commit structures\n"); - exit(5); -diff --git a/src/mtd.c b/src/mtd.c -index 9ea92ad..77ba307 100644 ---- a/src/mtd.c -+++ b/src/mtd.c -@@ -2344,7 +2344,7 @@ int v4_rom_mtd_init(struct mtd_data *md, FILE *fp) - - int mtd_commit_bcb(struct mtd_data *md, char *bcb_name, - loff_t ofs1, loff_t ofs2, loff_t ofs_mchip, -- loff_t end, size_t size, int ecc) -+ loff_t end, size_t size, int ecc, int verify) - { - int chip; - loff_t end_index, search_area_indices[2], o; -@@ -2355,6 +2355,13 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name, - unsigned search_area_size_in_strides; - unsigned search_area_size_in_bytes; - unsigned count; -+ char *readbuf = NULL; -+ -+ if (verify) { -+ readbuf = malloc(mtd_writesize(md)); -+ if (NULL == readbuf) -+ return -1; -+ } - - vp(md, "-------------- Start to write the [ %s ] -----\n", bcb_name); - //---------------------------------------------------------------------- -@@ -2457,6 +2464,20 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name, - err ++; - } - -+ if (verify) { -+ //------------------------------------------------------ -+ // Verify the written data -+ //------------------------------------------------------ -+ r = pread(md->part[chip].fd, readbuf, mtd_writesize(md), o); -+ if (r != mtd_writesize(md)) { -+ fprintf(stderr, "mtd: Failed to read @0x%llx (%d)\n", o, r); -+ goto err_free; -+ } -+ if (memcmp(md->buf, readbuf, mtd_writesize(md))) { -+ fprintf(stderr, "mtd: Verification error @0x%llx\n", o); -+ goto err_free; -+ } -+ } - } - - } -@@ -2466,16 +2487,31 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name, - if (md->flags & F_VERBOSE) - printf("%s(%s): status %d\n\n", __func__, bcb_name, err); - -- return err; -+err_free: -+ if (verify) -+ free(readbuf); -+ if (err) { -+ fprintf(stderr, "mtd: %d errors\n", err); -+ return -1; -+ } -+ else -+ return 0; - } - --int write_boot_stream(struct mtd_data *md, FILE *fp) -+int write_boot_stream(struct mtd_data *md, FILE *fp, int verify) - { - int startpage, start, size; - loff_t ofs, end; -- int i, r, chunk; -+ int i, r = 0, chunk; - int chip = 0; - struct fcb_block *fcb = &md->fcb.FCB_Block; -+ char *readbuf = NULL; -+ -+ if (verify) { -+ readbuf = malloc(mtd_writesize(md)); -+ if (NULL == readbuf) -+ return -1; -+ } - - vp(md, "---------- Start to write the [ %s ]----\n", (char*)md->private); - for (i = 0; i < 2; i++) { -@@ -2530,7 +2566,7 @@ int write_boot_stream(struct mtd_data *md, FILE *fp) - r = fread(md->buf, 1, chunk, fp); - if (r < 0) { - fprintf(stderr, "mtd: Failed %d (fread %d)\n", r, chunk); -- return -1; -+ goto err_free; - } - if (r < chunk) { - memset(md->buf + r, 0, chunk - r); -@@ -2539,10 +2575,30 @@ int write_boot_stream(struct mtd_data *md, FILE *fp) - - /* write page */ - r = mtd_write_page(md, chip, ofs, 1); -- if (r != mtd_writesize(md)) -+ if (r != mtd_writesize(md)) { - fprintf(stderr, "mtd: Failed to write BS @0x%llx (%d)\n", - ofs, r); -+ r = -1; -+ goto err_free; -+ } - -+ if (verify) { -+ //------------------------------------------------------ -+ // Verify the written data -+ //------------------------------------------------------ -+ r = pread(md->part[chip].fd, readbuf, -+ mtd_writesize(md), ofs); -+ if (r != mtd_writesize(md)) { -+ fprintf(stderr, "mtd: Failed to read BS @0x%llx (%d)\n", ofs, r); -+ r = -1; -+ goto err_free; -+ } -+ if (memcmp(md->buf, readbuf, mtd_writesize(md))) { -+ fprintf(stderr, "mtd: Verification error @0x%llx\n", ofs); -+ r = -1; -+ goto err_free; -+ } -+ } - ofs += mtd_writesize(md); - size -= chunk; - } -@@ -2555,19 +2611,26 @@ int write_boot_stream(struct mtd_data *md, FILE *fp) - */ - memset(md->buf, 0, mtd_writesize(md)); - r = mtd_write_page(md, chip, ofs, 1); -- if (r != mtd_writesize(md)) -+ if (r != mtd_writesize(md)) { - fprintf(stderr, "Failed to write safe page\n"); -+ r = -1; -+ goto err_free; -+ } - vp(md, "mtd: We write one page for save guard. *\n"); -- - if (ofs >= end) { - fprintf(stderr, "mtd: Failed to write BS#%d\n", i); -- return -1; -+ r = -1; -+ goto err_free; - } - } -- return 0; -+ -+err_free: -+ if (verify) -+ free(readbuf); -+ return r; - } - --int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) -+int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify) - { - int startpage, start, size; - unsigned int search_area_sz, stride; -@@ -2666,7 +2729,9 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - if (r < 0) - return r; - -- mtd_commit_bcb(md, "NCB", 0, 1, 0, 1, size, false); -+ r = mtd_commit_bcb(md, "NCB", 0, 1, 0, 1, size, false, verify); -+ if (r < 0) -+ return r; - } - - if (flags & UPDATE_LDLB) { -@@ -2675,7 +2740,10 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - memset(md->buf, 0, mtd_writesize(md)); - memcpy(md->buf, md->curr_ldlb, sizeof(*md->curr_ldlb)); - -- mtd_commit_bcb(md, "LDLB", 2, 3, 1, 1, mtd_writesize(md), true); -+ r = mtd_commit_bcb(md, "LDLB", 2, 3, 1, 1, mtd_writesize(md), true, -+ verify); -+ if (r < 0) -+ return r; - } - - if (flags & UPDATE_DBBT) { -@@ -2684,7 +2752,11 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - memset(md->buf, 0, mtd_writesize(md)); - memcpy(md->buf, md->curr_dbbt, sizeof(*md->curr_dbbt)); - -- mtd_commit_bcb(md, "DBBT", 4, 5, 2, 1, mtd_writesize(md), true); -+ r = mtd_commit_bcb(md, "DBBT", 4, 5, 2, 1, mtd_writesize(md), true, -+ verify); -+ if (r < 0) -+ return r; -+ - for (i = 0; i < 2; i++) { - for (j = 0; j < 2; j++) { - if (md->flags & F_MULTICHIP) { -@@ -2766,7 +2838,7 @@ static void write_dbbt(struct mtd_data *md, int dbbt_num) - } - } - --int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) -+int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify) - { - int size ,r; - -@@ -2779,8 +2851,11 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - size = mtd_writesize(md) + mtd_oobsize(md); - r = fcb_encrypt(&md->fcb, md->buf, size, 1); - if (r < 0) -- return r; -- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false); -+ return -1; -+ -+ r = mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false, verify); -+ if (r < 0) -+ return -1; - - //---------------------------------------------------------------------- - // Write the DBBT search area. -@@ -2788,14 +2863,17 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - memset(md->buf, 0, mtd_writesize(md)); - memcpy(md->buf, &(md->dbbt28), sizeof(md->dbbt28)); - dbbt_checksum(md, &md->dbbt28); -- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true); -+ r = mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, -+ verify); -+ if (r < 0) -+ return -1; - write_dbbt(md, 1); /* only write the DBBT for nand0 */ - - /* write the boot image. */ -- return write_boot_stream(md, fp); -+ return write_boot_stream(md, fp, verify); - } - --int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) -+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify) - { - int startpage, start, size; - unsigned int search_area_size_in_bytes, stride_size_in_bytes; -@@ -2832,7 +2910,9 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - memset(md->buf, 0, mtd_writesize(md)); - memcpy(md->buf, &(md->fcb), sizeof(md->fcb)); - -- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md), true); -+ r = mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md), true, verify); -+ if (r < 0) -+ return -1; - - //---------------------------------------------------------------------- - // Write the DBBT search area. -@@ -2841,7 +2921,9 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - memset(md->buf, 0, mtd_writesize(md)); - memcpy(md->buf, &(md->dbbt28), sizeof(md->dbbt28)); - -- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true); -+ r = mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, verify); -+ if (r < 0) -+ return -1; - - //---------------------------------------------------------------------- - // Write the DBBT table area. -@@ -2985,7 +3067,7 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - return 0; - } - --int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) -+int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify) - { - int size, i, r, chip = 0; - loff_t ofs; -@@ -2997,12 +3079,16 @@ int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - r = fcb_encrypt(&md->fcb, md->buf, size, 1); - if (r < 0) - return r; -- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false); -+ r = mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false, verify); -+ if (r < 0) -+ return r; - - /* [2] Write the DBBT search area. */ - memset(md->buf, 0, mtd_writesize(md)); - memcpy(md->buf, &(md->dbbt50), sizeof(md->dbbt50)); -- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true); -+ r = mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, verify); -+ if (r < 0) -+ return -1; - - /* Write the DBBT table area. */ - memset(md->buf, 0, mtd_writesize(md)); -@@ -3023,7 +3109,7 @@ int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags) - } - - /* [3] Write the two boot streams. */ -- return write_boot_stream(md, fp); -+ return write_boot_stream(md, fp, verify); - } - - #undef ARG -diff --git a/src/mtd.h b/src/mtd.h -index 18e4d70..699e505 100644 ---- a/src/mtd.h -+++ b/src/mtd.h -@@ -295,11 +295,11 @@ int mtd_markbad(struct mtd_data *md, int chip, loff_t ofs); - #define UPDATE_BS(x) (0x08 << ((x) & 1)) - #define UPDATE_ALL (UPDATE_NCB | UPDATE_LDLB | UPDATE_DBBT | UPDATE_BS0 | UPDATE_BS1) - --int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags); --int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags); --int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags); --int v3_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags); --int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags); -+int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify); -+int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify); -+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify); -+int v3_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify); -+int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify); - - int mtd_set_ecc_mode(struct mtd_data *md, int ecc); - -diff --git a/src/plat_boot_config.h b/src/plat_boot_config.h -index 8242ede..a3c03a7 100644 ---- a/src/plat_boot_config.h -+++ b/src/plat_boot_config.h -@@ -55,7 +55,7 @@ typedef struct _platform_config_t { - uint32_t m_u32Arm_type; - uint32_t m_u32DBBT_FingerPrint; - int (* rom_mtd_init)(struct mtd_data *md, FILE *fp); -- int (* rom_mtd_commit_structures)(struct mtd_data *md, FILE *fp, int flags); -+ int (* rom_mtd_commit_structures)(struct mtd_data *md, FILE *fp, int flags, int verify); - } platform_config; - - extern platform_config *plat_config_data; diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0007-disable-use-of-nfc_geometry.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0007-disable-use-of-nfc_geometry.patch deleted file mode 100644 index 5d2e8bb9d..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0007-disable-use-of-nfc_geometry.patch +++ /dev/null @@ -1,24 +0,0 @@ -From: Javier Viguera -Date: Thu, 14 Nov 2013 16:46:01 +0100 -Subject: [PATCH] disable use of nfc_geometry - -Not supported in kernel v3.10 - -Signed-off-by: Javier Viguera ---- - src/plat_boot_config.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/plat_boot_config.c b/src/plat_boot_config.c -index af7e03a47f1b..463045f0bc75 100644 ---- a/src/plat_boot_config.c -+++ b/src/plat_boot_config.c -@@ -46,7 +46,7 @@ static platform_config mx28_boot_config = { - .m_u32EnDISBBM = 0, - .m_u32EnSoftEcc = 1, - .m_u32EnBootStreamVerify = 1, -- .m_u32UseNfcGeo = 1, -+ .m_u32UseNfcGeo = 0, - .m_u32UseMultiBootArea = 0, - .m_u32UseSinglePageStride = 1, - .m_u32DBBT_FingerPrint = DBBT_FINGERPRINT2, diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0008-mtd-configure-16-bit-ECC-for-4K-page-NAND-with-224-b.patch b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0008-mtd-configure-16-bit-ECC-for-4K-page-NAND-with-224-b.patch deleted file mode 100644 index 23dcad30b..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng-3.0.35-4.1.0/0008-mtd-configure-16-bit-ECC-for-4K-page-NAND-with-224-b.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 62d43285dd08709c86b91ba0ae23c974e96c2905 Mon Sep 17 00:00:00 2001 -From: Hector Palacios -Date: Thu, 15 Oct 2015 12:31:24 +0200 -Subject: [PATCH] mtd: configure 16-bit ECC for 4K page NAND with 224-byte OOB - -Signed-off-by: Hector Palacios ---- - src/mtd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/mtd.c b/src/mtd.c -index 77ba3070de7a..4d04f4c2921d 100644 ---- a/src/mtd.c -+++ b/src/mtd.c -@@ -2124,7 +2124,7 @@ int v1_rom_mtd_init(struct mtd_data *md, FILE *fp) - if (mtd_writesize(md) == 2048) { - geo->ecc_strength = ROM_BCH_Ecc_8bit << 1; - } else if (mtd_writesize(md) == 4096) { -- if (mtd_oobsize(md) == 218) -+ if (mtd_oobsize(md) == 218 || mtd_oobsize(md) == 224) - geo->ecc_strength = ROM_BCH_Ecc_16bit << 1; - else if ((mtd_oobsize(md) == 128)) - geo->ecc_strength = ROM_BCH_Ecc_8bit << 1; diff --git a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng_3.0.35-4.1.0.bb b/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng_3.0.35-4.1.0.bb deleted file mode 100644 index 889e36673..000000000 --- a/meta-digi-arm/recipes-bsp/kobs-ng/kobs-ng_3.0.35-4.1.0.bb +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2013 Digi International. All rights reserved. - -SUMMARY = "Freescale's mxs nand update utility" -SECTION = "base" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=393a5ca445f6965873eca0259a17f833" - -inherit autotools - -SRC_URI = " \ - ${DIGI_PKG_SRC}/${PN}-${PV}.tar.gz \ - file://0001-makefile.am.patch \ - file://0002-fix-mtd-defines.patch \ - file://0003-cleanup-ROM-version-detection-code-and-add-cpx2-supp.patch \ - file://0004-discover-boot-ROM-version-from-FDT-if-available.patch \ - file://0005-dump-v1-boot-structures.patch \ - file://0006-added-option-to-verify-data-written-to-flash.patch \ - file://0007-disable-use-of-nfc_geometry.patch \ - file://0008-mtd-configure-16-bit-ECC-for-4K-page-NAND-with-224-b.patch \ -" - -SRC_URI[md5sum] = "2a0e55b5063605b2664fd67c95a6c686" -SRC_URI[sha256sum] = "92d2f23add8c5d3102c77f241cae26ca55871ccc613a7af833bebbbac7afb8ea" - -COMPATIBLE_MACHINE = "mxs" diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi.bb b/meta-digi-arm/recipes-bsp/libdigi/libdigi.bb deleted file mode 100644 index 6f9c00945..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi.bb +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2013,2017 Digi International. - -SUMMARY = "Digi's utilities library" -SECTION = "libs" -LICENSE = "GPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" - -SRC_URI = " \ - file://cmdopt.c \ - file://cmdopt.h \ - file://crc32.c \ - file://crc32.h \ - file://digi-platforms.h \ - file://log.c \ - file://log.h \ - file://mem.c \ - file://mem.h \ - file://misc_helper.h \ - file://platform.c \ -" - -S = "${WORKDIR}" - -do_compile() { - ${CC} -O2 -Wall ${LDFLAGS} -c -o log.o log.c - ${CC} -O2 -Wall ${LDFLAGS} -c -o cmdopt.o cmdopt.c - ${CC} -O2 -Wall ${LDFLAGS} -c -o mem.o mem.c - ${CC} -O2 -Wall ${LDFLAGS} -c -o crc32.o crc32.c - ${CC} -O2 -Wall ${LDFLAGS} -c -o platform.o platform.c - ${AR} -rcs libdigi.a log.o cmdopt.o mem.o crc32.o platform.o -} - -do_install() { - mkdir -p ${D}${includedir}/libdigi ${D}${libdir} - install -m 0644 libdigi.a ${D}${libdir} - install -m 0644 cmdopt.h crc32.h digi-platforms.h log.h mem.h misc_helper.h ${D}${includedir}/libdigi -} - -RDEPENDS_${PN}-dev = "" diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.c b/meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.c deleted file mode 100644 index 5deadbe5b..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.c +++ /dev/null @@ -1,366 +0,0 @@ -/*********************************************************************** - * - * Copyright 2001,2002 by FS-Forth Systeme GmbH. - * All rights reserved. - * - * $Id: cmdopt.c,v 1.4 2007-01-23 15:13:27 mpietrek Exp $ - * @Author: Markus Pietrek - * @Descr: Provides some helper functions to access the command line - * options. The results are stored in global variables. - * This file is not thread safe. - * - ********************************************************************** */ -/*********************************************************************** * - * @History: - * 2002/10/21 : Purified for splint. Changed to new variable - * naming convention. - * - *********************************************************************** */ - -#include -#include // toupper -#include // getopt -#include -#include // atoi -#include // strlen - -#include "cmdopt.h" -#include "log.h" -#include "misc_helper.h" - -#define BUFFER_SIZE 1024 -#define MAX_ENTRIES 32 - -/*@observer@*/ -void (*fnCmdOptExtendedUsage) (char bCmdLine) = NULL; -const char* szCmdOptVersion = "$Revision: 1.4 $"; // if not - // overwritten take - // at least the - // revision of cmdopt - -static CmdOptEntry cmdOptEntries[ MAX_ENTRIES ]; // to avoid malloc we - // use a static buffer -/*@noreturn@*/ -static void usageAndExit( int argc, - char* argv[], - const CmdOptEntry entries[], - const char* szDescr, - char cWrongNumber ); -static void updateVar( const CmdOptEntry entries[], - int nOptIndex, - const char* szStr ); - - -/*********************************************************************** - * @Function: cmdOptParse - * @Return: only if command line could be parsed otherwise ends - * the application. Result is only set if COT_MORE is specified - * and points to the first unprocessed entry - * @Descr: reads the command line and sets the variables. Displays a usage - * if values are wrong. - ***********************************************************************/ - -int cmdOptParse( int argc, - char* argv[], - const CmdOptEntry entries[], - const char* szDescr ) -{ - char szOptLine[ BUFFER_SIZE ]; - struct option axLongOptions[ MAX_ENTRIES ]; - int nOptIndex = 0; - int nSize = 0; - int nSizeLong = 0; - signed char cOptChar; - int nOptIndexStatic = 0; - int nOptLongIndex = 0; - char cPrintVersion = 0; - char cPrintHelp = 0; - - CmdOptEntry coePrintVersion = - {COT_BOOL, -1, &cPrintVersion, "version", "print version and exit" }; - CmdOptEntry coePrintHelp = - {COT_BOOL, 'h', &cPrintHelp, "help", "print help" }; - CmdOptEntry coeLogLevel = - {COT_INT, 'l', &logLevel, "log-level", "log level for messages" }; - - CLEAR( axLongOptions ); - - // add global default command line arguments - cmdOptEntries[ nOptIndexStatic++ ] = coePrintVersion; - cmdOptEntries[ nOptIndexStatic++ ] = coePrintHelp; - cmdOptEntries[ nOptIndexStatic++ ] = coeLogLevel; - - // copy default command line entries - // will break when all entries are copied to global area - // or too much arguments - while( 1 ) - { - if( nOptIndexStatic == MAX_ENTRIES ) - { - logMsg( LOG_ERR, "cmdOptParse: too many command line options" ); - exit( EXIT_FAILURE ); - } - - cmdOptEntries[ nOptIndexStatic ] = entries[ nOptIndex ]; - if( entries[ nOptIndex ].type == COT_NONE ) - // no more entries - break; - - nOptIndexStatic++; - nOptIndex++; - } - - // create parameter list for getopt - - nOptIndex = 0; - szOptLine[ nOptIndex ] = 0; - - while( cmdOptEntries[ nSize ].type != COT_NONE ) - { - if( ( cmdOptEntries[ nSize ].type != COT_MORE ) && - ( cmdOptEntries[ nSize ].type != COT_MORE_OPT ) ) { - axLongOptions[ nSizeLong ].name = cmdOptEntries[ nSize ].szLabelStr; - axLongOptions[ nSizeLong ].has_arg = - ((cmdOptEntries[ nSize ].type != COT_BOOL ) ? required_argument : no_argument); - axLongOptions[ nSizeLong ].flag = NULL; - axLongOptions[ nSizeLong ].val = -2 - nSize; - nSizeLong++; - } - - if( NULL != cmdOptEntries[ nSize ].pbPresent ) - *cmdOptEntries[ nSize ].pbPresent = 0; - if( !cmdOptEntries[ nSize ].cOptChar ) - { - // parameter is not mandatory - nSize++; - continue; - } - - if( nOptIndex >= BUFFER_SIZE - 2 ) - { - logMsg( LOG_ERR, - "cmdOptParse: too long command line" ); - exit( EXIT_FAILURE ); - } - - if( -1 != cmdOptEntries[ nSize ].cOptChar ) { - szOptLine[ nOptIndex++ ] = cmdOptEntries[ nSize ].cOptChar; - if( cmdOptEntries[ nSize ].type != COT_BOOL ) - szOptLine[ nOptIndex++ ] = ':'; - } - - szOptLine[ nOptIndex ] = 0; - - nSize++; - } - - // parse optional command line options - - while( ( cOptChar = getopt_long( argc, argv, szOptLine, axLongOptions, &nOptLongIndex ) ) != -1 ) - { - char cFound = 0; - - if( cOptChar < 0 ) { - cFound = 1; - updateVar( cmdOptEntries, -2 - cOptChar, optarg ); - } else { - for( nOptIndex = 0; nOptIndex < nSize; nOptIndex++ ) - { - if( cmdOptEntries[ nOptIndex ].cOptChar == cOptChar ) - { - // optional arguments only - cFound = 1; - updateVar( cmdOptEntries, nOptIndex, optarg ); - } - } - } - - if( !cFound ) - usageAndExit( argc, argv, cmdOptEntries, szDescr, 0 ); - } - - if( cPrintVersion ) - { - fprintf( stdout, "%s %s\n", - argv[ 0 ], - szCmdOptVersion ); - exit( EXIT_SUCCESS ); - } - - if( cPrintHelp ) - usageAndExit( argc, argv, cmdOptEntries, szDescr, 0 ); - - // parse mandatory command line options - - nOptIndex = 0; - for( nOptIndex = 0; nOptIndex < nSize; nOptIndex++ ) - if( !cmdOptEntries[ nOptIndex ].cOptChar ) - { - if( cmdOptEntries[ nOptIndex ].type == COT_MORE_OPT ) - // don't parse the following arguments as they - // can't be covered by this lib yet - return optind; - - if( !( argc - optind ) ) - usageAndExit( argc, argv, cmdOptEntries, szDescr, 1 ); - - if( cmdOptEntries[ nOptIndex ].type == COT_MORE ) - // don't parse the following arguments as they - // can't be covered by this lib yet - return optind; - - updateVar( cmdOptEntries, nOptIndex, argv[ optind++ ] ); - } - - if( argc - optind ) - // COT_MORE is aborted before - usageAndExit( argc, argv, cmdOptEntries, szDescr, 1 ); - - return 0; -} - -void cmdOptUsageAndExit( - int argc, - char* argv[], - const CmdOptEntry entries[], - const char* szDescr ) -{ - usageAndExit( argc, argv, entries, szDescr, 0 ); -} - - -/*********************************************************************** - * @Function: usageAndExit - * @Return: never - * @Descr: displays usage and exits with EXIT_FAILURE. If wrongNumber is 1, - * a message "too many arguments is displayed". - ***********************************************************************/ - -static void usageAndExit( /*@unused@*/ int argc, - char* argv[], - const CmdOptEntry entries[], - const char* szDescr, - char cWrongNumber ) -{ - int nOptIndex = 0; - size_t maxStrLen = 0; - - fprintf( stdout, "Usage: %s ", argv[ 0 ] ); - - // print command line arguments - while( entries[ nOptIndex ].type != COT_NONE ) - { - if( entries[ nOptIndex ].szLabelStr != NULL ) - { - // determine max len of labelStr for formatted output - size_t strLen = strlen( entries[ nOptIndex ].szLabelStr ); - - if( strLen > maxStrLen ) - maxStrLen = strLen; - } - - switch( entries[ nOptIndex ].type ) - { - case COT_BOOL: - case COT_INT: - case COT_STRING: - fprintf( stdout, "[--%s] ", entries[ nOptIndex ].szLabelStr ); - break; - case COT_MORE: - case COT_MORE_OPT: - fprintf( stdout, - "%s ", - entries[ nOptIndex ].szLabelStr ); - break; - case COT_NONE: - // will never happen but satisfies compiler - break; - } - nOptIndex++; - } - if( NULL != fnCmdOptExtendedUsage ) - fnCmdOptExtendedUsage( 1 ); - - fprintf( stdout, "\n" ); - - // explain command line options - nOptIndex = 0; - while( entries[ nOptIndex ].type != COT_NONE ) - { - fprintf( stdout, " " ); - fprintf( stdout, " %-*s", - (int) maxStrLen, - entries[ nOptIndex ].szLabelStr ); - - if( entries[ nOptIndex ].cOptChar > 0) - fprintf( stdout, " [-%c]", entries[ nOptIndex ].cOptChar ); - else - fprintf( stdout, " " ); - /*@+matchanyintegral*/ // maxStrLen is size_t. We shall - // unrestrict for this case the - // behaviour of splint because the - // compiler should do some - // checking, too - /*@-matchanyintegral*/ - - if( entries[ nOptIndex ].szHelpStr != NULL ) - fprintf( stdout, " : %s", entries[ nOptIndex ].szHelpStr ); - - fprintf( stdout, "\n" ); - nOptIndex++; - } - - if( NULL != fnCmdOptExtendedUsage ) - fnCmdOptExtendedUsage( 0 ); - - fprintf( stdout, "\n%s\n", szDescr ); - - // explain failure - if( cWrongNumber ) - fprintf( stderr, "\n*** Wrong # arguments ***\n" ); - - exit( EXIT_FAILURE ); -} - - -/*********************************************************************** - * @Function: updateVar - * @Return: nothing - * @Descr: sets the variable in entries[ index ] to the value in str - * and does conversion if necessary - ***********************************************************************/ - -static void updateVar( const CmdOptEntry entries[], - int nOptIndex, - const char* szStr ) -{ - switch( entries[ nOptIndex ].type ) - { - case COT_BOOL: - *((char*) entries[ nOptIndex ].vValuePtr) = 1; - break; - case COT_INT: - if( (int) strlen( szStr ) > 2 && - ((szStr[ 0 ] == '0' && (toupper( szStr[ 1 ] ) == 'X' )))) - { - sscanf( &szStr[ 2 ], - "%x", - ((int*) entries[ nOptIndex ].vValuePtr ) ); - break; - } - *((int*) entries[ nOptIndex ].vValuePtr) = atoi( szStr ); - break; - case COT_STRING: - *((const char**) entries[ nOptIndex ].vValuePtr) = szStr; - break; - case COT_MORE: - case COT_MORE_OPT: - case COT_NONE: - // will never happen but satisfies compiler - break; - } - - if( NULL != entries[ nOptIndex ].pbPresent ) - *entries[ nOptIndex ].pbPresent = 1; -} - diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.h b/meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.h deleted file mode 100644 index 7f9ca2ab5..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/cmdopt.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * libdigi/cmdopt.h - * - * Copyright (C) 2001,2002 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Helper functions to access command line options. - * The results are stored in global variables. - * - */ - -#ifndef DG_CMDOPT_H -#define DG_CMDOPT_H - -typedef enum { - COT_BOOL, // if present,bool is set 1, otherwise unchanged - COT_INT, // sets *valuePtr to the int value - // with conversions (if 0x - // prefix is present) - COT_STRING, // sets *valuePtr to the string - COT_MORE, // to end the array. Any additional arguments - // are allowed - COT_MORE_OPT, // to end the array. Any optional arguments - // are allowed - COT_NONE // to end the array. Any additional arguments - // are considered as failures -} CmdOptTypes; - -typedef struct { - CmdOptTypes type; // type of option to be read - signed char cOptChar; // character to identify that option, if 0, then - // no option is used but parameter is required - void *vValuePtr; // ptr to the variable where value is stored - const char *szLabelStr; // label displayed in command line - const char *szHelpStr; // displays this help string for the variable - char *pbPresent; // will be set to if this option is present -} CmdOptEntry; - -/* can be set to display additional usage */ -extern void (*fnCmdOptExtendedUsage) (char bCmdLine); - -extern const char *szCmdOptVersion; // overwrite it before calling cmdOptParse to - // define version of application - -int cmdOptParse(int argc, char *argv[], const CmdOptEntry entries[], const char *szDescr); - -void cmdOptUsageAndExit(int argc, - char *argv[], const CmdOptEntry entries[], const char *szDescr); - -#endif /* DG_CMDOPT_H */ diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.c b/meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.c deleted file mode 100644 index 52d7aa710..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * crc32.c - * - * Copyright (C) 2006 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Flash Test Util - * - */ - -#include "crc32.h" - -static const crc32_t crc32_table[256] = { - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL -}; - -crc32_t crc32(crc32_t uiCRC, const void *pvBuf, size_t iLen) -{ - const unsigned char *pcBuf = (const unsigned char *)pvBuf; - - /* uiCRC starts with 0 on first block. If run on a block, undoes the - previous uiCRC ^ 0xffffffff. */ - uiCRC ^= 0xffffffff; - - while (iLen-- > 0) - uiCRC = crc32_table[(uiCRC ^ *pcBuf++) & 0xff] ^ (uiCRC >> 8); - - /* if last block, this is the result. Otherwise this will be undone - on next crc32 call */ - return uiCRC ^ 0xffffffff; -} diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.h b/meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.h deleted file mode 100644 index 6cf7e1197..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/crc32.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * libdigi/crc32.h - * - * Copyright (C) 2006 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: CRC32 functions - * - */ - -#ifndef DG_CRC32_H -#define DG_CRC32_H - -#include /* uint32_t */ -#include /* size_t */ - -typedef uint32_t crc32_t; -extern crc32_t crc32(crc32_t uiCRC, const void *pvBuf, size_t iLen); - -#endif /* DG_CRC32_H */ diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/digi-platforms.h b/meta-digi-arm/recipes-bsp/libdigi/libdigi/digi-platforms.h deleted file mode 100644 index 6b4639e72..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/digi-platforms.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * libdigi/digi-platforms.h - * - * Copyright (C) 2011 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Digi platforms - * - */ - -#ifndef DIGI_PLATFORMS_H -#define DIGI_PLATFORMS_H - -#define PLATFORM_NAME(x) x ## _NAME - -#define MACH_TYPE_CC7U 1017 -#define MACH_TYPE_CC7U_NAME "cc7u" -#define MACH_TYPE_CWIEM 1033 -#define MACH_TYPE_CWIEM_NAME "cwiem" -#define MACH_TYPE_CCW9C 1110 -#define MACH_TYPE_CCW9C_NAME "ccw9c" -#define MACH_TYPE_CC9P9360DEV 1114 -#define MACH_TYPE_CC9P9360DEV_NAME "cc9p9360dev" -#define MACH_TYPE_CC9P9750DEV 1115 -#define MACH_TYPE_CC9P9750DEV_NAME "cc9p9750dev" -#define MACH_TYPE_CC9P9360VAL 1116 -#define MACH_TYPE_CC9P9360VAL_NAME "cc9p9360val" -#define MACH_TYPE_CC9P9750VAL 1117 -#define MACH_TYPE_CC9P9750VAL_NAME "cc9p9750val" -#define MACH_TYPE_CC9P9360JS 1264 -#define MACH_TYPE_CC9P9360JS_NAME "cc9p9360js" -#define MACH_TYPE_CC9P9215 1445 -#define MACH_TYPE_CC9P9215_NAME "cc9p9215" -#define MACH_TYPE_CC9P9210 1446 -#define MACH_TYPE_CC9P9210_NAME "cc9p9210" -#define MACH_TYPE_CC9P9215JS 1447 -#define MACH_TYPE_CC9P9215JS_NAME "cc9p9215js" -#define MACH_TYPE_CC9P9210JS 1448 -#define MACH_TYPE_CC9P9210JS_NAME "cc9p9210js" -#define MACH_TYPE_CC7UCAMRY 1493 -#define MACH_TYPE_CC7UCAMRY_NAME "cc7ucamry" -#define MACH_TYPE_CC9M2443JS 1663 -#define MACH_TYPE_CC9M2443JS_NAME "cc9m2443js" -#define MACH_TYPE_CME9210 1712 -#define MACH_TYPE_CME9210_NAME "cme9210" -#define MACH_TYPE_CCW9P9215JS 1811 -#define MACH_TYPE_CCW9P9215JS_NAME "ccw9p9215js" -#define MACH_TYPE_CC9M2443 1815 -#define MACH_TYPE_CC9M2443_NAME "cc9m2443" -#define MACH_TYPE_CME9210JS 1854 -#define MACH_TYPE_CME9210JS_NAME "cme9210js" -#define MACH_TYPE_CC9P9360 1855 -#define MACH_TYPE_CC9P9360_NAME "cc9p9360" -#define MACH_TYPE_CCW9P9215 2137 -#define MACH_TYPE_CCW9P9215_NAME "ccw9p9215" -#define MACH_TYPE_CCW9M2443 2145 -#define MACH_TYPE_CCW9M2443_NAME "ccw9m2443" -#define MACH_TYPE_CCW9M2443JS 2146 -#define MACH_TYPE_CCW9M2443JS_NAME "ccw9m2443js" -#define MACH_TYPE_CC9P9215_3G 2397 -#define MACH_TYPE_CC9P9215_3G_NAME "cc9p9215_3g" -#define MACH_TYPE_CC9P9215_3GJS 2398 -#define MACH_TYPE_CC9P9215_3GJS_NAME "cc9p9215_3gjs" -#define MACH_TYPE_CCMX51 2516 -#define MACH_TYPE_CCMX51_NAME "ccmx51" -#define MACH_TYPE_CCMX51JS 2517 -#define MACH_TYPE_CCMX51JS_NAME "ccmx51js" -#define MACH_TYPE_CCWMX51 2518 -#define MACH_TYPE_CCWMX51_NAME "ccwmx51" -#define MACH_TYPE_CCWMX51JS 2519 -#define MACH_TYPE_CCWMX51JS_NAME "ccwmx51js" -#define MACH_TYPE_CWME9210 3320 -#define MACH_TYPE_CWME9210_NAME "cwme9210" -#define MACH_TYPE_CWME9210JS 3321 -#define MACH_TYPE_CWME9210JS_NAME "cwme9210js" -#define MACH_TYPE_CCMX53 3346 -#define MACH_TYPE_CCMX53_NAME "ccmx53" -#define MACH_TYPE_CCMX53JS 3347 -#define MACH_TYPE_CCMX53JS_NAME "ccmx53js" -#define MACH_TYPE_CCWMX53 3348 -#define MACH_TYPE_CCWMX53_NAME "ccwmx53" -#define MACH_TYPE_CCWMX53JS 3349 -#define MACH_TYPE_CCWMX53JS_NAME "ccwmx53js" -#define MACH_TYPE_CPX2 3419 -#define MACH_TYPE_CPX2_NAME "cpx2" -#define MACH_TYPE_WR21 3737 -#define MACH_TYPE_WR21_NAME "wr21" -#define MACH_TYPE_CCARDWMX28 3893 -#define MACH_TYPE_CCARDWMX28_NAME "ccardwmx28" -#define MACH_TYPE_CCARDMX28 3894 -#define MACH_TYPE_CCARDMX28_NAME "ccardmx28" -#define MACH_TYPE_CCARDWMX28JS 3917 -#define MACH_TYPE_CCARDWMX28JS_NAME "ccardwmx28js" -#define MACH_TYPE_CCARDMX28JS 3918 -#define MACH_TYPE_CCARDMX28JS_NAME "ccardmx28js" -#define MACH_TYPE_CCIMX53 9980 -#define MACH_TYPE_CCIMX53_NAME "ccimx53" -#define MACH_TYPE_CCIMX53JS 9981 -#define MACH_TYPE_CCIMX53JS_NAME "ccimx53js" -#define MACH_TYPE_CCIMX51 9982 -#define MACH_TYPE_CCIMX51_NAME "ccimx51" -#define MACH_TYPE_CCIMX51JS 9983 -#define MACH_TYPE_CCIMX51JS_NAME "ccimx51js" -#define MACH_TYPE_CCARDIMX28 9984 -#define MACH_TYPE_CCARDIMX28_NAME "ccardimx28" -#define MACH_TYPE_CCARDIMX28JS 9985 -#define MACH_TYPE_CCARDIMX28JS_NAME "ccardimx28js" - -int get_platform_id(void); -char is_nand_oob_atomic(void); - -#endif /* DIGI_PLATFORMS_H */ diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/log.c b/meta-digi-arm/recipes-bsp/libdigi/libdigi/log.c deleted file mode 100644 index 5aeebafc2..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/log.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * log.c - * - * Copyright (C) 2001,2002 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: implements logging interface - * - */ - -#include // fprintf -#include // EXIT_FAILURE -#include // errno -#include // h_errno -#include // strerror -#include // vprintf - -#include "log.h" - -/* Globaly visible */ -LogLevel logLevel = LOG_STATUS; - - -/*********************************************************************** - * @Function: log - * @Return: nothing - * @Descr: format and arg1..arg3 are printed on stderr only if level - * is <= logLevel - * format may not contain any newline character. - ***********************************************************************/ -void logMsg(LogLevel level, const char *szFormat, ...) -{ - if (level <= logLevel) { - va_list ap; - - /*@-formatconst@ */ - va_start(ap, szFormat); - vfprintf(stderr, szFormat, ap); - va_end(ap); - /*@-formatconst@ */ - fputs("\n", stderr); - } -} - -/*********************************************************************** - * @Function: systemLog - * @Return: nothing - * @Descr: dumps the system error that happened just before - ***********************************************************************/ -void systemLog(const char *szFormat, ...) -{ - char *szError = NULL; - va_list ap; - - if (errno) - szError = strdup(strerror(errno)); - else if (h_errno) - szError = strdup(hstrerror(h_errno)); - - /*@-formatconst@ */ - va_start(ap, szFormat); - vfprintf(stderr, szFormat, ap); - va_end(ap); - /*@-formatconst@ */ - if (NULL != szError) - fprintf(stderr, " (%s)", szError); - - fputs("\n", stderr); - - if (NULL != szError) - free(szError); -} - -/*********************************************************************** - * @Function: error - * @Return: never - * @Descr: format and arg1..arg3 are printed on stderr only if level - * is <= logLevel - * format may not contain any newline character. - ***********************************************************************/ -void error(const char *szFormat, ...) -{ - va_list ap; - - fprintf(stderr, "*** Error: "); - /*@-formatconst@ */ - va_start(ap, szFormat); - vfprintf(stderr, szFormat, ap); - va_end(ap); - /*@-formatconst@ */ - fputs("\n", stderr); - - exit(EXIT_FAILURE); -} - -/*********************************************************************** - * @Function: systemError - * @Return: never - * @Descr: dumps the system error that happened just before and exits the - * application - ***********************************************************************/ -void systemError(const char *szFormat, ...) -{ - char *szError = NULL; - va_list ap; - - if (errno) - szError = strdup(strerror(errno)); - else if (h_errno) - szError = strdup(hstrerror(h_errno)); - - fprintf(stderr, "*** Error: "); - /*@-formatconst@ */ - va_start(ap, szFormat); - vfprintf(stderr, szFormat, ap); - va_end(ap); - /*@-formatconst@ */ - if (NULL != szError) - fprintf(stderr, " (%s)", szError); - - fputs("\n", stderr); - free(szError); - - exit(EXIT_FAILURE); -} diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/log.h b/meta-digi-arm/recipes-bsp/libdigi/libdigi/log.h deleted file mode 100644 index 26f573f64..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/log.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * libdigi/log.h - * - * Copyright (C) 2001,2002 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Logging facility for applications - * - */ - -#ifndef DG_LOG_H -#define DG_LOG_H - -typedef enum { - LOG_ERR = 0, - LOG_STATUS, - LOG_HARDWARE1, - LOG_HARDWARE2, - LOG_PACKET, - LOG_LAST -} LogLevel; - -extern LogLevel logLevel; - -extern void logMsg(LogLevel level, const char *szFormat, ...); -extern void systemLog(const char *szFormat, ...); -extern void error(const char *szFormat, ...); -extern void systemError(const char *szFormat, ...); - -#endif /* DG_LOG_H */ diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.c b/meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.c deleted file mode 100644 index df4a853f9..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * mem.c - * - * Copyright (C) 2006 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: provides MemCmp() and MemDump() - * - */ - -#include /* printf */ - -#include "mem.h" - -/*********************************************************************** - * !Function: MemCmp - * !Descr: compares memory - * !Return: offset of failure or -1 if none - ***********************************************************************/ -loff_t MemCmp(const void *pvS1, const void *pvS2, size_t iSize) -{ - const char *pcS2 = (const char *)pvS2; - const char *pcS1 = (const char *)pvS1; - loff_t iOffset = 0; - - while (iOffset < iSize) { - if (*pcS2 != *pcS1) - return iOffset; - - pcS2++; - pcS1++; - iOffset++; - } - - return -1; -} - -/*********************************************************************** - * !Function: MemDump - * !Descr: Prints memory from pvbase + iOffset to pvBase + iOffset + iLen - ***********************************************************************/ -void MemDump(const void *pvBase, loff_t iOffset, size_t iLen) -{ - const unsigned char *pucBuf = (const unsigned char *)pvBase + iOffset; - const int COLUMN_COUNT = 16; - int i; - - for (i = 0; i < iLen; i += COLUMN_COUNT) { - /* print one row */ - int j, iRowLen; - - if ((i + COLUMN_COUNT) <= iLen) - iRowLen = COLUMN_COUNT; - else - iRowLen = iLen - i; - - printf("%08llx ", (long long)iOffset); - - /* print hexadecimal representation */ - for (j = 0; j < iRowLen; j++) { - printf("%02x ", *(pucBuf + j)); - if (((COLUMN_COUNT / 2) - 1) == j) - /* additional separator */ - printf(" "); - } - - printf(" "); - - /* print character representation row */ - for (j = 0; j < iRowLen; j++) { - unsigned char c = *(pucBuf + j); - if ((c < 32) || (c > 127)) - c = '.'; - - if (((COLUMN_COUNT / 2) - 1) == j) - /* additional separator */ - printf(" "); - - printf("%c", c); - } - - printf("\r\n"); - pucBuf += iRowLen; - iOffset += iRowLen; - } -} diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.h b/meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.h deleted file mode 100644 index 0316e6d56..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/mem.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * libdigi/mem.h - * - * Copyright (C) 2006 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: provides MemCmp() and MemDump() - * - */ - -#ifndef DG_MEM_H -#define DG_MEM_H - -#include /* size_t */ - -extern loff_t MemCmp(const void *pvS1, const void *pvS2, size_t iSize); -extern void MemDump(const void *pvBase, loff_t iOffset, size_t iLen); - -#endif /* DG_MEM_H */ diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/misc_helper.h b/meta-digi-arm/recipes-bsp/libdigi/libdigi/misc_helper.h deleted file mode 100644 index d809980f6..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/misc_helper.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * libdigi/misc_helper.h - * - * Copyright (C) 2006 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: miscellaneous definitions that simplifies developing - * May require 'string.h' or 'log.h' - * - */ - -#ifndef DG_MISC_HELPER_H -#define DG_MISC_HELPER_H - -#include /* snprintf */ -#include /* memset */ - -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x))) -#define CLEAR(x) memset( &x, 0, sizeof( x ) ) - -/* round up to kB */ -#define TO_KiB(x) (((x) + 1023) / 1024) - -/* to bytes */ -#define KiB(x) ((x) * 1024) -#define MiB(x) (KiB(x) * 1024) - -#define MAX(a, b) ((a) < (b) ? (b) : (a)) -#define MIN(a, b) ((a) > (b) ? (b) : (a)) - -#define FREE(x) \ - do { \ - free((void *)x); \ - x = NULL; \ - } while (0) - -#define CLOSE(x) \ - do { \ - if (close(x)) \ - systemError("close"); \ - x = -1; \ - } while (0) - -#define SPRINTF(acStr, args...) \ - snprintf(acStr, sizeof(acStr), args) - -#endif /* DG_MISC_HELPER_H */ diff --git a/meta-digi-arm/recipes-bsp/libdigi/libdigi/platform.c b/meta-digi-arm/recipes-bsp/libdigi/libdigi/platform.c deleted file mode 100644 index 25d37c514..000000000 --- a/meta-digi-arm/recipes-bsp/libdigi/libdigi/platform.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2011 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version2 as published by - * the Free Software Foundation. -*/ - -#include -#include -#include -#include - -#include "digi-platforms.h" -#include "log.h" - -/* - * Gets the platform ID from the file /proc/cpuinfo - * (the kernel needs to write the machine ID in this file). - * Returns the machine ID or -1 on error - */ -int get_platform_id(void) -{ - char buffer[80]; - FILE *fp; - long id = -1; - - fp = popen("cat /proc/cpuinfo | grep \"Machine ID\" | cut -f 2 -d :", "r"); - if (fp == NULL) - systemError("cannot access /proc/cpuinfo"); - - if (fgets(buffer, sizeof(buffer) - 1, fp)) { - errno = 0; /* to distinguish success/failure after call */ - id = strtol(buffer, NULL, 10); - if (errno != 0) - id = -1; /* don't care about the error code */ - } - fclose(fp); - - return id; -} - -/* - * get_platform_name_from_fdt - * - * Read the device tree and return platform name or NULL - */ -static char *get_platform_name_from_fdt(void) -{ - static const char *fdt = "/proc/device-tree/digi,machine,name"; - static char buffer[64]; /* static buffer so it can be used in the caller function */ - char *plat_name = NULL; - FILE *fp; - - fp = fopen(fdt, "r"); - if (fp == NULL) - goto out; - - plat_name = fgets(buffer, sizeof(buffer), fp); - fclose(fp); - -out: - return plat_name; -} - -/* - * Checks whether platform requires an atomic access to NAND OOB - */ -char is_nand_oob_atomic(void) -{ - int platform_id; - - platform_id = get_platform_id(); - if (platform_id != -1) { - /* The following platforms require atomic access to NAND OOB */ - if (MACH_TYPE_CPX2 == platform_id || - MACH_TYPE_WR21 == platform_id || - MACH_TYPE_CCMX51 == platform_id || - MACH_TYPE_CCMX51JS == platform_id || - MACH_TYPE_CCWMX51 == platform_id || - MACH_TYPE_CCWMX51JS == platform_id || - MACH_TYPE_CCIMX51 == platform_id || - MACH_TYPE_CCIMX51JS == platform_id || - MACH_TYPE_CCMX53 == platform_id || - MACH_TYPE_CCMX53JS == platform_id || - MACH_TYPE_CCWMX53 == platform_id || - MACH_TYPE_CCWMX53JS == platform_id || - MACH_TYPE_CCIMX53 == platform_id || - MACH_TYPE_CCIMX53JS == platform_id || - MACH_TYPE_CCARDMX28 == platform_id || - MACH_TYPE_CCARDMX28JS == platform_id || - MACH_TYPE_CCARDWMX28 == platform_id || - MACH_TYPE_CCARDWMX28JS == platform_id || - MACH_TYPE_CCARDIMX28 == platform_id || - MACH_TYPE_CCARDIMX28JS == platform_id) - return 1; - } else { - /* - * Workaround to detect is_nand_oob_atomic in ccardimx28 using - * linux 3.x - * TODO: generalize this. - */ - char *platform_name = get_platform_name_from_fdt(); - if (platform_name && !strcmp(platform_name, "ccardimx28")) - return 1; - } - - return 0; -} diff --git a/meta-digi-arm/recipes-bsp/nvram/nvram.inc b/meta-digi-arm/recipes-bsp/nvram/nvram.inc deleted file mode 100644 index 8b0506d23..000000000 --- a/meta-digi-arm/recipes-bsp/nvram/nvram.inc +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2013 Digi International. - -SUMMARY = "Digi's NVRAM tool" -SECTION = "base" -LICENSE = "GPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" - -require recipes-bsp/u-boot/u-boot-dey-rev_${PV}.inc - -DEPENDS = "libdigi" - -SRC_URI += " \ - file://main.c \ - file://nvram_priv_linux.c \ -" - -S = "${WORKDIR}" - -CMD_GIT_SHA1 = "$(cd ${THISDIR} && git rev-parse --short=7 HEAD)" -LIB_GIT_SHA1 = "$(cd ${WORKDIR}/git && git rev-parse --short=7 HEAD)" - -EXTRA_CFLAGS = "-Wall -DLINUX -DCMD_GIT_SHA1=\"${CMD_GIT_SHA1}\" -DLIB_GIT_SHA1=\"${LIB_GIT_SHA1}\" -Ilib/include -I${STAGING_INCDIR}/libdigi" - -do_configure() { - rm -f lib && ln -s ${UBOOT_NVRAM_LIBPATH} -} - -do_compile() { - # 'libnvram.a' static library - ${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o nvram.o lib/src/nvram.c - ${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o nvram_cmdline.o lib/src/nvram_cmdline.c - ${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o nvram_priv_linux.o nvram_priv_linux.c - ${AR} -rcs libnvram.a nvram.o nvram_cmdline.o nvram_priv_linux.o - # 'nvram' command-line tool - ${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o main.o main.c - ${CC} ${LDFLAGS} -o nvram main.o libnvram.a -ldigi -} - -do_install() { - mkdir -p ${D}${base_sbindir} ${D}${includedir} ${D}${libdir} - install -m 0644 libnvram.a ${D}${libdir}/ - install -m 0644 lib/include/nvram.h lib/include/nvram_types.h ${D}${includedir}/ - install -m 0755 nvram ${D}${base_sbindir}/ -} - -PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/meta-digi-arm/recipes-bsp/nvram/nvram/main.c b/meta-digi-arm/recipes-bsp/nvram/nvram/main.c deleted file mode 100644 index f3627cf0f..000000000 --- a/meta-digi-arm/recipes-bsp/nvram/nvram/main.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * nvram/src/main.c - * - * Copyright (C) 2006-2013 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version2 as published by - * the Free Software Foundation. - */ -/* - * !Author: Markus Pietrek - * !Descr: main() and user code for nvram. - */ - -#include /* errno */ -#include /* open */ -#include /* vprintf */ -#include /* snprintf */ -#include /* EXIT_SUCCESS */ -#include /* strdup */ -#include - -/* from libdigi */ -#include -#include -#include - -#include "nvram.h" /* Nv* */ - -#define CA(cmd) \ - do { \ - if( !cmd ) \ - ExitError( #cmd ); \ - } while( 0 ) - -#define VERSION "1.15" "-g"CMD_GIT_SHA1 - -/* Hack to change priv_linux mode */ -void NvPrivLinuxSetMode(char bManufMode); - -/* local functions */ -static void ExitError(const char *szFormat, ...); -static void OnExit(void); -static void ExtendedUsage(char bCmdLine); -static void OSLoadFromFile(nv_os_type_e eOS, const char *szFile); -static void OSSaveToFile(nv_os_type_e eOS, const char *szFile); - -static char l_bOptDetailed = 0; -static char quiet = 0; -static char l_bManufMode = 0; - -int main(int argc, char *argv[]) -{ - char acVersion[128]; - uint32_t uiLibVerMajor; - uint32_t uiLibVerMinor; - int iExtendedArgs; - const char *xPrintAll[] = { "printall" }; - const char *szOSOutFile = NULL; - const char *szOSInFile = NULL; - const char *szOS = NULL; - char bSave = 0; - nv_os_type_e eOS = NVOS_NONE; - int ret; - - CmdOptEntry aCmdEntries[] = { - /*@@-nullassign@@ */// only COT_NONE may have a NULL for vValuePtr - {COT_BOOL, 'e', &l_bOptDetailed, "error_detailed", - "detailed error messages"}, - {COT_BOOL, 'b', &g_markBadBlocks, "bad-block-marking", - "On repeated error, mark block as bad."}, - {COT_STRING, 'g', &szOSOutFile, "get_os_cfg", - "copies the os configuration block to file"}, - {COT_STRING, 's', &szOSInFile, "set_os_cfg", - "copies the os configuration block from file"}, - {COT_STRING, 'o', &szOS, "os", - "select's the OS to get configuration from"}, - {COT_BOOL, 'q', &quiet, "quiet", - "display no error messages"}, - {COT_BOOL, 'm', &l_bManufMode, "manuf-mode", - "manufacturing mode (no auto-repair, permit reset)"}, - {COT_MORE_OPT, 0, NULL, "", ""}, - {COT_NONE, 0, NULL, NULL, NULL}, - /*@@+nullassign@@ */ - }; - - NvGetLibVersion(&uiLibVerMajor, &uiLibVerMinor); - snprintf(acVersion, - sizeof(acVersion) - 1, - "Version: " VERSION ", NVRAM Library %u.%u-g" LIB_GIT_SHA1 ", compiled on " - __DATE__ "," __TIME__, uiLibVerMajor, uiLibVerMinor); - acVersion[sizeof(acVersion) - 1] = 0U; - szCmdOptVersion = acVersion; - fnCmdOptExtendedUsage = ExtendedUsage; - - iExtendedArgs = cmdOptParse(argc, argv, aCmdEntries, - "NVRAM Tool for updating nvram settings"); - logMsg(LOG_HARDWARE1, - "Sizes: Critical: %i\n" - " Module ID: %i\n" - " IP: %i\n" - " IP Device: %i\n" - " Partition Table: %i\n" - " Partition Entry: %i\n" - " OS Cfg Table: %i\n" - " OS Cfg: %i\n", - sizeof(nv_critical_t), - sizeof(nv_param_module_id_t), - sizeof(nv_param_ip_t), - sizeof(nv_param_ip_device_t), - sizeof(nv_param_part_table_t), - sizeof(nv_param_part_t), - sizeof(nv_param_os_cfg_table_t), - sizeof(nv_param_os_cfg_t)); - - /* so we can close everything even on error() or on return of main */ - atexit(OnExit); - - NvPrivLinuxSetMode(l_bManufMode); - - /* In manufacturing mode, do not let library auto-repair the NVRAM */ - ret = NvInit(l_bManufMode ? NVR_MANUAL : NVR_AUTO); - if (!ret) { - /* If NVRAM was not initialized, only continue if - * we are requesting a reset. - */ - if (argc == iExtendedArgs) { - ExitError("NvInit"); - } else { - if (strcmp("reset", argv[iExtendedArgs])) - ExitError("NvInit"); - } - } - - if (NULL != szOS) { - if (!NvToOS(&eOS, szOS)) - error("OS not known: %s\n", szOS); - } - - if (NULL != szOSInFile) { - bSave = 1; - OSLoadFromFile(eOS, szOSInFile); - } - - if (NULL != szOSOutFile) - /* it's load from NVRAM view */ - OSSaveToFile(eOS, szOSOutFile); - - if (argc == iExtendedArgs) { - if ((NULL == szOSInFile) && (NULL == szOSOutFile)) - /* on -o, the user likes to read/write something */ - CA(NvCmdLine(ARRAY_SIZE(xPrintAll), xPrintAll)); - } else { - CA(NvCmdLine(argc - iExtendedArgs, (const char **)&argv[iExtendedArgs])); - - if (!strcmp("set", argv[iExtendedArgs]) || - !strcmp("reset", argv[iExtendedArgs]) || - !strcmp("init", argv[iExtendedArgs])) - bSave = 1; - } - - if (bSave) - CA(NvSave()); - - return EXIT_SUCCESS; -} - -/* ********** local functions ********** */ - -static void ExtendedUsage(char bCmdLine) -{ - if (bCmdLine == 1) - CA(NvPrintHelp()); -} - -static void ExitError(const char *szFormat, ...) -{ - const char *szError = NULL; - const char *szWhat = NULL; - const char *szFunc = NULL; - const char *szFile = NULL; - int iLine; - - va_list ap; - - if (!quiet || l_bOptDetailed) { - fprintf(stderr, "*** Error: "); - if (l_bOptDetailed) { - /*@-formatconst@ */ - va_start(ap, szFormat); - vfprintf(stderr, szFormat, ap); - va_end(ap); - fprintf(stderr, ": "); - /*@+formatconst@ */ - } - - if (NVE_GOOD != NvErrorMsg(&szError, &szWhat, &szFunc, &szFile, &iLine)) { - if (l_bOptDetailed) - fprintf(stderr, " %s: (%s) @ %s:%i (%s)", - szError, szWhat, szFile, iLine, szFunc); - else - fprintf(stderr, " %s: (%s)", szError, szWhat); - } - - fprintf(stderr, "\n"); - } - - exit(EXIT_FAILURE); -} - -static void OSLoadFromFile(nv_os_type_e eOS, const char *szFile) -{ - int iFd; - nv_param_os_cfg_t xCfg; - void *pvTmp; - - CA(NvOSCfgFind(&xCfg, eOS)); - pvTmp = malloc(xCfg.uiSize); - if (NULL == pvTmp) - systemError("malloc: %i", xCfg.uiSize); - - iFd = open(szFile, O_RDONLY); - if (-1 == iFd) - systemError("%s", szFile); - if (-1 == read(iFd, pvTmp, xCfg.uiSize)) - systemError("read"); - CLOSE(iFd); - - CA(NvOSCfgSet(eOS, pvTmp, xCfg.uiSize)); - - FREE(pvTmp); - - printf("Loaded from %s\n", szFile); -} - -static void OSSaveToFile(nv_os_type_e eOS, const char *szFile) -{ - int iFd; - nv_param_os_cfg_t xCfg; - void *pvTmp; - size_t iSize; - - CA(NvOSCfgFind(&xCfg, eOS)); - pvTmp = malloc(xCfg.uiSize); - if (NULL == pvTmp) - systemError("malloc: %i", xCfg.uiSize); - - CA(NvOSCfgGet(eOS, pvTmp, xCfg.uiSize, &iSize)); - - iFd = open(szFile, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (-1 == iFd) - systemError("%s", szFile); - if (xCfg.uiSize != write(iFd, pvTmp, xCfg.uiSize)) - systemError("write"); - CLOSE(iFd); - FREE(pvTmp); - - printf("Stored to %s\n", szFile); -} - -/*! \brief closes all descriptors on any exit */ -static void OnExit(void) -{ - NvFinish(); -} diff --git a/meta-digi-arm/recipes-bsp/nvram/nvram/nvram_priv_linux.c b/meta-digi-arm/recipes-bsp/nvram/nvram/nvram_priv_linux.c deleted file mode 100644 index 47cbffe65..000000000 --- a/meta-digi-arm/recipes-bsp/nvram/nvram/nvram_priv_linux.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * nvram/src/nvram_priv_linux.c - * - * Copyright (C) 2006-2013 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version2 as published by - * the Free Software Foundation. - */ -/* - * !Author: Markus Pietrek - * !Descr: Defines the private functions needed by the nvram core to - * access I2C, Flash and a console for linux userspace. - */ - -#define _XOPEN_SOURCE 500 /* for pread/pwrite */ - -#include /* ENOTSUP */ -#include /* open */ -#include /* MEMERASE */ -#include /* vprintf */ -#include /* ioctl */ -#include /* stat */ - -/* from libdigi */ -#include /* systemError */ -#include /* CLEAR */ - -#include "nvram_priv.h" - -#define NVRAM_PARTITION 1 - -char g_markBadBlocks = 0; - -/* ********** local variables ********** */ -static char l_acMtd[32]; -static int l_iFdMtd = -1; -static mtd_info_t l_xMtdInfo; -static unsigned char bbMaxRetries = 3; -extern void MemDump(const void *pvBase, loff_t iOffset, size_t iLen); - -static char l_bManufMode = 0; - -/* ********** global functions ********** */ -void NvPrivLinuxSetMode(char bManufMode) -{ - /* Hack so linux nvram can change behavior of priv_linux */ - /* without ubootenv also changing. */ - l_bManufMode = bManufMode; -} - -int NvPrivOSInit(void) -{ - struct stat xStat; - - CLEAR(xStat); - - /* detect NVRAM partition */ - SPRINTF(l_acMtd, "/dev/mtd/%i", NVRAM_PARTITION); - - /* determine whether we are /dev/mtd/ or /dev/mtd */ - if (-1 == stat(l_acMtd, &xStat)) { - SPRINTF(l_acMtd, "/dev/mtd%i", NVRAM_PARTITION); - /* not dev fs */ - if (-1 == stat(l_acMtd, &xStat)) - return NV_SET_ERROR(NVE_NO_DEV, strerror(errno)); - } - - return 1; -} - -int NvPrivOSFinish(void) -{ - return 1; -} - -int NvPrivOSPostInit(void) -{ - return 1; -} - -int NvPrivOSCriticalPostReset(struct nv_critical *pParams) -{ - /* nothing to do */ - return 1; -} - -int NvPrivOSCriticalPartReset(struct nv_critical *pCrit, nv_os_type_e eForOS) -{ - if (l_bManufMode) { - /* - * In manufacturing mode, don't return an error, assuming - * that caller knows what they're doing. - */ - return 1; - } else { - /* - * Retain previous behavior of returning an error, which - * will cause us to exit before calling NvSave(); this is - * done to prevent 'nvram reset' from linux from erasing the - * OSCfgTable, since we won't properly restore the ubootenv - * section. - */ - RETURN_NOT_IMPLEMENTED(); - } -} - -int NvPrivOSFlashOpen(char bForWrite) -{ - l_iFdMtd = open(l_acMtd, bForWrite ? (O_RDWR | O_SYNC) : O_RDONLY); - if (-1 == l_iFdMtd) - return NV_SET_ERROR(NVE_NO_DEV, strerror(errno)); - - CLEAR(l_xMtdInfo); - /* read partition info */ - if (ioctl(l_iFdMtd, MEMGETINFO, &l_xMtdInfo)) { - CLOSE(l_iFdMtd); - return NV_SET_ERROR(NVE_NO_DEV, strerror(errno)); - } - - return 1; -} - -int NvPrivOSFlashClose(void) -{ - CLOSE(l_iFdMtd); - - return 1; -} - -/* A block is marked as bad as a consequence of consecutive read/write errors, - * for example unrecoverable CRC errors, or if the data verification after a - * write finds data mismatch after a number of retries. */ -static int NvPrivMarkBadBlock(int fd, loff_t iOffset) -{ - logMsg(LOG_STATUS, "Marking offset %d as bad\n", (int)iOffset); - return (ioctl(fd, MEMSETBADBLOCK, &iOffset)); -} - -int NvPrivOSFlashRead(void *pvBuf, loff_t iOffs, size_t iLength) -{ - int iRead; - int i, iRet; - - for (i = 0; i < bbMaxRetries; i++) { - iRead = pread(l_iFdMtd, pvBuf, iLength, iOffs); - - if (iRead != iLength) { - if (g_markBadBlocks) { - systemLog("Retrying failed read:Got %i " - "Bytes instead of %i.\n", iRead, iLength); - continue; - } else { - systemLog("read failed. Got %i Bytes " - "instead of %i\n", iRead, iLength); - return NV_SET_ERROR(NVE_IO, strerror(errno)); - } - } - break; - } - - if (g_markBadBlocks && (i >= bbMaxRetries)) { - /* Read error, for example unrecoverable ECC */ - iRet = NvPrivMarkBadBlock(l_iFdMtd, iOffs); - return NV_SET_ERROR(NVE_IO, strerror(iRet)); - } - - return 1; -} - -int NvPrivOSFlashErase(loff_t iOffs) -{ - erase_info_t xErase; - CLEAR(xErase); - - xErase.length = l_xMtdInfo.erasesize; - xErase.start = iOffs; - if (ioctl(l_iFdMtd, MEMERASE, &xErase)) - return NV_SET_ERROR(NVE_IO, strerror(errno)); - - return 1; -} - -int NvPrivOSFlashWrite( /*@in@ */ const void *pvBuf, loff_t iOffs, size_t iLength) -{ - int iWritten, iRead; - int i, iRet; - unsigned char *pvRdBuf; - - /* we are not called for bad sectors */ - - for (i = 0; i < bbMaxRetries; i++) { - iWritten = pwrite(l_iFdMtd, pvBuf, iLength, iOffs); - if (iWritten != iLength) { - if (g_markBadBlocks) { - systemLog("Retrying failed write:" - "Wrote %i Bytes" - " instead of %i.\n", iWritten, iLength); - continue; - } else { - logMsg(LOG_ERR, "write failed." - " Wrote %i Bytes" " instead of %i\n", iWritten, iLength); - return NV_SET_ERROR(NVE_IO, strerror(errno)); - } - } - - if (g_markBadBlocks) { - pvRdBuf = (unsigned char *)malloc(iLength); - if (NULL == pvRdBuf) { - systemLog("Malloc failed.\n"); - return NV_SET_ERROR(NVE_IO, strerror(errno)); - } - for (i = 0; i < bbMaxRetries; i++) { - iRead = pread(l_iFdMtd, pvRdBuf, iLength, iOffs); - if (iRead != iLength) { - systemLog("Retrying failed read:" - "%i < > %i.\n", iRead, iLength); - continue; - } - if (memcmp(pvRdBuf, pvBuf, iLength) != 0) { - logMsg(LOG_ERR, - "\nData mismatch at offset 0x%08x\n", iOffs); - logMsg(LOG_ERR, "Source is"); - MemDump(pvBuf, iOffs & ~0xf, MIN(iLength, 0x20)); - logMsg(LOG_ERR, "Flash is"); - MemDump(pvRdBuf, iOffs & ~0xf, MIN(iRead, 0x20)); - continue; - } - break; - } - FREE(pvRdBuf); - } - break; - } - - if (g_markBadBlocks && (i >= bbMaxRetries)) { - iRet = NvPrivMarkBadBlock(l_iFdMtd, iOffs); - return NV_SET_ERROR(NVE_IO, strerror(iRet)); - } - - return 1; -} - -int NvPrivOSFlashProtect(loff_t iOffs, size_t iLength, char bProtect) -{ - erase_info_t xErase; - CLEAR(xErase); - - xErase.length = l_xMtdInfo.erasesize; - xErase.start = iOffs; - if (ioctl(l_iFdMtd, (bProtect ? MEMLOCK : MEMUNLOCK), &xErase)) { - if (ENOTSUP != errno) - /* e.g. NAND */ - return NV_SET_ERROR(NVE_IO, strerror(errno)); - } - - return 1; -} - -int NvPrivOSFlashInfo(loff_t iOffs, -/*@out@*/ struct nv_priv_flash_status *pStatus) -{ - int iRes; - - CLEAR(*pStatus); - - /* linux hasn't an interface yet to determine erase size at iOffs. - Anyway, we place NVRAM immediately after U-Boot, so we have unique - erase sizes */ - pStatus->iEraseSize = l_xMtdInfo.erasesize; - pStatus->type = l_xMtdInfo.type; - - /* determine whether block at iOffs is bad */ - iRes = ioctl(l_iFdMtd, MEMGETBADBLOCK, &iOffs); - - if (iRes > 0) - pStatus->bBad = 1; - else if ((iRes < 0) && (ENOTSUP != errno)) - return NV_SET_ERROR(NVE_IO, strerror(errno)); - /* else if not supported (NOR), is is assumed good */ - - return 1; -} - -void NvPrivOSPrintf(const char *szFormat, ...) -{ - va_list ap; - - va_start(ap, szFormat); - vprintf(szFormat, ap); - va_end(ap); -} - -void NvPrivOSPrintfError(const char *szFormat, ...) -{ - va_list ap; - - va_start(ap, szFormat); - vfprintf(stderr, szFormat, ap); - va_end(ap); -} diff --git a/meta-digi-arm/recipes-bsp/nvram/nvram_2013.01.bb b/meta-digi-arm/recipes-bsp/nvram/nvram_2013.01.bb deleted file mode 100644 index e0667c69d..000000000 --- a/meta-digi-arm/recipes-bsp/nvram/nvram_2013.01.bb +++ /dev/null @@ -1,5 +0,0 @@ -PV = "2013.01" - -require recipes-bsp/nvram/nvram.inc - -COMPATIBLE_MACHINE = "(ccardimx28)" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-2013.01/ccardimx28/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-2013.01/ccardimx28/boot.txt deleted file mode 100644 index fa6d69123..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-2013.01/ccardimx28/boot.txt +++ /dev/null @@ -1,16 +0,0 @@ -# -# U-Boot bootscript for SD images created by Yocto. -# -# Layout: -# * U-Boot (raw copied) -# * Boot partion (FAT) with kernel images and DTB -# * Rootfs partion (EXT4) -# -# +--------------+----------------------+-------------------------+ -# | U-BOOT (RAW) | BOOT_PARTITION (FAT) | ROOTFS_PARTITION (EXT4) | -# +--------------+----------------------+-------------------------+ -# -setenv fdtimg uimage-imx28-ccardimx28js.dtb -setenv kimg uimage-ccardimx28js.bin -setenv mmc_rpart /dev/mmcblk0p3 -dboot linux mmc 0:2 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-rev_2013.01.inc b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-rev_2013.01.inc deleted file mode 100644 index 03d459756..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey-rev_2013.01.inc +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (C) 2013 Digi International - -SRCBRANCH = "v2013.01/dub-2.0/maint" -SRCREV = "${AUTOREV}" - -# Select internal or Github U-Boot repo -UBOOT_GIT_URI ?= "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git', d)}" - -SRC_URI = "${UBOOT_GIT_URI};branch=${SRCBRANCH}" - -UBOOT_NVRAM_LIBPATH = "git/board/digi/common/cmd_nvram/lib" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2013.01.bb b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2013.01.bb deleted file mode 100644 index d78543dbc..000000000 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey_2013.01.bb +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2012 Digi International - -DESCRIPTION = "Bootloader for Digi platforms" -require recipes-bsp/u-boot/u-boot.inc -include u-boot-dey-rev_${PV}.inc - -PROVIDES += "u-boot" - -LICENSE = "GPLv2+" -LIC_FILES_CHKSUM = "file://COPYING;md5=1707d6db1d42237583f50183a5651ecb" - -SRC_URI += "file://boot.txt" - -S = "${WORKDIR}/git" - -DEPENDS += "elftosb-native u-boot-mkimage-native" - -do_compile_prepend() { - ${S}/tools/setlocalversion --save-scmversion ${S} -} - -do_deploy_append() { - mkimage -T script -n bootscript -C none -d ${WORKDIR}/boot.txt ${DEPLOYDIR}/boot.scr -} - -COMPATIBLE_MACHINE = "(ccardimx28)" diff --git a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv.bb b/meta-digi-arm/recipes-bsp/ubootenv/ubootenv.bb deleted file mode 100644 index 680a4bb24..000000000 --- a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv.bb +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2013 Digi International. - -SUMMARY = "Digi's ubootenv tool" -SECTION = "base" -LICENSE = "GPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" - -DEPENDS = "libdigi nvram" - -SRC_URI = " \ - file://env_funcs.c \ - file://env_funcs.h \ - file://environment.h \ - file://main_env.c \ -" - -S = "${WORKDIR}" - -GIT_SHA1 = "$(cd ${THISDIR} && git rev-parse --short=7 HEAD)" - -EXTRA_CFLAGS = "-Wall -DLINUX -DGIT_SHA1=\"${GIT_SHA1}\" -I${STAGING_INCDIR}/libdigi" - -do_compile() { - ${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o main_env.o main_env.c - ${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o env_funcs.o env_funcs.c - ${CC} ${LDFLAGS} -o ubootenv main_env.o env_funcs.o -lnvram -ldigi -} - -do_install() { - mkdir -p ${D}${base_sbindir} - install -m 0755 ubootenv ${D}${base_sbindir}/ -} - -PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.c b/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.c deleted file mode 100644 index 588c9b6c6..000000000 --- a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * env_funcs.c - * - * Copyright (C) 2006-2013 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Function prototypes for all the flavors of the NVRAM tool - * - */ - -#include -#include - -#include "env_funcs.h" - -/* - * Function: get_var_value - * Return: NULL on failure/ pointer where var value starts on succes - * Description: Checks if the variable name is contained on the string and - * returns a pointer where the variable value starts. - */ -char *get_var_value(const char *from, const char *var_name, char sep) -{ - char *separator; - char *start; - - if (((separator = strchr(from, sep)) != NULL) && - ((start = strstr(from, var_name)) != NULL)) { - if (start < separator) - return (++separator); - } - - return NULL; -} - -/* - * Function: get_var_name - * Return: 1 on success, 0 otherwise - * Description: Retrieves the var name from a var string - */ -int get_var_name(const char *from, char *var_name, char sep) -{ - char *separator; - - if ((separator = strchr(from, sep)) != NULL) { - while (from < separator) - *var_name++ = *from++; - *var_name = 0; - return 1; - } - return 0; -} - -/* - * Function: get_next_env_string - * Return: the string to the next environment variable in UBOOT or - * NULL on failure - * Description: returns the addr of the next string in a data structure - * \0\0\0 - * It does an offset calculation to check for overflow. - */ -char *get_next_env_string(char *from, char *till) -{ - if (*from == 0) - return NULL; - - while (from < till && *from) - from++; - - if (from == till && *from) - return NULL; // Indicate string to long - - return (++from); -} - -/* - * Function: get_var_addr - * Return: the pointer to the address string or NULL if not found. - * Description: Returns the addr of the variable in a data structure - * \0\0\0 - * It does an offset calculation to check for overflow. - */ -char *get_var_addr(char *from, char *till, char *var_name) -{ - char *data = from; - char *var_addr; - char var_name_temp[ENV_MAX_VAR_NAME_LEN + 1]; - - sprintf(var_name_temp, "%s%s", var_name, "="); - - do { - if (*data && data < till) { - if ((var_addr = strstr(data, var_name_temp)) != NULL - && (var_addr == data)) - return var_addr < till ? var_addr : NULL; - } - } while ((data = get_next_env_string(data, till)) != NULL); - - return NULL; -} - -/* - * Function: get_end_mark - * Description: - */ -char *get_end_mark(char *from, char *till) -{ - while (from < till) { - while (*from) - from++; - if (from >= till) - return NULL; - if (*(++from) == 0) - return from; - } - return NULL; -} - -/* - * Function: remove_var - * Return: 1 on success, 0 otherwise - * Description: Remove environment variables - */ -int remove_var(char *from, char *till, char *var_name) -{ - char *var_addr; - char *env_end; - char *var_end; - - /* Check if variable already exists */ - if ((var_addr = get_var_addr(from, till, var_name)) != NULL) { - if ((env_end = get_end_mark(var_addr, till)) != NULL) { - if ((var_end = get_next_env_string(var_addr, till)) != NULL) { - while (var_end <= env_end) - *var_addr++ = *var_end++; - while (var_addr <= env_end) - *var_addr++ = 0; /* Just to have a clean environment :-) */ - return 1; - } - } - } - - return 0; -} - -/* - * Function: add_var - * Return: 1 on success, 0 otherwise - * Description: Add a new environment variable - */ -int add_var(char *from, char *till, char *var_str) -{ - char *var_addr; - char var_name[ENV_MAX_VAR_NAME_LEN]; - - if (get_var_name(var_str, var_name, '=')) { - /* Check if variable already exists */ - if ((var_addr = get_var_addr(from, till, var_name)) != NULL) { - /* @TODO: remove more?? could be that it were there more than once?? */ - if (!remove_var(var_addr, till, var_name)) - return 0; - } - /* Append the variable to the end */ - if ((var_addr = get_end_mark(from, till)) != NULL) { - /* Check if environment is empty. If yes, start from the beginning */ - if (var_addr == (from + 1)) - var_addr--; - while (var_addr < till && *var_str) - *var_addr++ = *var_str++; - *var_addr++ = 0; - *var_addr = 0; - return 1; - } else { - fprintf(stderr, "Unable to find environment end\n"); - } - } - - return 0; -} diff --git a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.h b/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.h deleted file mode 100644 index 051ca0662..000000000 --- a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/env_funcs.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * env_funcs.h - * - * Copyright (C) 2006-2013 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Data types and prototypes for parsing the NVRAM environment - * - */ - -#ifndef ENV_FUNCS_H -#define ENV_FUNCS_H - -#define ENV_MAX_VAR_NAME_LEN 50 -#define ENV_MAX_VAR_VAL_LEN 256 - -char *get_var_value(const char *from, const char *var_name, char sep); -char *get_next_env_string(char *from, char *till); -char *get_var_addr(char *from, char *till, char *var_name); -char *get_end_mark(char *from, char *till); -int get_var_name(const char *from, char *var_name, char sep); -int add_var(char *from, char *till, char *var_str); -int remove_var(char *from, char *till, char *var_name); - -#endif diff --git a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/environment.h b/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/environment.h deleted file mode 100644 index ea60bd84a..000000000 --- a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/environment.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * environment.h - * - * Copyright (C) 2006-2013 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: Data types and definitions for environment in NVRAM - * - */ - -#ifndef __ENV_TOOL_H_ -#define __ENV_TOOL_H_ - -#define VAR_SEP '\0' -#define VAR_ASIGN '=' - -typedef struct { - unsigned long crc; - char data[]; -} env_t; - -#endif diff --git a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/main_env.c b/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/main_env.c deleted file mode 100644 index 1e5a7257f..000000000 --- a/meta-digi-arm/recipes-bsp/ubootenv/ubootenv/main_env.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * main_env.c - * - * Copyright (C) 2006-2013 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * Description: main() and user code to manage u-boot and linux environment - * - */ - -#define VERSION "1.8" "-g"GIT_SHA1 - -#include -#include -#include -#include /* MEMERASE */ -#include -#include -#include -#include /* ioctl */ -#include - -#include - -#include /* Nv* */ - -#include "env_funcs.h" -#include "environment.h" - -#define APP_UBOOTENV "ubootenv" -#define APP_PRODINFOENV "prodinfoenv" - -static char *fileadd = NULL; -static char *printlist = NULL; -static char *setstring = NULL; -static char *eraselist = NULL; -static char *cmdname = NULL; -static int dump = 0, clean = 0; -static nv_os_type_e envType; - -static const char *envTypes[] = { - [NVOS_NONE] = "None", - [NVOS_UBOOT] = "U-Boot", - [NVOS_PROD_INFO] = "Product Info", -}; - -static const size_t envDefaultSizes[] = { - [NVOS_NONE] = 0, - [NVOS_UBOOT] = 8192, /* Default value is CONFIG_ENV_SIZE, normally set by U-Boot */ - [NVOS_PROD_INFO] = PROD_INFO_DATA_SIZE, /* Defined in nvram.h but shouldn't be except uboot needs it */ -}; - -static const char* excludeVars[][2] = { - {"ethaddr", "ethaddr1" }, - {"wlanaddr", "ethaddr2" }, - {"eth1addr", "ethaddr3" }, - {"ipaddr", "ip1" }, - {"ipaddr_wlan", "ip2" }, - {"ipaddr1", "ip3" }, - {"netmask", "netmask1" }, - {"netmask_wlan","netmask2" }, - {"netmask1", "netmask3" }, - {"serverip", "server" }, - {"gatewayip", "gateway" }, - {"dnsip", "dns1" }, - {"dnsip2", "dns2" }, - {"dhcp", "dhcp1" }, - {"dhcp_wlan", "dhcp2" }, - {"dhcp1", "dhcp3" }, -}; - -static const char *env_os_type_to_string(void) -{ - return envTypes[envType]; -} - -static int env_onetime_writable(void) -{ - if (NVOS_PROD_INFO == envType) - return 1; - - return 0; -} - -static int env_is_empty(env_t * env, unsigned int envlen) -{ - char *from = (char *)&env->data; - char *till = (char *)&env->data + envlen; - char *end; - - end = get_end_mark(from, till); - /* Check if environment is empty. If yes, start from the beginning */ - if (end == (from + 1)) - return 1; - - return 0; -} - -static int env_have_to_use_nvram(const char *varname) -{ - int j; - - if (envType == NVOS_UBOOT) { - for (j = 0; j < ARRAY_SIZE(excludeVars); j++) { - if (strcmp(varname, excludeVars[j][0]) == 0) - return j; - } - } - return -1; -} - -static void show_usage(void) -{ - fprintf(stdout, "Usage: %s [options]\n" - "%s %s Copyright Digi International Inc.\n\n" - "Prints or updates the %s environment\n" - "\n" - " -d, --dump Prints the values of all the environment\n" - " -p, --print 'var_name_list' Prints the value of the list of variables\n" - " The list has to be simple quoted ('')\n" - " -s, --set 'var_name=var_value' Sets var_value in the variable var_name\n" - " The string has to be simple quoted ('') to allow\n" - " spaces\n" - " -e --erase 'var_name_list' Removes the list of variables (simple quoted)\n" - " -c --clean Removes all variables\n" - " -a --fileadd file_name Adds variables from file_name. To init the full\n" - " environment from file use -c -a simultaneously\n" - " -h --help Displays usage information\n\n", - cmdname, cmdname, VERSION, env_os_type_to_string()); - - if (env_onetime_writable()) { - fprintf(stdout, " WARNING: Variables can only be set the first time\n" - " and become read-only afterwards.\n"); - } -} - -static void show_usage_and_exit(int exit_code) -{ - show_usage(); - exit(exit_code); -} - -static void process_options(int argc, char *argv[]) -{ - int opt_index, opt, optcount = 0; - static const char *short_options = "?hdcp:s:e:a:"; - static const struct option long_options[] = { - {"dump", no_argument, NULL, 'd'}, - {"help", no_argument, NULL, 'h'}, - {"erase", required_argument, NULL, 'e'}, - {"clean", no_argument, NULL, 'c'}, - {"fileadd", required_argument, NULL, 'a'}, - {"print", required_argument, NULL, 'p'}, - {"set", required_argument, NULL, 's'}, - {0, 0, 0, 0}, - }; - - for (opt_index = 0;;) { - - opt = getopt_long(argc, argv, short_options, long_options, &opt_index); - if (opt == EOF) - break; - - switch (opt) { - case 'd': - dump = 1; - break; - case 'p': - printlist = optarg; - break; - case 's': - setstring = optarg; - break; - case 'a': - fileadd = optarg; - break; - case 'e': - eraselist = optarg; - break; - case 'c': - clean = 1; - break; - case 'h': - case '?': - show_usage_and_exit(EXIT_SUCCESS); - break; - } - optcount++; - } - - if (optcount == 0) - show_usage_and_exit(EXIT_FAILURE); - - /* Check options */ - if (dump && (printlist != NULL)) { - fprintf(stderr, "--dump and --print can't be used simultaneously\n"); - show_usage_and_exit(EXIT_FAILURE); - } - if (clean && (eraselist != NULL)) { - fprintf(stderr, "--clean and --erase can't be used simultaneously\n"); - show_usage_and_exit(EXIT_FAILURE); - } -} - -static int env_add_var(const char *varstring, env_t * env, unsigned int envlen) -{ - char *nvramCmd[3] = { "set", "network", NULL }; - char tmpstr[50]; - - char *varval; - int j; - - if (varstring == NULL) - return -EINVAL; - - if (!get_var_name(varstring, tmpstr, VAR_ASIGN)) - return -EINVAL; - - /* Check if is a special variable */ - if ((j = env_have_to_use_nvram(tmpstr)) != -1) { - if ((varval = get_var_value(varstring, excludeVars[j][0], VAR_ASIGN)) != NULL) { - /* Define command to be used by nvram */ - sprintf(tmpstr, "%s=%s", excludeVars[j][1], varval); - nvramCmd[2] = tmpstr; - if (!NvCmdLine(3, (const char **)nvramCmd)) { - return -EINVAL; - } - } - } else { - if (!add_var(env->data, env->data + envlen, (char *)varstring)) { - return -EINVAL; - } - } - - return 0; -} - -static int env_add_vars_from_file(char *filename, env_t * env, unsigned int envlen) -{ - FILE *fp; - char line[ENV_MAX_VAR_NAME_LEN + ENV_MAX_VAR_VAL_LEN + 3]; - int ret = EXIT_SUCCESS; - - if ((fp = fopen(filename, "r")) == NULL) - return -errno; - - while (!feof(fp)) { - if (fgets(line, sizeof(line), fp)) { - /* TODO should we remove comments starting with # ?? */ - /* Remove '\n' */ - if (line[strlen(line) - 1] == '\n') - line[strlen(line) - 1] = 0; - if (env_add_var((const char *)line, env, envlen)) { - fprintf(stderr, "Unable to add environment variable %s\n", - line); - ret = -EINVAL; - goto out; - } - } - } - - out: - if (fp) - fclose(fp); - return ret; -} - -static void env_remove_varlist(const char *varlist, env_t * env, unsigned int envlen) -{ - char *var; - - var = strtok((char *)varlist, " "); - - while (var != NULL) { - if (!remove_var(env->data, env->data + envlen, var)) - fprintf(stderr, "Unable to remove environment variable %s\n", var); - var = strtok(NULL, " "); - } -} - -static int env_validate(env_t * env, int datalen, int verbose) -{ - unsigned long new_crc; - - /* Check stored crc with data */ - new_crc = crc32(0, (const unsigned char *)env->data, datalen); - - if ((unsigned int)env->crc != new_crc) { - if ( verbose ) { - fprintf(stderr, "CRC failure: got 0x%08x expected 0x%08x\n", - (unsigned int)env->crc, (unsigned int)new_crc); - } - return 1; - } - return 0; -} - -static void env_printenv_nvram_vars(char *varname) -{ - struct nv_critical *crit; - nv_param_ip_t *ip_params; - int index; - int oneloop = 0; - - if (NvCriticalGet(&crit)) { - - ip_params = &crit->s.p.xIP; - for (index = 3; index < ARRAY_SIZE(excludeVars); index++) { - if (varname != NULL) { - if ((index = env_have_to_use_nvram(varname)) == -1) - break; - oneloop = 1; - } - - switch (index) { - case 3: - fprintf(stdout, "ipaddr=%s\n", - NvToStringIP(ip_params->axDevice[0].uiIP)); - break; - case 4: - fprintf(stdout, "ipaddr_wlan=%s\n", - NvToStringIP(ip_params->axDevice[1].uiIP)); - break; - case 5: - fprintf(stdout, "ipaddr1=%s\n", - NvToStringIP(crit->s.p.eth1dev.uiIP)); - break; - case 6: - fprintf(stdout, "netmask=%s\n", - NvToStringIP(ip_params->axDevice[0].uiNetMask)); - break; - case 7: - fprintf(stdout, "netmask_wlan=%s\n", - NvToStringIP(ip_params->axDevice[1].uiNetMask)); - break; - case 8: - fprintf(stdout, "netmask1=%s\n", - NvToStringIP(crit->s.p.eth1dev.uiNetMask)); - break; - case 9: - fprintf(stdout, "serverip=%s\n", - NvToStringIP(ip_params->uiIPServer)); - break; - case 10: - fprintf(stdout, "gatewayip=%s\n", - NvToStringIP(ip_params->uiIPGateway)); - break; - case 11: - fprintf(stdout, "dnsip=%s\n", - NvToStringIP(ip_params->auiIPDNS[0])); - break; - case 12: - fprintf(stdout, "dnsip2=%s\n", - NvToStringIP(ip_params->auiIPDNS[1])); - break; - case 13: - fprintf(stdout, "dhcp=%s\n", - (ip_params->axDevice[0].flags.bDHCP ? "on" : "off")); - break; - case 14: - fprintf(stdout, "dhcp_wlan=%s\n", - (ip_params->axDevice[1].flags.bDHCP ? "on" : "off")); - break; - case 15: - fprintf(stdout, "dhcp1=%s\n", - (crit->s.p.eth1dev.flags.bDHCP ? "on" : "off")); - break; - } - if (oneloop) - break; - } - } -} - -static void env_printenv(int dump, char *varlist, env_t * env, unsigned int envlen) -{ - char *var; - char *data = env->data; - char *varinenv; - - if (dump) { - /* print the full environment */ - while (data != NULL && *data) { - fprintf(stdout, "%s\n", data); - data = get_next_env_string(data, env->data + envlen); - } - if (envType == NVOS_UBOOT) - env_printenv_nvram_vars(NULL); - return; - } else { - var = strtok((char *)varlist, " "); - - while (var != NULL) { - - if (envType == NVOS_UBOOT) - env_printenv_nvram_vars(var); - if ((varinenv = - get_var_addr(env->data, env->data + envlen, var)) != NULL) { - fprintf(stdout, "%s\n", varinenv); - } - var = strtok(NULL, " "); - } - } -} - -int main(int argc, char *argv[]) -{ - unsigned int envlen = 0; - env_t *env = NULL; - nv_param_os_cfg_t xCfg; - size_t iSize; - int save_env = 0; - int ret = EXIT_SUCCESS; - int found; - char *cmdstart; - - cmdname = argv[0]; - - cmdname = *argv; - - if ((cmdstart = strrchr(cmdname, '/')) != NULL) { - cmdname = cmdstart + 1; - } - - if (strcmp(cmdname, APP_UBOOTENV) == 0) - envType = NVOS_UBOOT; - else if (strcmp(cmdname, APP_PRODINFOENV) == 0) - envType = NVOS_PROD_INFO; - else { - fprintf(stderr, "This application can be invoked as:\n" - "%s\n%s\n\n", APP_UBOOTENV, APP_PRODINFOENV); - return EXIT_FAILURE; - } - - /* read and process command line */ - process_options(argc, argv); - - if (!NvInit(NVR_AUTO)) { - fprintf(stderr, "Unable to initialize nvram\n"); - return EXIT_FAILURE; - } - - found = NvOSCfgFind(&xCfg, envType); - - if (!found && clean) { - /* Add missing section to nvram if --clean specified */ - - if (envDefaultSizes[envType] != 0 ) { - if (!NvOSCfgAdd(envType, envDefaultSizes[envType])) { - fprintf(stderr, "Unable to add missing %s environment to flash\n", - env_os_type_to_string()); - return EXIT_FAILURE; - } - - /* Try again to find our section */ - found = NvOSCfgFind(&xCfg, envType); - } - } - - if (!found) { - fprintf(stderr, "Unable to detect %s environment in flash\n", - env_os_type_to_string()); - return EXIT_FAILURE; - } - - env = malloc(xCfg.uiSize); - if (NULL == env) { - perror("malloc"); - return EXIT_FAILURE; - } - - memset(env, 0, xCfg.uiSize); - /* Adjust envlen for just for data, crc32 value not included */ - envlen = xCfg.uiSize - sizeof(unsigned long); - - if (!NvOSCfgGet(envType, (void *)env, xCfg.uiSize, &iSize)) { - /* This can't fail; we either found it, created it, or exited. */ - /* But just to be safe... */ - fprintf(stderr, "Unable to get %s environment from flash\n", - env_os_type_to_string()); - ret = EXIT_FAILURE; - goto free_and_ret; - } - - /* Check if env is one-time writable, is valid, and was already written */ - if (env_onetime_writable() && !env_validate(env, envlen, 0) && - !env_is_empty(env, envlen)) { - if ( clean || fileadd || eraselist || setstring ) { - fprintf(stderr, "Environment is one-time writable only\n"); - ret = EXIT_FAILURE; - goto free_and_ret; - } - } - - if (clean) { - memset(env, 0, xCfg.uiSize); - save_env = 1; - } else { - if (env_validate(env, envlen, 1)) { - fprintf(stderr, "Invalid %s environment found\n", - env_os_type_to_string()); - ret = EXIT_FAILURE; - goto free_and_ret; - } - } - - if (fileadd != NULL) { - if (env_add_vars_from_file(fileadd, env, envlen) < 0) { - fprintf(stderr, "Unable to add %s environment from file %s\n", - env_os_type_to_string(), fileadd); - ret = EXIT_FAILURE; - goto free_and_ret; - } - save_env = 1; - } - - if (eraselist != NULL) { - env_remove_varlist(eraselist, env, envlen); - save_env = 1; - } - - if (setstring != NULL) { - if (env_add_var(setstring, env, envlen)) { - fprintf(stderr, "Unable to add environment variable %s\n", setstring); - ret = EXIT_FAILURE; - goto free_and_ret; - } - save_env = 1; - } - - if (dump) { - env_printenv(1, NULL, env, envlen); - } else if (printlist != NULL) { - env_printenv(0, printlist, env, envlen); - } - - if (save_env) { - /* Compute new crc32 value just in case we are going to update the value in flash */ - env->crc = crc32(0, (const unsigned char *)env->data, envlen); - - if (!NvOSCfgSet(envType, env, xCfg.uiSize)) { - fprintf(stderr, "Unable to set %s environment to store in flash\n", - env_os_type_to_string()); - ret = EXIT_FAILURE; - } - if (!NvSave()) { - fprintf(stderr, "Unable to save %s environment in flash\n", - env_os_type_to_string()); - ret = EXIT_FAILURE; - } - } - - free_and_ret: - free(env); - return ret; -} - diff --git a/meta-digi-arm/recipes-bsp/update-flash/update-flash.bb b/meta-digi-arm/recipes-bsp/update-flash/update-flash.bb deleted file mode 100644 index 49194d0b7..000000000 --- a/meta-digi-arm/recipes-bsp/update-flash/update-flash.bb +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2013,2017 Digi International. - -SUMMARY = "Digi's update test utility" -SECTION = "base" -LICENSE = "GPL-2.0" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" - -DEPENDS += "libdigi" -RDEPENDS_${PN}_append_mxs = " kobs-ng" - -SRC_URI = "file://update_flash.c \ - file://jffs2-user.h \ - " - -GIT_SHA1 = "$(cd ${THISDIR} && git rev-parse --short HEAD)" - -S = "${WORKDIR}" - -do_compile() { - ${CC} -O2 -Wall ${LDFLAGS} -DGIT_SHA1=\"${GIT_SHA1}\" update_flash.c -o update_flash -ldigi -} - -do_install() { - install -d ${D}${bindir} - install -m 0755 update_flash ${D}${bindir} -} diff --git a/meta-digi-arm/recipes-bsp/update-flash/update-flash/jffs2-user.h b/meta-digi-arm/recipes-bsp/update-flash/update-flash/jffs2-user.h deleted file mode 100644 index 001685d7f..000000000 --- a/meta-digi-arm/recipes-bsp/update-flash/update-flash/jffs2-user.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * JFFS2 definitions for use in user space only - */ - -#ifndef __JFFS2_USER_H__ -#define __JFFS2_USER_H__ - -/* This file is blessed for inclusion by userspace */ -#include -#include -#include - -#undef cpu_to_je16 -#undef cpu_to_je32 -#undef cpu_to_jemode -#undef je16_to_cpu -#undef je32_to_cpu -#undef jemode_to_cpu - -extern int target_endian; - -#define t16(x) ({ uint16_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); }) -#define t32(x) ({ uint32_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); }) - -#define cpu_to_je16(x) ((jint16_t){t16(x)}) -#define cpu_to_je32(x) ((jint32_t){t32(x)}) -#define cpu_to_jemode(x) ((jmode_t){t32(x)}) - -#define je16_to_cpu(x) (t16((x).v16)) -#define je32_to_cpu(x) (t32((x).v32)) -#define jemode_to_cpu(x) (t32((x).m)) - -#endif /* __JFFS2_USER_H__ */ diff --git a/meta-digi-arm/recipes-bsp/update-flash/update-flash/update_flash.c b/meta-digi-arm/recipes-bsp/update-flash/update-flash/update_flash.c deleted file mode 100644 index 4c91ab90f..000000000 --- a/meta-digi-arm/recipes-bsp/update-flash/update-flash/update_flash.c +++ /dev/null @@ -1,1770 +0,0 @@ -/* - * update_flash.c - * - * Copyright (C) 2006 by Digi International Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - */ -/* - * - * !Revision: $Revision: 1.25 $ - * !Descr: Flash Test Util - * !References: [1] mtd-utils/flash_eraseall.c - * [2] http://www.linux-mtd.infradead.org/doc/nand.html - * [3] http://www.linux-mtd.infradead.org/tech/mtdnand/x255.html - */ - -#define _XOPEN_SOURCE 500 /* for pread/pwrite */ - -#include /* ENOENT */ -#include /* open */ -#include /* basename */ -#include /* regexp */ -#include /* kill */ -#include /* varg */ -#include /* printf */ -#include /* EXIT_SUCCESS */ -#include /* memset */ -#include /* close */ -#include /* reboot */ - -#include /* ntohl */ -#include /* setmntent */ -#include /* ioctl */ -#include /* mount */ -#include /* stat */ -#include /* statfs */ - -#include /* MEMERASE */ - -static int target_endian = __BYTE_ORDER; /* for jffs2-user.h, cpu_to_je16 */ -#include "jffs2-user.h" /* jffs2_unknown_node */ - -/* libdigi */ -#include -#include -#include -#include -#include -#include - -#define VERSION "1.25" "-g"GIT_SHA1 - -/* man statfs does mention them, but they are only defined inside kernel */ -#define NFS_SUPER_MAGIC 0x6969 /* linux/nfs_fs.h */ -#define JFFS2_SUPER_MAGIC 0x72b6 /* linux/jffs2.h */ - -#define IO_BLOCK_SIZE 65536 - -#define FLASH_ERASED_BYTE 0xff - -#define WARNING "!!! " -#define INFO "--- " - -#define PRINTF(...) \ - do { \ - if (!cSilent) \ - printf(__VA_ARGS__); \ - } while (0) - -#define PERCENTAGE(iCurrent, iTotal) ((iCurrent * 100) / (iTotal ? iTotal : 1)) - -#define SET_CRC32(pMtd, uiCRC32) \ - do { \ - pMtd->uiCRC32 = uiCRC32; \ - pMtd->cChecksumSet = 1; \ - } while (0) - -/* open it at least read-only so we can see whether open fails or not */ -#define OPEN_READWRITE_IF_NOT_DRY ((cDryRun ? O_RDONLY : O_RDWR) | O_SYNC) - -/* ********** data types ********** */ - -typedef enum { - PTUBoot = 0, - PTKernel, - PTEnvironment, - PTFPGA, - PTBootstream, - PTUnknown /* always last */ -} PartType_e; - -typedef enum { - FTUBoot = 0, - FTKernel, - FTFPGA, - FTNVRAM, - FTJFFS2, - FTSQUASHFS, - FTUBI, - FTBootstream, - FTUnknown /* always last */ -} FileType_e; - -typedef struct { - /* configuration data */ - const char *szOrigImageFileName; - const char *szImageFileName; /* may later be /tmp/ */ - unsigned int uiPartition; - char cChecksumSet; - char cEraseAll; - uint32_t uiCRC32; - - /* auto-detected */ - char cChecksumCalculated; - char acName[64]; - char cIsNAND; - char cWriteCleanMarker; - char cFileType; - char cIsJFFS2; - loff_t iSize; - loff_t iFileSize; - size_t iPageSize; - mtd_info_t xInfo; - unsigned int uiBadBlocks; - PartType_e ePartType; - FileType_e eFileType; - FileType_e eFileTypeNeeded; - - /* open handles */ - int iFd; /* of Partition */ - - /* status */ - char cAlreadyPrintedVerifyWarning; - char cAlreadyRemounted; - - unsigned int uiClMPos; - unsigned int uiClMLen; - struct jffs2_unknown_node xCleanMarker; -} mtdPartition_t; - - -/* ********** function definitions ********** */ - -/* top level functions */ -static void DoPrintChecksums(void); -static void DoMtdUpdate(void); -static void DoMtdVerify(void); - -static void OnExit(void); - -/* helper functions */ -static void MtdInit(void); -static void MtdPartInit( /*@out@ */ mtdPartition_t * pMtd, unsigned int uiPartition, - const char *szImageFileName); -static void MtdPartOpen( /*@inout@ */ mtdPartition_t * pMtd, char cReadOnly); -static void MtdPartClose( /*@inout@ */ mtdPartition_t * pMtd); -static int MtdPartIsBadBlock(const mtdPartition_t * pMtd, loff_t iOffset); -static void MtdPartUseFile( /*@inout@ */ mtdPartition_t * pMtd, const char *szImageFileName); -static void MtdPartErase(const mtdPartition_t * pMtd); -static void MtdPartWrite(mtdPartition_t * pMtd); -static int MtdPartVerify(mtdPartition_t * pMtd); -static void MtdPartCheckCRC32(mtdPartition_t * pMtd); -static void MtdPartCopyFile(mtdPartition_t * pMtd, const char *szDstFileName); -static void MtdPartInitCleanMarker(const mtdPartition_t * pMtd, - struct jffs2_unknown_node *pCleanMarker, - unsigned int *puiClMPos, unsigned int *puiClMLen); -static void MtdPartInitJFFS2Node(struct jffs2_unknown_node *pNode, unsigned short uhNodeType, - size_t iLen); -static void MtdPartCompareCRC32(mtdPartition_t * pMtd, uint32_t uiCRC32); -static void MtdPartRemountAllReadOnly(mtdPartition_t * pMtd); -static void MtdPartDeterminePartType(mtdPartition_t * pMtd); -static void MtdPartDetermineAndCheckFileType(mtdPartition_t * pMtd); -static void MtdPartVerifyFile(mtdPartition_t * pMtd); -static void MtdPartVerifyJFFS2Block(mtdPartition_t * pMtd, unsigned char *pucData, - size_t iSize); -static int MtdPartGetThrottle(const mtdPartition_t * pMtd, uint64_t ullSize); -static void PrintProgress(int iPercentage, int iThrottle, const char *szFmt, ...); -static void VerifyTmpDir(void); -static uint32_t CalcCRC32OfFile(const char *szFileName); -static const char *GetRootDevice(void); -static void mtd_part_write_ubi(mtdPartition_t * pMtd); - -/* ********** local variables ********** */ - -/* set by command line */ -static const char *szTmpDir = NULL; -static const char *szKey = NULL; -static char cNoImageTypeCheck = 0; -static char cProgressInNewLine = 0; -static char cSilent = 0; -static char cChecksumOnly = 0; -static char cDoReboot = 0; -static char cHasChecksum = 0; -static char cWriteCleanMarker = 0; -static char cDryRun = 0; -static char cVerify = 0; -static char cVerifyOnly = 0; -static char cEraseAll = 0; -static char cMaxRetries = 3; -static char cMarkBadBlocks = 0; - -/* calculated */ -static mtdPartition_t axMtdParts[64]; -static mtdPartition_t *pMtdPartLastToUpdate = axMtdParts; -static const char *szMtdPrefix = "/dev/mtd/"; -static const char *szMtdBlockPrefix = "/dev/mtdblock/"; -static unsigned int uiMtdPartsCount = 0; - -#define MK(x, szName)[x] = szName -static const char *aszPartType[PTUnknown + 1] = { - MK(PTUBoot, "U-Boot"), - MK(PTKernel, "Kernel"), - MK(PTEnvironment, "NVRAM"), - MK(PTFPGA, "FPGA"), - MK(PTBootstream, "Bstrm-U-Boot"), - MK(PTUnknown, "Unknown"), -}; -#undef MK - -#define MK(x, szRegExp, szName)[x] = {szRegExp, szName} -static const struct { - const char *szExp; - const char *szName; -} axFileType[FTUnknown + 1] = { - MK(FTUBoot, "u-boot-.*\\.bin", "UBoot"), - MK(FTNVRAM, "nvram-.*", "NVRAM"), - MK(FTKernel, "uImage-.*", "Kernel"), - MK(FTFPGA, ".*\\.biu", "FPGA"), - MK(FTJFFS2, ".*\\.jffs2", "JFFS2"), - MK(FTSQUASHFS, ".*\\.squashfs", "SQUASHFS"), - MK(FTUBI, ".*\\.ubi", "UBI"), - MK(FTBootstream, ".*\\.sb", "Bootstream"), - MK(FTUnknown, ".*", "Unknown"), -}; -#undef MK - -/* ********** function implementations ********** */ - -int main(int argc, char *argv[]) -{ - int iPartListIndex; - - CmdOptEntry aCmdEntries[] = { - {COT_BOOL, 'C', &cChecksumOnly, "checksum-only", - "calculates only CRC32 checksum of image"}, - {COT_BOOL, 'R', &cDoReboot, "reboot", - "reboots the system"}, - {COT_BOOL, 'V', &cVerifyOnly, "verify-only", - "verifies current contents, no updates are done"}, - {COT_BOOL, 'v', &cVerify, "verify", - "After flashing, compare flash contents with image on byte-to-byte"}, - {COT_BOOL, 'c', &cHasChecksum, "checksum", - "flashes only when checksum matches"}, - {COT_BOOL, -1, &cDryRun, "dry-run", - "don't erase or write to the flash"}, - {COT_BOOL, -1, &cProgressInNewLine, "progress-in-new-line", - "each percentage is printed in an own line"}, - {COT_BOOL, 'i', &cNoImageTypeCheck, "no-image-type-check", - "doesn't check image type for partition"}, - {COT_BOOL, 'f', &cEraseAll, "erase-all", - "erases the partition, not only the parts being written"}, - {COT_BOOL, -1, &cWriteCleanMarker, "clean-marker", - "writes clean markers to every partition (implies -f)"}, - {COT_BOOL, 'b' , &cMarkBadBlocks, "bad-block-marking", - "On repeated error, marks block as bad."}, - {COT_BOOL, 's', &cSilent, "silent", - "Silent Mode"}, - {COT_STRING, 't', &szTmpDir, "tmpdir", - "copy files to temporary directory before flashing"}, - {COT_STRING, 'k', &szKey, "encrypt_key", - "Verify bootstream image against encryption key"}, - {COT_MORE, 0, NULL, "", - "file to flash to partition and check for checksum"}, - {COT_NONE, 0, NULL, NULL, NULL}, - }; - - CLEAR(axMtdParts); - - szCmdOptVersion = "Version: " VERSION ", compiled on " __DATE__ "," __TIME__; - iPartListIndex = cmdOptParse(argc, argv, aCmdEntries, - "Flash Update Tool\n\n" - "Examples of use cases:\n" - " update_flash rootfs-ccw9cjsnand-128.jffs2 4\n" - " => updates partition /dev/mtd4 with rootfs image\n" - "\n" - " update_flash -C uImage-ccw9cjsnand\n" - " => calculates file CRC32 only\n" - "\n" - " update_flash -c uImage-ccw9cjsnand 3 0x1051e3c9\n" - " => updates partition /dev/mtd3 only if CRC32 of file is 0x1051e3c9\n" - "\n" - " update_flash uImage-ccw9cjsnand 3 rootfs-ccw9cjsnand-128.jffs2 4:\n" - " => updates kernel at partition 3 and rootfs at partition 4\n" - "\n" - " update_flash u-boot-cpx2-ivt.sb 0 -k 48855699413545113545511513300447\n" - " => updates bootstream file on partition 0 if the encryption key matches\n"); - - /* so we can close everything even on error() or on return of main */ - atexit(OnExit); - - /* Force disable writing clean markers for platforms that require atomic - * access to the OOB */ - if (cWriteCleanMarker && is_nand_oob_atomic()) { - PRINTF(WARNING "JFFS2 clean markers disabled for this platform\n"); - cWriteCleanMarker = 0; - } - - if (cWriteCleanMarker) - cEraseAll = 1; - - if (!cChecksumOnly) - MtdInit(); - - /* check what files to write to what partition */ - while (iPartListIndex < argc) { - unsigned int uiPartition = 0; - - if ((pMtdPartLastToUpdate - axMtdParts) >= ARRAY_SIZE(axMtdParts)) - error("Too many partitions to update on command line"); - - if (iPartListIndex > (argc - (1 + (cChecksumOnly ? 0 : 1) + (cHasChecksum ? 1 : 0)))) - error("Require filename%s%s", (cChecksumOnly ? "" : " and partition"), - (cHasChecksum ? " and checksum" : "")); - - if (!cChecksumOnly) { - /* check partition argument */ - if (sscanf(argv[iPartListIndex + 1], "%u", &uiPartition) != 1) - error("Wrong partition number\n"); - - if (uiPartition >= uiMtdPartsCount) - error("Have only %u mtd partitions", uiMtdPartsCount); - - MtdPartInit(pMtdPartLastToUpdate, uiPartition, argv[iPartListIndex]); - iPartListIndex++; - } else { - /* initialize it partly */ - CLEAR(*pMtdPartLastToUpdate); - pMtdPartLastToUpdate->iFd = -1; - MtdPartUseFile(pMtdPartLastToUpdate, argv[iPartListIndex]); - } - - if (cHasChecksum) { - /* parse checksum argument */ - const char *szCRC32 = argv[iPartListIndex + 1]; - uint32_t uiCRC32; - - if (sscanf(szCRC32, "%x", &uiCRC32) != 1) - error("Invalid Checksum: %s", szCRC32); - SET_CRC32(pMtdPartLastToUpdate, uiCRC32); - iPartListIndex++; - } - - iPartListIndex++; - pMtdPartLastToUpdate++; - } /* while( iPartListIndex ) */ - - /* all command line parsing verifications complete */ - - /* report what will be done */ - if (cNoImageTypeCheck || cDryRun || cWriteCleanMarker || cEraseAll) { - PRINTF("\nEnabled command line options:\n"); - if (cNoImageTypeCheck) - PRINTF(INFO "do not check image type\n"); - if (cDryRun) - PRINTF(INFO "dry-run: flash content is not changed\n"); - if (cWriteCleanMarker) - PRINTF(INFO "write JFFS2 clean markers\n"); - if (cEraseAll) - PRINTF(INFO "erase complete partition\n"); - PRINTF("\n"); - } - - if (cChecksumOnly) - DoPrintChecksums(); - else if (cVerifyOnly) - DoMtdVerify(); - else - DoMtdUpdate(); - - PRINTF("Done\n"); - - if (cDoReboot) { - sync(); - reboot(RB_AUTOBOOT); - } - - /* may not be reached in case of kill */ - return EXIT_SUCCESS; -} - -/*********************************************************************** - * !Function: DoPrintChecksums - * !Descr: Calculates CRC32 of files (and compares them to -c option) - ***********************************************************************/ -static void DoPrintChecksums(void) -{ - mtdPartition_t *pMtd = NULL; - - PRINTF("CRC32 Results:\n"); - - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) { - uint32_t uiCRC32 = 0; - - uiCRC32 = CalcCRC32OfFile(pMtd->szImageFileName); - PRINTF(" %-20s : 0x%08x\n", pMtd->szImageFileName, uiCRC32); - - if (pMtd->cChecksumSet) - MtdPartCompareCRC32(pMtd, uiCRC32); - } -} - -/*********************************************************************** - * !Function: DoMtdUpdate - * !Descr: Updates all flash partitions - ***********************************************************************/ -static void DoMtdUpdate(void) -{ - mtdPartition_t *pMtd = NULL; - - if (NULL != szTmpDir) { - /* checksum is checked or calculated while copying to tmp */ - VerifyTmpDir(); - - /* copy all files to tmp before starting to update */ - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) { - /* copy it to temp */ - char acTmpFileName[256]; - char *szFileName = strdup(pMtd->szImageFileName); - snprintf(acTmpFileName, sizeof(acTmpFileName) - 1, - "%s/%s", szTmpDir, basename(szFileName)); - acTmpFileName[sizeof(acTmpFileName) - 1] = 0; - FREE(szFileName); - - PRINTF("Copying %s to %s\n", pMtd->szImageFileName, szTmpDir); - MtdPartCopyFile(pMtd, acTmpFileName); - - /* use temporary file name from name */ - FREE(pMtd->szImageFileName); /* get rid of const* */ - pMtd->szImageFileName = strdup(acTmpFileName); - } - } else if (cHasChecksum || !cNoImageTypeCheck) { - /* verify checksum before starting to update */ - PRINTF("Verifying File(s): "); - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) { - PRINTF(" %s\n", pMtd->szImageFileName); - MtdPartVerifyFile(pMtd); - } - } - - /* make it read-only so no one can destroy the data */ - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) - MtdPartRemountAllReadOnly(pMtd); - - PRINTF("Updating:\n"); - - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) { - PRINTF(" %s (%lli KiB)\n", pMtd->szImageFileName, TO_KiB(pMtd->iFileSize)); - - MtdPartOpen(pMtd, 0); - /* For UBI images 'ubiformat' takes care of erasing the partition */ - if (pMtd->eFileType != FTUBI) { - MtdPartErase(pMtd); - } - if (PTBootstream == pMtd->ePartType) { - char cmd[1024]; - - /* Bootstream partitions must be updated by Freescale kobs-ng application */ - /* Close open mtd device */ - MtdPartClose(pMtd); - /* Build command to call kobs-ng - * Use 'strcat' because -O2 compiler optimization - * creates problems with 'sprintf' */ - strcpy(cmd, "kobs-ng init -w"); - if (cVerify) - strcat(cmd, " -c"); - if (NULL != szKey) { - strcat(cmd, " -k"); - strcat(cmd, szKey); - } - strcat(cmd, " --chip_0_device_path="); - strcat(cmd, pMtd->acName); - strcat(cmd, " "); - strcat(cmd, pMtd->szImageFileName); - strcat(cmd, " > /dev/null"); - if (!system(cmd)) { - PRINTF("\r Flashing: complete \n"); - if (cVerify) { - PRINTF("\r Verifying: complete \n"); - } - } - else { - PRINTF("\r Flashing: FAILED! \n"); - exit(EXIT_FAILURE); - } - } else if (pMtd->eFileType == FTUBI) { - /* UBI images are flashed using 'ubiformat' command */ - MtdPartClose(pMtd); - mtd_part_write_ubi(pMtd); - } else { - MtdPartWrite(pMtd); - if (cVerify) { - if (!MtdPartVerify(pMtd)) - exit(EXIT_FAILURE); - /* if CRC32 is given, it has been already checked on - the input files. And Mtd is now same to them. So no - need to check CRC32 again. */ - } else if (cHasChecksum) - MtdPartCheckCRC32(pMtd); - MtdPartClose(pMtd); - } - - PRINTF(" CRC32: 0x%08x\n", pMtd->uiCRC32); - } - - if (NULL != szTmpDir) { - /* delete all temporary files */ - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) - if (unlink(pMtd->szImageFileName)) { - /* - * Do not exit with error in case the file to remove does not - * exist. - * Try to address corner cases like CCORE_MX53_EXTENSIONS-170 - * (using same file to flash several different partitions) - */ - if (ENOENT == errno) { - systemLog("%s", pMtd->szImageFileName); - } else { - systemError("%s", pMtd->szImageFileName); - } - } - } -} - -/*********************************************************************** - * !Function: DoMtdVerify - * !Descr: Verifies the flash images - ***********************************************************************/ -static void DoMtdVerify(void) -{ - mtdPartition_t *pMtd = NULL; - - PRINTF("Verifying Images:\n"); - - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) { - MtdPartOpen(pMtd, 1); - MtdPartVerify(pMtd); - MtdPartClose(pMtd); - } -} - -/*********************************************************************** - * !Function: OnExit - * !Descr: Closes all open mtd partitions - ***********************************************************************/ -static void OnExit(void) -{ - mtdPartition_t *pMtd; - - for (pMtd = axMtdParts; pMtd < pMtdPartLastToUpdate; pMtd++) { - if (-1 != pMtd->iFd) - MtdPartClose(pMtd); - - FREE(pMtd->szImageFileName); - } -} - -/*********************************************************************** - * !Function: MtdInit - * !Descr: Checks where the partitions (devfs or not) and how many we have - ***********************************************************************/ -static void MtdInit(void) -{ - struct stat xStat; - - CLEAR(xStat); - - /* determine whether we are /dev/mtd/ or /dev/mtd */ - if (-1 == stat(szMtdPrefix, &xStat)) { - /* not dev fs */ - if (-1 == stat("/dev/mtd0", &xStat)) - error("No MTD devices available"); - - szMtdPrefix = "/dev/mtd"; - szMtdBlockPrefix = "/dev/mtdblock"; - } - - /* determine number of partitions */ - while (uiMtdPartsCount < ARRAY_SIZE(axMtdParts)) { - char acName[64]; - - axMtdParts[uiMtdPartsCount].iFd = -1; /* not open yet */ - - sprintf(acName, "%s%u", szMtdPrefix, uiMtdPartsCount); - if (-1 == stat(acName, &xStat)) - break; - - uiMtdPartsCount++; - } - - if (!uiMtdPartsCount) - error("No MTD partitions found"); -} - -/*********************************************************************** - * !Function: MtdPartInit - * !Descr: opens partition and initializes all sizes and bad blocks - ***********************************************************************/ -static void MtdPartInit( /*@out@ */ mtdPartition_t * pMtd, unsigned int uiPartition, - const char *szImageFileName) -{ - CLEAR(*pMtd); - pMtd->iFd = -1; - pMtd->uiPartition = uiPartition; - - /* open mtd (may be /dev/mtd0 or /dev/mtd/0) */ - MtdPartOpen(pMtd, 0); - - /* read partition info */ - if (ioctl(pMtd->iFd, MEMGETINFO, &pMtd->xInfo)) - systemError("ioctl( MEMGETINFO )"); - - pMtd->iSize = pMtd->xInfo.size; - pMtd->cIsNAND = (MTD_NANDFLASH == pMtd->xInfo.type); - pMtd->uiBadBlocks = 0; - pMtd->cEraseAll = cEraseAll; - pMtd->cWriteCleanMarker = cWriteCleanMarker; - - if (pMtd->cIsNAND) { - /* determine bad block count */ - /* !TODO. in 2.6.18 there already exists - mtd_ecc_stats/ECCGETLAYOUT */ - loff_t iOffset = 0; - - while (iOffset < pMtd->xInfo.size) { - if (MtdPartIsBadBlock(pMtd, iOffset)) { - logMsg(LOG_HARDWARE1, - "Bad Block 0x%08llx on partition %u", - iOffset, pMtd->uiPartition); - pMtd->uiBadBlocks++; - } - iOffset += pMtd->xInfo.erasesize; - } - } - - pMtd->iPageSize = (pMtd->cIsNAND ? pMtd->xInfo.writesize : pMtd->xInfo.erasesize); - - MtdPartDeterminePartType(pMtd); - - PRINTF("Partition %u is %s (%s)\n", pMtd->uiPartition, - (pMtd->cIsNAND ? "NAND" : ((MTD_NORFLASH == pMtd->xInfo.type) ? "NOR" : "???")), - (pMtd->ePartType != PTUnknown) ? aszPartType[pMtd->ePartType] : ""); - PRINTF(" Full Size: %llu KiB\n", TO_KiB(pMtd->iSize)); - - if (pMtd->uiBadBlocks) { - /* determine effective (good) size */ - PRINTF(" %u bad blocks\n", pMtd->uiBadBlocks); - pMtd->iSize -= pMtd->xInfo.erasesize * pMtd->uiBadBlocks; - } - - PRINTF(" Good Size: %llu KiB\n", TO_KiB(pMtd->iSize)); - - if (!is_nand_oob_atomic()) - MtdPartInitCleanMarker(pMtd, &pMtd->xCleanMarker, &pMtd->uiClMPos, &pMtd->uiClMLen); - - MtdPartUseFile(pMtd, szImageFileName); - - /* close it to not leave an unused file descriptor open too long. - The partition info is not gonna change anyway. */ - MtdPartClose(pMtd); - - if (!cVerifyOnly && pMtd->cIsJFFS2) { - PRINTF(INFO "JFFS2 partition %u will be fully erased", - pMtd->uiPartition); - /* clean rootfs completely */ - pMtd->cEraseAll = 1; - if (!is_nand_oob_atomic()) { - pMtd->cWriteCleanMarker = 1; - PRINTF(" and clean markers written\n"); - } else { - PRINTF("\n"); - } - } -} - -/*********************************************************************** - * !Function: MtdPartOpen - * !Descr: Opens the partition, either read only or read-writable - ***********************************************************************/ -static void MtdPartOpen( /*@inout@ */ mtdPartition_t * pMtd, char cReadOnly) -{ - char cReallyReadOnly = cReadOnly || cVerifyOnly; - if (-1 != pMtd->iFd) - error("Partition %u already open", pMtd->uiPartition); - - sprintf(pMtd->acName, "%s%u", szMtdPrefix, pMtd->uiPartition); - pMtd->iFd = open(pMtd->acName, (cReallyReadOnly ? O_RDONLY : OPEN_READWRITE_IF_NOT_DRY)); - if (-1 == pMtd->iFd) - systemError(": %s", pMtd->acName); -} - -/*********************************************************************** - * !Function: MtdPartClose - * !Descr: closes the Mtd Partition - ***********************************************************************/ -static void MtdPartClose( /*@inout@ */ mtdPartition_t * pMtd) -{ - CLOSE(pMtd->iFd); -} - -/*********************************************************************** - * !Function: MtdPartIsBadBlock - * !Return: 1 if the block at iOffset is bad and mustn't be used - * !TODO: on first run, all bad blocks can be stored in a "bad" list and - * reused later to reduce kernel calls - ***********************************************************************/ -static int MtdPartIsBadBlock(const mtdPartition_t * pMtd, loff_t iOffset) -{ - char cIsBad = 0; - int iRes = ioctl(pMtd->iFd, MEMGETBADBLOCK, &iOffset); - - if (iRes > 0) - cIsBad = 1; - else if ((iRes < 0) && (ENOTSUP != errno)) - /* if not supported (NOR), assume it is good */ - systemError("ioctl( MEMGETBADBLOCK )"); - - return cIsBad; -} - -/*********************************************************************** - * !Function: MtdMarkBadBlock - * !Return: 0 on success, <1 on error - ***********************************************************************/ -static int MtdMarkBadBlock(const mtdPartition_t * pMtd, loff_t iOffset) -{ - PRINTF("Marking offset %d as bad\n",(int)iOffset); - return ( ioctl(pMtd->iFd, MEMSETBADBLOCK, &iOffset) ); -} - -/*********************************************************************** - * !Function: MtdPartUseFile - * !Descr: Checks whether szImageFileName can be used for updating. - * E.g. if !cNoImageTypeCheck is set, the prefixes of the image - * file names are checked. - ***********************************************************************/ -static void MtdPartUseFile( /*@inout@ */ mtdPartition_t * pMtd, const char *szImageFileName) -{ - struct stat xStat; - - CLEAR(xStat); - if (stat(szImageFileName, &xStat)) - systemError("%s", szImageFileName); - - pMtdPartLastToUpdate->szOrigImageFileName = szImageFileName; - pMtd->szImageFileName = strdup(szImageFileName); - pMtd->iFileSize = xStat.st_size; - pMtd->eFileType = FTUnknown; - - if (-1 != pMtd->iFd) { - if (xStat.st_size > pMtd->iSize) - error("File %s is %lu KiB, but partition %u has only %lu KiB good free", - pMtd->szImageFileName, - TO_KiB(xStat.st_size), pMtd->uiPartition, TO_KiB(pMtd->iSize)); - - if (!cNoImageTypeCheck) - MtdPartDetermineAndCheckFileType(pMtd); - } -} - -/*********************************************************************** - * !Function: MtdPartErase - * !Descr: erases the flash partition. - * !see [1] - ***********************************************************************/ -static void MtdPartErase(const mtdPartition_t * pMtd) -{ - erase_info_t xErase; - loff_t iEraseSize = 0; - loff_t iBytesErasedTotal = 0; - char cLastWasBad = 0; - struct mtd_oob_buf xoob; - int iThrottle = MtdPartGetThrottle(pMtd, pMtd->xInfo.erasesize); - - CLEAR(xErase); - - xErase.length = pMtd->xInfo.erasesize; - /* bad sectors have already been removed in pMtd->iSize */ - iEraseSize = (pMtd->cEraseAll ? pMtd->iSize : pMtd->iFileSize); - - CLEAR(xoob); - xoob.length = pMtd->uiClMLen; - xoob.ptr = (unsigned char *)&pMtd->xCleanMarker; - - while (iBytesErasedTotal < iEraseSize) { - if (!MtdPartIsBadBlock(pMtd, xErase.start)) { - PrintProgress((((iBytesErasedTotal) * 100) / iEraseSize), - iThrottle, - " Erasing%s %i KiB @ 0x%08x:", - (pMtd->cWriteCleanMarker ? " (CM)" : ""), - TO_KiB(xErase.length), xErase.start); - - if (!cDryRun && ioctl(pMtd->iFd, MEMERASE, &xErase)) - systemError("ioctl(MEMERASE)"); - - iBytesErasedTotal += xErase.length; - cLastWasBad = 0; - - if (!cDryRun && pMtd->cWriteCleanMarker) { - /* write cleanmarker */ - if (pMtd->cIsNAND) { - xoob.start = xErase.start + pMtd->uiClMPos; - if (ioctl(pMtd->iFd, MEMWRITEOOB, &xoob)) - systemError("ioctl( MEMWRITEOOB )"); - } else { - /* the NOR image already contains them. */ - if (pwrite(pMtd->iFd, &pMtd->xCleanMarker, - sizeof(pMtd->xCleanMarker), - xErase.start) != sizeof(pMtd->xCleanMarker)) - systemError("pwrite"); - } - } - } else { - logMsg(LOG_HARDWARE1, - "%s" WARNING "Skipping bad sector @ 0x%08x ", - (!cLastWasBad ? "\r" : ""), xErase.start); - cLastWasBad = 1; - } - - xErase.start += xErase.length; - } - - PRINTF("\r Erasing: complete \n"); -} - -/*********************************************************************** - * !Function: mtd_part_write_ubi - * !Descr: writes an UBI image file to partition - ***********************************************************************/ -static void mtd_part_write_ubi(mtdPartition_t * pMtd) -{ - char line[256]; - FILE *fpin; - int ret; - - snprintf(line, sizeof(line), "ubiformat %s -f %s -y -q 2>&1 >/dev/null", pMtd->acName, - pMtd->szImageFileName); - fpin = popen(line, "r"); - if (fgets(line, sizeof(line) - 1, fpin) != NULL) { - line[strlen(line) - 1] = 0; - } - ret = pclose(fpin); - if (!WEXITSTATUS(ret)) { - PRINTF("\r Flashing: complete \n"); - } else { - PRINTF("\r Flashing: FAILED! (%s)\n", line); - exit(EXIT_FAILURE); - } -} - -/*********************************************************************** - * !Function: MtdPartWrite - * !Descr: writes the image file to partition - ***********************************************************************/ -static void MtdPartWrite(mtdPartition_t * pMtd) -{ - loff_t iBytesReadTotal = 0; - loff_t iCurrentOffs = 0; - int iFdSrc = -1; - char cLastWasBad = 0; - int iBytesRead = 0; - uint32_t uiCRC32 = 0; - unsigned char *pucBuffer = NULL; - const size_t iBlockSize = pMtd->iPageSize; - int iThrottle = MtdPartGetThrottle(pMtd, pMtd->iFileSize); - unsigned int i,iRet; - unsigned int ref_uicrc32 = 0,new_uicrc32 = 0; - unsigned char *pucBufferMtd = NULL; - - pucBuffer = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBuffer) - systemError("malloc"); - - iFdSrc = open(pMtd->szImageFileName, O_RDONLY); - if (-1 == iFdSrc) - systemError("%s", pMtd->szImageFileName); - - /* rewind because descriptor was open and we don't know the state */ - if (lseek(pMtd->iFd, 0, SEEK_SET)) - systemError("%s", pMtd->acName); - - do { - /* write one sector */ - if (!MtdPartIsBadBlock(pMtd, iCurrentOffs)) { - int iBytesWritten; - - PrintProgress(PERCENTAGE(iBytesReadTotal, pMtd->iFileSize), - iThrottle, " Flashing:"); - - iBytesRead = read(iFdSrc, pucBuffer, iBlockSize); - if (!iBytesRead) - break; - else if (-1 == iBytesRead) - systemError("%s", pMtd->szImageFileName); - - if (!pMtd->cChecksumCalculated) - uiCRC32 = crc32(uiCRC32, pucBuffer, iBytesRead); - - if (iBytesRead < iBlockSize) { - char cEmptyChar = FLASH_ERASED_BYTE; - char bJFFS2Padding = 0; - - if (pMtd->cIsJFFS2 && - (iBytesRead + sizeof(struct jffs2_unknown_node) < - iBlockSize)) { - bJFFS2Padding = 1; - cEmptyChar = 0; /* see wbuf.c */ - } - - /* fill block with empty characters */ - memset(pucBuffer + iBytesRead, - cEmptyChar, iBlockSize - iBytesRead); - - if (bJFFS2Padding) { - /* write padding to avoid Empty block messages. - see linux/fs/jffs2/wbuf.c:flush_wbuf */ - struct jffs2_unknown_node *pNode = - (struct jffs2_unknown_node *)(pucBuffer + - iBytesRead); - logMsg(LOG_HARDWARE1, "\nPadding last sector"); - MtdPartInitJFFS2Node(pNode, - JFFS2_NODETYPE_PADDING, - iBlockSize - iBytesRead); - } - } - - /* at least nand writes should be aligned */ - - if( !cDryRun && cMarkBadBlocks ) { - ref_uicrc32 = crc32(0, pucBuffer, iBlockSize); - pucBufferMtd = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBufferMtd) - systemError("malloc"); - } - - for( i = 0 ; i < cMaxRetries ; i++ ) { - int iBytesReadMtd; - - iBytesWritten = (!cDryRun ? - pwrite(pMtd->iFd, - pucBuffer, iBlockSize, - iCurrentOffs) : iBlockSize); - - if (iBytesWritten != iBlockSize) { - if( !cDryRun && cMarkBadBlocks ) { - PRINTF("[%s:%d] %s: Retrying failed write %d.\n", - __FUNCTION__,__LINE__,pMtd->acName,i); - continue; - } - else { - systemError("%s", pMtd->acName); - } - } - - if (!cDryRun && cMarkBadBlocks) { - iBytesReadMtd = pread(pMtd->iFd, pucBufferMtd, iBlockSize, - iCurrentOffs); - if ( iBytesReadMtd < 0 ) { - PRINTF("[%s:%d] %s: Read error.\n", - __FUNCTION__,__LINE__,pMtd->acName); - continue; - } - - new_uicrc32 = crc32(0, pucBufferMtd, iBlockSize); - if( new_uicrc32 != ref_uicrc32 ) { - PRINTF("[%s:%d] %s: CRC mismatch %08x <> %08x.\n", - __FUNCTION__,__LINE__,pMtd->acName,ref_uicrc32, - new_uicrc32); - continue; - } - FREE(pucBufferMtd); - } - break; - } - - if( !cDryRun && cMarkBadBlocks && (i >= cMaxRetries) ) { - PRINTF("[%s:%d] %s: Marking as bad block.\n", - __FUNCTION__,__LINE__,pMtd->acName); - iRet = MtdMarkBadBlock( pMtd , iCurrentOffs ); - systemError("%s: Bad block marking %s.", pMtd->acName, - strerror(iRet)); - } - - iBytesReadTotal += iBytesRead; - - cLastWasBad = 0; - } else { - logMsg(LOG_HARDWARE1, - "%s" WARNING "Skipping bad sector @ 0x%08x ", - (!cLastWasBad ? "\r" : ""), iCurrentOffs); - - cLastWasBad = 1; - } - - iCurrentOffs += iBlockSize; - } while (iCurrentOffs < pMtd->xInfo.size); - - CLOSE(iFdSrc); - FREE(pucBuffer); - - if (pMtd->iFileSize != iBytesReadTotal) - error("Filesize changed while updating: %s", pMtd->szImageFileName); - - if (!pMtd->cChecksumCalculated) { - SET_CRC32(pMtd, uiCRC32); - pMtd->cChecksumCalculated = 1; - } - - PRINTF("\r Flashing: complete \n"); -} - -/*********************************************************************** - * !Function: MtdPartVerify - * !Return: 1 if identical in the used sectors of szOrigImageFileName - * otherwise 0 - * !Descr: compares contents of MtdPartition with szOrigImageFileName - * Only checks the last used sector whether the parts the source - * file not uses are empty. Other blocks are not checked. - ***********************************************************************/ -static int MtdPartVerify(mtdPartition_t * pMtd) -{ - unsigned char *pucBufferSrc; - unsigned char *pucBufferMtd; - int iFdSrc = -1; - loff_t iBytesReadTotal = 0; - loff_t iOffsMtd = 0; - char cRes = 0; - char cLastWasBad = 0; - const size_t iBlockSize = pMtd->iPageSize; - int iThrottle = MtdPartGetThrottle(pMtd, pMtd->iFileSize); - unsigned int i,iRet; - - pucBufferSrc = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBufferSrc) - systemError("malloc"); - - pucBufferMtd = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBufferMtd) - systemError("malloc"); - - /* sync everything */ - MtdPartClose(pMtd); - MtdPartOpen(pMtd, 1); /* also rewinds read pointer */ - - iFdSrc = open(pMtd->szOrigImageFileName, O_RDONLY); - if (-1 == iFdSrc) - systemError("%s", pMtd->szOrigImageFileName); - - do { - if (!MtdPartIsBadBlock(pMtd, iOffsMtd)) { - int iBytesReadSrc; - int iBytesReadMtd; - loff_t iOffs; - - PrintProgress(PERCENTAGE(iBytesReadTotal, pMtd->iFileSize), - iThrottle, " Verifying:"); - - iBytesReadSrc = read(iFdSrc, pucBufferSrc, iBlockSize); - if (!iBytesReadSrc) - /* nothing left */ - break; - else if (iBytesReadSrc < 0) - systemError("%s", pMtd->szOrigImageFileName); - - for( i = 0 ; i < cMaxRetries ; i++ ) { - iBytesReadMtd = pread(pMtd->iFd, pucBufferMtd, iBlockSize, iOffsMtd); - if (iBytesReadMtd < 0) { - if( !cDryRun && cMarkBadBlocks ) { - printf("[%s:%d] %s: Retrying failed read %d, %s.\n", - __FUNCTION__,__LINE__,pMtd->acName,i,strerror(errno)); - continue; - } - else - systemError("%s", pMtd->acName); - } - break; - } - - if( !cDryRun && cMarkBadBlocks && (i >= cMaxRetries) ) { - PRINTF("[%s:%d] %s: Marking as bad block.\n", - __FUNCTION__,__LINE__,pMtd->acName); - iRet = MtdMarkBadBlock( pMtd , iOffsMtd ); - systemError("%s: Bad block marking %s.", pMtd->acName, strerror(iRet)); - } - - if (iBytesReadSrc > iBytesReadMtd) { - logMsg(LOG_ERR, - "\nSize mismatch. Source has %i Bytes but flash only %i bytes", - iBytesReadSrc, iBytesReadMtd); - goto ret; - } - - iOffs = MemCmp(pucBufferSrc, pucBufferMtd, iBytesReadSrc); - if (-1 != iOffs) { - logMsg(LOG_ERR, - "\nData mismatch @ 0x%08x\n", iBytesReadTotal + iOffs); - logMsg(LOG_ERR, "Source is"); - MemDump(pucBufferSrc, iOffs & ~0xf, MIN(iBytesReadSrc, 0x20)); - logMsg(LOG_ERR, "Flash is"); - MemDump(pucBufferMtd, iOffs & ~0xf, MIN(iBytesReadMtd, 0x20)); - goto ret; - } - - if (!pMtd->cIsJFFS2 && (iBytesReadSrc < iBytesReadMtd)) { - /* !TODO. JFFS2 is padded. - This is not yet checked. */ - int i; - - /* check for emptiness of block. */ - /* !TODO. This works only for NOR and NAND */ - for (i = iBytesReadSrc; i < iBytesReadMtd; i++) - if (FLASH_ERASED_BYTE != pucBufferMtd[i]) { - logMsg(LOG_ERR, - "Mtd is not empty @ 0x%llx\n", - iBytesReadTotal + i); - goto ret; - } - } /* if( iBytesReadSrc < iBytesReadMtd */ - iBytesReadTotal += iBytesReadSrc; - - cLastWasBad = 0; - } else { - logMsg(LOG_HARDWARE1, - "%s" WARNING "Skipping bad sector @ 0x%08x ", - (!cLastWasBad ? "\r" : ""), iOffsMtd); - cLastWasBad = 1; - } - - iOffsMtd += iBlockSize; - } while (iOffsMtd < pMtd->xInfo.size); - - if (pMtd->iFileSize != iBytesReadTotal) { - logMsg(LOG_ERR, "Filesize changed while updating: %s", pMtd->szImageFileName); - goto ret; - } - - PRINTF("\r Verifying: complete \n"); - - cRes = 1; - -ret: - CLOSE(iFdSrc); - - FREE(pucBufferMtd); - FREE(pucBufferSrc); - - return cRes; -} - -/*********************************************************************** - * !Function: MtdPartCheckCRC32 - * !Descr: calculates checksum of mtd partition up to filesize - ***********************************************************************/ -static void MtdPartCheckCRC32(mtdPartition_t * pMtd) -{ - unsigned char *pucBufferMtd; - loff_t iBytesReadTotal = 0; - loff_t iOffsMtd = 0; - uint32_t uiCRC32 = 0; - const size_t iBlockSize = pMtd->xInfo.erasesize; - int iThrottle = MtdPartGetThrottle(pMtd, pMtd->iFileSize); - - pucBufferMtd = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBufferMtd) - systemError("malloc"); - - /* sync everything */ - MtdPartClose(pMtd); - MtdPartOpen(pMtd, 1); /* also rewinds read pointer */ - - do { - if (!MtdPartIsBadBlock(pMtd, iOffsMtd)) { - int iBytesReadMtd; - - PrintProgress(PERCENTAGE(iBytesReadTotal, pMtd->iFileSize), - iThrottle, " CRC32: "); - - iBytesReadMtd = pread(pMtd->iFd, pucBufferMtd, iBlockSize, iOffsMtd); - if (iBytesReadMtd < 0) - systemError("%s", pMtd->acName); - - if ((iBytesReadTotal + iBytesReadMtd) > pMtd->iFileSize) - iBytesReadMtd = (pMtd->iFileSize - iBytesReadTotal); - - uiCRC32 = crc32(uiCRC32, pucBufferMtd, iBytesReadMtd); - iBytesReadTotal += iBytesReadMtd; - } - iOffsMtd += iBlockSize; - } while (pMtd->iFileSize > iBytesReadTotal); - - PRINTF("\r CRC32: complete \n"); - - FREE(pucBufferMtd); - - MtdPartCompareCRC32(pMtd, uiCRC32); -} - -/*********************************************************************** - * !Function: MtdPartCopyFile - * !Descr: copies the image file to szDstFileName and calculates its - * check sum - ***********************************************************************/ -static void MtdPartCopyFile(mtdPartition_t * pMtd, const char *szDstFileName) -{ - unsigned char *pucBuffer = NULL; - int iFdDst = -1; - int iFdSrc = -1; - loff_t iBytesReadTotal = 0; - int iBytesRead; - uint32_t uiCRC32 = 0; - const size_t iBlockSize = pMtd->xInfo.erasesize; - - pucBuffer = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBuffer) - systemError("malloc"); - - iFdSrc = open(pMtd->szImageFileName, O_RDONLY); - if (-1 == iFdSrc) - systemError("%s", pMtd->szImageFileName); - - iFdDst = open(szDstFileName, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (-1 == iFdDst) - systemError("%s", szDstFileName); - - do { - int iBytesWritten; - - iBytesRead = read(iFdSrc, pucBuffer, iBlockSize); - if (!iBytesRead) - break; - else if (-1 == iBytesRead) - systemError("%s", pMtd->szImageFileName); - - if (pMtd->cIsJFFS2) - MtdPartVerifyJFFS2Block(pMtd, pucBuffer, iBytesRead); - - uiCRC32 = crc32(uiCRC32, pucBuffer, iBytesRead); - - iBytesWritten = write(iFdDst, pucBuffer, iBytesRead); - if (iBytesWritten != iBytesRead) - systemError("%s", szDstFileName); - - iBytesReadTotal += iBytesRead; - } while (1); - - CLOSE(iFdDst); - CLOSE(iFdSrc); - - FREE(pucBuffer); - - if (pMtd->iFileSize != iBytesReadTotal) - error("Filesize changed while updating: %s", pMtd->szImageFileName); - - if (!pMtd->cChecksumSet) { - SET_CRC32(pMtd, uiCRC32); - pMtd->cChecksumCalculated = 1; - } else - MtdPartCompareCRC32(pMtd, uiCRC32); -} - -/*********************************************************************** - * !Function: MtdPartInitCleanMarker - * !Descr: initializes the clean marker - * !see [1] - ***********************************************************************/ -static void MtdPartInitCleanMarker(const mtdPartition_t * pMtd, - struct jffs2_unknown_node *pCleanMarker, - unsigned int *puiClMPos, unsigned int *puiClMLen) -{ - *puiClMPos = 0; - *puiClMLen = 8; - - if (pMtd->cIsNAND) { - struct nand_oobinfo xoobInfo; - - CLEAR(xoobInfo); - if (ioctl(pMtd->iFd, MEMGETOOBSEL, &xoobInfo)) - systemError("ioctl( MEMGETOOBSEL )"); - - /* check for autoplacement */ - if (MTD_NANDECC_AUTOPLACE == xoobInfo.useecc) { - /* get the position of the free bytes */ - if (!xoobInfo.oobfree[0][1]) - error("Autoplacement selected and no empty space in oob\n"); - - *puiClMPos = xoobInfo.oobfree[0][0]; - *puiClMLen = xoobInfo.oobfree[0][1]; - - if (*puiClMLen > 8) - *puiClMLen = 8; - else { - /* legacy mode, detect autoplacement ourselves [3] */ - switch (pMtd->xInfo.oobsize) { - case 8: - *puiClMPos = 6; - *puiClMLen = 2; - break; - case 16: - *puiClMPos = 8; - *puiClMLen = 8; - break; - case 64: - *puiClMPos = 16; - *puiClMLen = 8; - break; - default: - error("unsupported oobsize %i\n", pMtd->xInfo.oobsize); - break; - } /* switch */ - } /* if( *piClMPos ) */ - } /* if( NAND_AUTOPLACE */ - } else - MtdPartInitJFFS2Node(pCleanMarker, - JFFS2_NODETYPE_CLEANMARKER, - sizeof(struct jffs2_unknown_node)); - - logMsg(LOG_HARDWARE2, - " OOB has %i bytes, CleanMarker is from 0x%02x to 0x%02x", - pMtd->xInfo.oobsize, *puiClMPos, *puiClMPos + *puiClMLen); -} - -/*********************************************************************** - * !Function: MtdPartInitJFFS2Node - * !Descr: initializes a node and generates hdr checksum - ***********************************************************************/ -static void MtdPartInitJFFS2Node(struct jffs2_unknown_node *pNode, unsigned short uhNodeType, - size_t iLen) -{ - uint32_t uiStart = 0xffffffff; /* JFFS CRC32 starts from 0xfffffff, our crc32 from 0x0 */ - - CLEAR(*pNode); - - pNode->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); - pNode->nodetype = cpu_to_je16(uhNodeType); - - pNode->totlen = cpu_to_je32(iLen); - /* don't CRC32 the hdr_crc itself */ - pNode->hdr_crc = - cpu_to_je32(crc32(uiStart, pNode, sizeof(struct jffs2_unknown_node) - 4) ^ uiStart); -} - -/*********************************************************************** - * !Function: MtdPartCompareCRC32 - * !Descr: checks whether the CRC32 is same as previously calculated. - ***********************************************************************/ -static void MtdPartCompareCRC32(mtdPartition_t * pMtd, uint32_t uiCRC32) -{ - if (uiCRC32 != pMtd->uiCRC32) - error("CRC32 mismatch on %s.\n Expected 0x%08x, have 0x%08x\n", - pMtd->szImageFileName, pMtd->uiCRC32, uiCRC32); -} - -/*********************************************************************** - * !Function: MtdPartRemountAllReadOnly - * !Descr: remounts all uses of the partition as read-only - ***********************************************************************/ -static void MtdPartRemountAllReadOnly(mtdPartition_t * pMtd) -{ - static const char *szMount = "/proc/mounts"; - char acMtdBlock[20]; - FILE *fhMount = NULL; - const char *szRootDev = GetRootDevice(); - - if (pMtd->cAlreadyRemounted) - /* nothing to do */ - return; - - fhMount = setmntent(szMount, "r"); - if (NULL == fhMount) - systemError(szMount); - - sprintf(acMtdBlock, "%s%u", szMtdBlockPrefix, pMtd->uiPartition); - - /* scan all mount entries */ - do { - char bIsRootDev = 0; - char bRemount = 0; - - struct mntent *pxEnt = getmntent(fhMount); - if (NULL == pxEnt) - break; - - bIsRootDev = (!strcmp(pxEnt->mnt_fsname, "/dev/root") && - !strcmp(szRootDev, acMtdBlock)); - if (!bIsRootDev && !strcmp(pxEnt->mnt_fsname, acMtdBlock)) { - PRINTF(WARNING "Umounting %s\n", pxEnt->mnt_dir); - if (umount(pxEnt->mnt_dir) || bIsRootDev) { - /* rootdev can't be unmounted */ - /* it's for our mtd partition, remount it */ - PRINTF(WARNING "Failed, trying to remount read-only\n"); - bRemount = 1; - } - } - if (bIsRootDev || bRemount) { - PRINTF(WARNING "Remounting %s\n", pxEnt->mnt_dir); - if (mount(pxEnt->mnt_fsname, pxEnt->mnt_dir, - NULL, MS_REMOUNT | MS_RDONLY, NULL)) { - if (EBUSY == errno) - error("Partition in use, can't update it\n"); - else - systemError("%s", pxEnt->mnt_fsname); - } - } - } while (1); - - endmntent(fhMount); - - pMtd->cAlreadyRemounted = 1; -} - -/*********************************************************************** - * !Function: MtdPartDeterminePartType - * !Descr: Determine partition type (rootfs, uboot, etc.) based on - * partition name in /proc/mtd - ***********************************************************************/ -static void MtdPartDeterminePartType(mtdPartition_t * pMtd) -{ - static const char *szMtd = "/proc/mtd"; - FILE *fhMtd = NULL; - unsigned int uiPart; - char acBuffer[200]; - int iPart; - loff_t uiSize; - loff_t uiEraseSize; - char acName[200]; - static const struct { - PartType_e eType; - FileType_e eFileType; - const char *szName; - } axTypes[] = { - {PTUBoot, FTUBoot, "\"U-Boot"}, - {PTKernel, FTKernel, "\"Kernel"}, - {PTEnvironment, FTNVRAM, "\"NVRAM"}, - {PTFPGA, FTFPGA, "\"FPGA"}, - {PTBootstream, FTBootstream, "\"Bstrm-U-Boot"}, - }; - int i; - - /* open /proc/mtd */ - fhMtd = fopen(szMtd, "r"); - if (NULL == fhMtd) - systemError(szMtd); - - /* skip table header (check return value to avoid compiler warning) */ - if (fgets(acBuffer, sizeof(acBuffer), fhMtd)); - - /* seek partition description */ - for (iPart = 0; iPart <= pMtd->uiPartition; iPart++) - if (NULL == fgets(acBuffer, sizeof(acBuffer) - 1, fhMtd)) - systemError(szMtd); - - /* break it into parts */ - acBuffer[sizeof(acBuffer) - 1] = 0; - if (sscanf(acBuffer, "mtd%u: %llx %llx %199s", - &uiPart, &uiSize, &uiEraseSize, acName) != 4) - error("Wrong /proc/mtd line: %s", acBuffer); - if (uiPart != pMtd->uiPartition) - error("Wrong partition: %s", acBuffer); - - /* determine partition type */ - pMtd->ePartType = PTUnknown; - pMtd->eFileTypeNeeded = FTUnknown; - for (i = 0; i < ARRAY_SIZE(axTypes); i++) { - if (!strncmp(axTypes[i].szName, acName, strlen(axTypes[i].szName))) { - pMtd->ePartType = axTypes[i].eType; - pMtd->eFileTypeNeeded = axTypes[i].eFileType; - break; - } - } - - if (fclose(fhMtd) < 0) - systemError(szMtd); -} - -/*********************************************************************** - * !Function: MtdPartDetermineAndCheckFileType - * !Descr: Determine file type (rootfs, uboot, etc.) and checks whether it - * is ok for the partition. Done by looking at filename - ***********************************************************************/ -static void MtdPartDetermineAndCheckFileType(mtdPartition_t * pMtd) -{ - FileType_e eType = 0; - int iMatch = 0; - regex_t regexp; - - CLEAR(regexp); - - /* !TODO: Verify File Type, JFFS2, uimage, u-boot by looking into it */ - - while (eType < ARRAY_SIZE(axFileType)) { - /* does axFileType[ eType ] matches pMtd->szImageFileName? */ - int iError = regcomp(®exp, - axFileType[eType].szExp, - REG_NOSUB); - if (iError) { - char acError[200]; - regerror(iError, ®exp, acError, sizeof(acError) - 1); - error("%s", acError); - } - - iMatch = !regexec(®exp, pMtd->szImageFileName, 0, NULL, 0); - regfree(®exp); - - if (iMatch) { - pMtd->eFileType = eType; - - logMsg(LOG_HARDWARE1, - " Detected Image Type for %s: %s", - pMtd->szImageFileName, axFileType[eType].szName); - - /* check whether it matches the partition */ - if ((pMtd->eFileTypeNeeded != pMtd->eFileType) && - (pMtd->eFileTypeNeeded != FTUnknown)) - error("File %s (Type %s) doesn't match partition type %s", - pMtd->szImageFileName, - axFileType[pMtd->eFileType].szName, - aszPartType[pMtd->ePartType]); - - if (FTJFFS2 == pMtd->eFileType) - pMtd->cIsJFFS2 = 1; - - break; - } - eType++; - } -} - -/*********************************************************************** - * !Function: MtdPartVerifyFile - * !Descr: verifies the file (checksum, JFFS2) - ***********************************************************************/ -static void MtdPartVerifyFile(mtdPartition_t * pMtd) -{ - unsigned char *pucBuffer = NULL; - uint32_t uiCRC32 = 0; - int iFd = -1; - int iBytesRead; - const size_t iBlockSize = pMtd->xInfo.erasesize; - - pucBuffer = (unsigned char *)malloc(iBlockSize); - if (NULL == pucBuffer) - systemError("malloc"); - - iFd = open(pMtd->szImageFileName, O_RDONLY); - if (-1 == iFd) - systemError("%s", pMtd->szImageFileName); - - do { - iBytesRead = read(iFd, pucBuffer, iBlockSize); - if (!iBytesRead) - break; - else if (-1 == iBytesRead) - systemError("%s", pMtd->szImageFileName); - - if (pMtd->cIsJFFS2) - MtdPartVerifyJFFS2Block(pMtd, pucBuffer, iBytesRead); - - uiCRC32 = crc32(uiCRC32, pucBuffer, iBytesRead); - } while (1); - - CLOSE(iFd); - - FREE(pucBuffer); - - if (!pMtd->cChecksumSet) { - SET_CRC32(pMtd, uiCRC32); - pMtd->cChecksumCalculated = 1; - } else - MtdPartCompareCRC32(pMtd, uiCRC32); -} - -/*********************************************************************** - * !Function: MtdPartVerifyJFFS2Block - * !Descr: verifies whether the JFFS2 block is correct. On NOR clean markers - * need to be on the correct position, on NAND there mustn't be. - ***********************************************************************/ -static void MtdPartVerifyJFFS2Block(mtdPartition_t * pMtd, unsigned char *pucData, size_t iSize) -{ - char cCleanMarkerPresent = 0; - int iOffs; - /* only magic and node, length field of xCleanMarker may vary */ - static const size_t NODE_SIZE = 4; - - if (pMtd->cAlreadyPrintedVerifyWarning) - /* do it only once */ - return; - - if (iSize >= 4) - cCleanMarkerPresent = (MemCmp(pucData, &pMtd->xCleanMarker, NODE_SIZE) == -1); - - if (pMtd->cIsNAND) { - const jint16_t MAGIC = cpu_to_je16(JFFS2_MAGIC_BITMASK); - - if (cCleanMarkerPresent) { - logMsg(LOG_ERR, - WARNING - "CleanMarkers present in image for NAND. JFFS2 will complain but function."); - pMtd->cAlreadyPrintedVerifyWarning = 1; - } - - /* MAGIC is < sizeof( xCleanMarker ) */ - if (MemCmp(pucData, &MAGIC, sizeof(MAGIC)) != -1) - error("No JFFS2 Header at erase block begin"); - } else { - /* NOR etc. */ - if (!cCleanMarkerPresent) - error - ("No CleanMarkers present in image for NOR. JFFS2 won't like that. Possibly wrong erase block size of jffs2 or NAND image"); - - /* there shouldn't be any other clean marker in the block. - Check 2^n offsets. */ - for (iOffs = 16; iOffs < iSize - NODE_SIZE; iOffs *= 2) { - if (MemCmp(pucData + iOffs, &pMtd->xCleanMarker, NODE_SIZE) == -1) - error - ("Clean Markers present in the block at offset 0x%08x. Possibly wrong erase block size of jffs2", - iOffs); - } - } -} - -/*********************************************************************** - * !Function: MtdPartGetThrottle - ***********************************************************************/ -static int MtdPartGetThrottle(const mtdPartition_t * pMtd, uint64_t ullSize) -{ - /* Eclipse has a nicer output with an update every second. Therefore it - * is not throttled. */ - return 1; -} - -/*********************************************************************** - * !Function: PrintProgress - * !Descr: Prints message only when progress has changed - ***********************************************************************/ -static void PrintProgress(int iPercentage, int iThrottle, const char *szFmt, ...) -{ - static int iLastPercentage = -1; - int iThrottled = iPercentage / iThrottle; - - if (cSilent) - /* nothing to print */ - return; - - if (iThrottled != iLastPercentage) { - va_list args; - - iLastPercentage = iThrottled; - - va_start(args, szFmt); - vprintf(szFmt, args); - printf("% 3i%% \r", iPercentage); - va_end(args); - - if (cProgressInNewLine) - PRINTF("\n"); - fflush(stdout); - } -} - -/*********************************************************************** - * !Function: VerifyTmpDir - * !Descr: checks whether the temporary directory can be used - ***********************************************************************/ -static void VerifyTmpDir(void) -{ - struct statfs xStat; - - CLEAR(xStat); - - if (statfs(szTmpDir, &xStat)) - systemError("statfs"); - - switch (xStat.f_type) { - case JFFS2_SUPER_MAGIC: - /* flash image temporary on flash fs??? */ - error("Makes no sense to store flash image temporarily on JFFS2"); - break; /* not reached */ - case NFS_SUPER_MAGIC: - error("Makes no sense to store flash image temporarily on NFS"); - break; /* not reached */ - default: - /* Accept all other ones. If they are read-only, it is detected before - * erasing flash */ - break; - } -} - -/*********************************************************************** - * !Function: CalcCRC32OfFile - * !Descr: calculates the CRC32 of the file. - ***********************************************************************/ -static uint32_t CalcCRC32OfFile(const char *szFileName) -{ - char acBuffer[IO_BLOCK_SIZE]; - int iFd = -1; - uint32_t uiCRC32 = 0; - - iFd = open(szFileName, O_RDONLY); - if (-1 == iFd) - systemError("%s", szFileName); - - do { - int iBytesRead = read(iFd, acBuffer, IO_BLOCK_SIZE); - - if (!iBytesRead) - break; - else if (iBytesRead < 0) - systemError("%s", szFileName); - - uiCRC32 = crc32(uiCRC32, acBuffer, iBytesRead); - } while (1); - - CLOSE(iFd); - - return uiCRC32; -} - -/*********************************************************************** - * !Function: GetRootDevice - * !Descr: determines the rootdevice from kernel command line root= - ***********************************************************************/ -static const char *GetRootDevice(void) -{ - int iFd = -1; - int iRead; - /* arm command line is at max 1024 Bytes */ - char szCmdLine[1024]; - static char szRootDev[32] = ""; - const char *szRootStart = NULL; - - if (*szRootDev) - return szRootDev; - - iFd = open("/proc/cmdline", O_RDONLY); - if (-1 == iFd) - systemError("/proc/cmdline"); - - iRead = read(iFd, szCmdLine, sizeof(szCmdLine) - 2); - if (-1 == iRead) - systemError("read"); - szCmdLine[iRead + 1] = 0; - - CLOSE(iFd); - - szRootStart = strstr(szCmdLine, "root="); - if (NULL != szRootStart) { - const char *szDev = szRootStart + 5; /* strlen( root=) */ - const char *szDevEnd = szDev; - int iLen; - - szDevEnd = strchr(szDev, ' '); - iLen = ((NULL == szDevEnd) ? strlen(szDev) : (szDevEnd - szDev)); - - strncpy(szRootDev, szDev, MIN(sizeof(szRootDev), iLen)); - } - - return szRootDev; -} diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb deleted file mode 100644 index b81036507..000000000 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros.bb +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2013 Digi International. - -SUMMARY = "Atheros's wireless driver" -LICENSE = "ISC" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d" - -inherit module - -SRCREV_external = "" -SRCREV_internal = "50dafb5890180cf33fdb42919c3e6f591d0cd2ea" -SRCREV = "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${SRCREV_internal}', '${SRCREV_external}', d)}" - -SRC_URI_external = "${DIGI_GITHUB_GIT}/atheros.git;protocol=git;nobranch=1" -SRC_URI_internal = "${DIGI_GIT}linux-modules/atheros.git;protocol=git;nobranch=1" -SRC_URI = "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${SRC_URI_internal}', '${SRC_URI_external}', d)}" -SRC_URI += " \ - file://atheros-pre-up \ - file://Makefile \ - file://0001-atheros-convert-NLA_PUT-macros.patch \ - file://0002-atheros-update-renamed-struct-members.patch \ -" - -S = "${WORKDIR}/git" - -EXTRA_OEMAKE += "DEL_PLATFORM=${MACHINE} KLIB_BUILD=${STAGING_KERNEL_DIR}" - -do_configure_prepend() { - cp ${WORKDIR}/Makefile ${S}/ -} - -do_install_append() { - install -d ${D}${sysconfdir}/network/if-pre-up.d - install -m 0755 ${WORKDIR}/atheros-pre-up ${D}${sysconfdir}/network/if-pre-up.d/atheros - install -d ${D}${sysconfdir}/modprobe.d - cat >> ${D}${sysconfdir}/modprobe.d/atheros.conf <<-_EOF_ - install ath6kl_sdio true - options ath6kl_sdio ath6kl_p2p=1 softmac_enable=1 - _EOF_ -} - -FILES_${PN} += " \ - ${sysconfdir}/modprobe.d/ \ - ${sysconfdir}/network/ \ -" - -# 'modprobe' from kmod package is needed to load atheros driver. The one -# from busybox does not support '--ignore-install' option. -RDEPENDS_${PN} = "kmod" - -COMPATIBLE_MACHINE = "(ccardimx28)" diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0001-atheros-convert-NLA_PUT-macros.patch b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0001-atheros-convert-NLA_PUT-macros.patch deleted file mode 100644 index 331f62c78..000000000 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0001-atheros-convert-NLA_PUT-macros.patch +++ /dev/null @@ -1,1761 +0,0 @@ -From: Javier Viguera -Date: Fri, 13 Sep 2013 10:54:16 +0200 -Subject: [PATCH] atheros: convert NLA_PUT macros - -sed -i -e '/NLA_PUT_[A-Z0-9]\+.*;$/{s,\(\t*\)\(NLA_PUT_[A-Z0-9]\+\)\([^;]\+\);,\1if (\L\2\E\3)\n\1\tgoto nla_put_failure;,g}' compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c compat-wireless/net/wireless/nl80211.c - -sed -i -e '/NLA_PUT_[A-Z0-9]\+.*[^;]$/{N;s,\(\t*\)\(NLA_PUT_[A-Z0-9]\+\)\([^;]\+\);,\1if (\L\2\E\3)\n\1\tgoto nla_put_failure;,g}' compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c compat-wireless/net/wireless/nl80211.c - -sed -i -e '/NLA_PUT.*;$/{s,\(\t*\)\(NLA_PUT\)\([^;]\+\);,\1if (\L\2\E\3)\n\1\tgoto nla_put_failure;,g}' compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c compat-wireless/net/wireless/nl80211.c - -sed -i -e '/NLA_PUT.*[^;]$/{N;s,\(\t*\)\(NLA_PUT\)\([^;]\+\);,\1if (\L\2\E\3)\n\1\tgoto nla_put_failure;,g}' compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c compat-wireless/net/wireless/nl80211.c - -sed -i -e '/NLA_PUT.*[^;]$/{N;N;s,\(\t*\)\(NLA_PUT\)\([^;]\+\);,\1if (\L\2\E\3)\n\1\tgoto nla_put_failure;,g}' compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c compat-wireless/net/wireless/nl80211.c - -And some minor manual fixes after running above commands. - -Signed-off-by: Javier Viguera ---- - .../drivers/net/wireless/ath/ath6kl/testmode.c | 6 +- - .../drivers/net/wireless/ath/ath6kl/wmiconfig.c | 6 +- - compat-wireless/net/wireless/nl80211.c | 1058 ++++++++++++-------- - 3 files changed, 676 insertions(+), 394 deletions(-) - -diff --git a/compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c b/compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c -index 942537cf81b5..c0ce573efb01 100644 ---- a/compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c -+++ b/compat-wireless/drivers/net/wireless/ath/ath6kl/testmode.c -@@ -59,8 +59,10 @@ void ath6kl_tm_rx_event(struct ath6kl *ar, void *buf, size_t buf_len) - ath6kl_warn("failed to allocate testmode rx skb!\n"); - return; - } -- NLA_PUT_U32(skb, ATH6KL_TM_ATTR_CMD, ATH6KL_TM_CMD_TCMD); -- NLA_PUT(skb, ATH6KL_TM_ATTR_DATA, buf_len, buf); -+ if (nla_put_u32(skb, ATH6KL_TM_ATTR_CMD, ATH6KL_TM_CMD_TCMD)) -+ goto nla_put_failure; -+ if (nla_put(skb, ATH6KL_TM_ATTR_DATA, buf_len, buf)) -+ goto nla_put_failure; - cfg80211_testmode_event(skb, GFP_KERNEL); - return; - -diff --git a/compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c b/compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c -index bb60ed23a967..450f915b9f96 100644 ---- a/compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c -+++ b/compat-wireless/drivers/net/wireless/ath/ath6kl/wmiconfig.c -@@ -64,8 +64,10 @@ void ath6kl_tm_rx_wmi_event(struct ath6kl *ar, void *buf, size_t buf_len) - ath6kl_warn("failed to allocate testmode rx skb!\n"); - return; - } -- NLA_PUT_U32(skb, ATH6KL_TM_ATTR_CMD, ATH6KL_TM_CMD_WMI_CMD); -- NLA_PUT(skb, ATH6KL_TM_ATTR_DATA, buf_len, buf); -+ if (nla_put_u32(skb, ATH6KL_TM_ATTR_CMD, ATH6KL_TM_CMD_WMI_CMD)) -+ goto nla_put_failure; -+ if (nla_put(skb, ATH6KL_TM_ATTR_DATA, buf_len, buf)) -+ goto nla_put_failure; - cfg80211_testmode_event(skb, GFP_KERNEL); - return; - -diff --git a/compat-wireless/net/wireless/nl80211.c b/compat-wireless/net/wireless/nl80211.c -index 66d35f2ca879..c219a2ca027f 100644 ---- a/compat-wireless/net/wireless/nl80211.c -+++ b/compat-wireless/net/wireless/nl80211.c -@@ -363,20 +363,26 @@ static inline void *nl80211hdr_put(struct sk_buff *skb, u32 pid, u32 seq, - static int nl80211_msg_put_channel(struct sk_buff *msg, - struct ieee80211_channel *chan) - { -- NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_FREQ, -- chan->center_freq); -+ if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_FREQ, -+ chan->center_freq)) -+ goto nla_put_failure; - - if (chan->flags & IEEE80211_CHAN_DISABLED) -- NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_DISABLED); -+ if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_DISABLED)) -+ goto nla_put_failure; - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) -- NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN); -+ if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN)) -+ goto nla_put_failure; - if (chan->flags & IEEE80211_CHAN_NO_IBSS) -- NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_NO_IBSS); -+ if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS)) -+ goto nla_put_failure; - if (chan->flags & IEEE80211_CHAN_RADAR) -- NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_RADAR); -+ if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR)) -+ goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER, -- DBM_TO_MBM(chan->max_power)); -+ if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER, -+ DBM_TO_MBM(chan->max_power))) -+ goto nla_put_failure; - - return 0; - -@@ -630,7 +636,8 @@ static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) - i = 0; - while (ifmodes) { - if (ifmodes & 1) -- NLA_PUT_FLAG(msg, i); -+ if (nla_put_flag(msg, i)) -+ goto nla_put_failure; - ifmodes >>= 1; - i++; - } -@@ -673,8 +680,9 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, - nl_limit = nla_nest_start(msg, j + 1); - if (!nl_limit) - goto nla_put_failure; -- NLA_PUT_U32(msg, NL80211_IFACE_LIMIT_MAX, -- c->limits[j].max); -+ if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX, -+ c->limits[j].max)) -+ goto nla_put_failure; - if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES, - c->limits[j].types)) - goto nla_put_failure; -@@ -684,12 +692,15 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, - nla_nest_end(msg, nl_limits); - - if (c->beacon_int_infra_match) -- NLA_PUT_FLAG(msg, -- NL80211_IFACE_COMB_STA_AP_BI_MATCH); -- NLA_PUT_U32(msg, NL80211_IFACE_COMB_NUM_CHANNELS, -- c->num_different_channels); -- NLA_PUT_U32(msg, NL80211_IFACE_COMB_MAXNUM, -- c->max_interfaces); -+ if (nla_put_flag(msg, -+ NL80211_IFACE_COMB_STA_AP_BI_MATCH)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_IFACE_COMB_NUM_CHANNELS, -+ c->num_different_channels)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM, -+ c->max_interfaces)) -+ goto nla_put_failure; - - nla_nest_end(msg, nl_combi); - } -@@ -720,64 +731,89 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - if (!hdr) - return -1; - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx); -- NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); -- -- NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, -- cfg80211_rdev_list_generation); -- -- NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, -- dev->wiphy.retry_short); -- NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, -- dev->wiphy.retry_long); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, -- dev->wiphy.frag_threshold); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, -- dev->wiphy.rts_threshold); -- NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, -- dev->wiphy.coverage_class); -- NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, -- dev->wiphy.max_scan_ssids); -- NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, -- dev->wiphy.max_sched_scan_ssids); -- NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, -- dev->wiphy.max_scan_ie_len); -- NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, -- dev->wiphy.max_sched_scan_ie_len); -- NLA_PUT_U8(msg, NL80211_ATTR_MAX_MATCH_SETS, -- dev->wiphy.max_match_sets); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_string(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy))) -+ goto nla_put_failure; -+ -+ if (nla_put_u32(msg, NL80211_ATTR_GENERATION, -+ cfg80211_rdev_list_generation)) -+ goto nla_put_failure; -+ -+ if (nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, -+ dev->wiphy.retry_short)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, -+ dev->wiphy.retry_long)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, -+ dev->wiphy.frag_threshold)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, -+ dev->wiphy.rts_threshold)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, -+ dev->wiphy.coverage_class)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, -+ dev->wiphy.max_scan_ssids)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, -+ dev->wiphy.max_sched_scan_ssids)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, -+ dev->wiphy.max_scan_ie_len)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, -+ dev->wiphy.max_sched_scan_ie_len)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS, -+ dev->wiphy.max_match_sets)) -+ goto nla_put_failure; - - if (dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) -- NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_IBSS_RSN); -+ if (nla_put_flag(msg, NL80211_ATTR_SUPPORT_IBSS_RSN)) -+ goto nla_put_failure; - if (dev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) -- NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_MESH_AUTH); -+ if (nla_put_flag(msg, NL80211_ATTR_SUPPORT_MESH_AUTH)) -+ goto nla_put_failure; - if (dev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) -- NLA_PUT_FLAG(msg, NL80211_ATTR_SUPPORT_AP_UAPSD); -+ if (nla_put_flag(msg, NL80211_ATTR_SUPPORT_AP_UAPSD)) -+ goto nla_put_failure; - if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) -- NLA_PUT_FLAG(msg, NL80211_ATTR_ROAM_SUPPORT); -+ if (nla_put_flag(msg, NL80211_ATTR_ROAM_SUPPORT)) -+ goto nla_put_failure; - if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) -- NLA_PUT_FLAG(msg, NL80211_ATTR_TDLS_SUPPORT); -+ if (nla_put_flag(msg, NL80211_ATTR_TDLS_SUPPORT)) -+ goto nla_put_failure; - if (dev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) -- NLA_PUT_FLAG(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP); -+ if (nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP)) -+ goto nla_put_failure; - -- NLA_PUT(msg, NL80211_ATTR_CIPHER_SUITES, -+ if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES, - sizeof(u32) * dev->wiphy.n_cipher_suites, -- dev->wiphy.cipher_suites); -+ dev->wiphy.cipher_suites)) -+ goto nla_put_failure; - -- NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, -- dev->wiphy.max_num_pmkids); -+ if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, -+ dev->wiphy.max_num_pmkids)) -+ goto nla_put_failure; - - if (dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) -- NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE); -+ if (nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE)) -+ goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, -- dev->wiphy.available_antennas_tx); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, -- dev->wiphy.available_antennas_rx); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, -+ dev->wiphy.available_antennas_tx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, -+ dev->wiphy.available_antennas_rx)) -+ goto nla_put_failure; - - if (dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) -- NLA_PUT_U32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, -- dev->wiphy.probe_resp_offload); -+ if (nla_put_u32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, -+ dev->wiphy.probe_resp_offload)) -+ goto nla_put_failure; - - if ((dev->wiphy.available_antennas_tx || - dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { -@@ -785,8 +821,10 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - int res; - res = dev->ops->get_antenna(&dev->wiphy, &tx_ant, &rx_ant); - if (!res) { -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant)) -+ goto nla_put_failure; - } - } - -@@ -808,15 +846,19 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - - /* add HT info */ - if (dev->wiphy.bands[band]->ht_cap.ht_supported) { -- NLA_PUT(msg, NL80211_BAND_ATTR_HT_MCS_SET, -+ if (nla_put(msg, NL80211_BAND_ATTR_HT_MCS_SET, - sizeof(dev->wiphy.bands[band]->ht_cap.mcs), -- &dev->wiphy.bands[band]->ht_cap.mcs); -- NLA_PUT_U16(msg, NL80211_BAND_ATTR_HT_CAPA, -- dev->wiphy.bands[band]->ht_cap.cap); -- NLA_PUT_U8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR, -- dev->wiphy.bands[band]->ht_cap.ampdu_factor); -- NLA_PUT_U8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY, -- dev->wiphy.bands[band]->ht_cap.ampdu_density); -+ &dev->wiphy.bands[band]->ht_cap.mcs)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_BAND_ATTR_HT_CAPA, -+ dev->wiphy.bands[band]->ht_cap.cap)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR, -+ dev->wiphy.bands[band]->ht_cap.ampdu_factor)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY, -+ dev->wiphy.bands[band]->ht_cap.ampdu_density)) -+ goto nla_put_failure; - } - - /* add frequencies */ -@@ -850,11 +892,13 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - goto nla_put_failure; - - rate = &dev->wiphy.bands[band]->bitrates[i]; -- NLA_PUT_U32(msg, NL80211_BITRATE_ATTR_RATE, -- rate->bitrate); -+ if (nla_put_u32(msg, NL80211_BITRATE_ATTR_RATE, -+ rate->bitrate)) -+ goto nla_put_failure; - if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) -- NLA_PUT_FLAG(msg, -- NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE); -+ if (nla_put_flag(msg, -+ NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE)) -+ goto nla_put_failure; - - nla_nest_end(msg, nl_rate); - } -@@ -874,7 +918,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - do { \ - if (dev->ops->op) { \ - i++; \ -- NLA_PUT_U32(msg, i, NL80211_CMD_ ## n); \ -+ if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \ -+ goto nla_put_failure; \ - } \ - } while (0) - -@@ -901,7 +946,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL); - if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { - i++; -- NLA_PUT_U32(msg, i, NL80211_CMD_SET_WIPHY_NETNS); -+ if (nla_put_u32(msg, i, NL80211_CMD_SET_WIPHY_NETNS)) -+ goto nla_put_failure; - } - CMD(set_channel, SET_CHANNEL); - CMD(set_wds_peer, SET_WDS_PEER); -@@ -914,29 +960,34 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - CMD(probe_client, PROBE_CLIENT); - if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { - i++; -- NLA_PUT_U32(msg, i, NL80211_CMD_REGISTER_BEACONS); -+ if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS)) -+ goto nla_put_failure; - } - - #undef CMD - - if (dev->ops->connect || dev->ops->auth) { - i++; -- NLA_PUT_U32(msg, i, NL80211_CMD_CONNECT); -+ if (nla_put_u32(msg, i, NL80211_CMD_CONNECT)) -+ goto nla_put_failure; - } - - if (dev->ops->disconnect || dev->ops->deauth) { - i++; -- NLA_PUT_U32(msg, i, NL80211_CMD_DISCONNECT); -+ if (nla_put_u32(msg, i, NL80211_CMD_DISCONNECT)) -+ goto nla_put_failure; - } - - nla_nest_end(msg, nl_cmds); - - if (dev->ops->remain_on_channel) -- NLA_PUT_U32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, -- dev->wiphy.max_remain_on_channel_duration); -+ if (nla_put_u32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, -+ dev->wiphy.max_remain_on_channel_duration)) -+ goto nla_put_failure; - - if (dev->ops->mgmt_tx_cancel_wait) -- NLA_PUT_FLAG(msg, NL80211_ATTR_OFFCHANNEL_TX_OK); -+ if (nla_put_flag(msg, NL80211_ATTR_OFFCHANNEL_TX_OK)) -+ goto nla_put_failure; - - if (mgmt_stypes) { - u16 stypes; -@@ -955,8 +1006,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - stypes = mgmt_stypes[ift].tx; - while (stypes) { - if (stypes & 1) -- NLA_PUT_U16(msg, NL80211_ATTR_FRAME_TYPE, -- (i << 4) | IEEE80211_FTYPE_MGMT); -+ if (nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, -+ (i << 4) | IEEE80211_FTYPE_MGMT)) -+ goto nla_put_failure; - stypes >>= 1; - i++; - } -@@ -977,8 +1029,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - stypes = mgmt_stypes[ift].rx; - while (stypes) { - if (stypes & 1) -- NLA_PUT_U16(msg, NL80211_ATTR_FRAME_TYPE, -- (i << 4) | IEEE80211_FTYPE_MGMT); -+ if (nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, -+ (i << 4) | IEEE80211_FTYPE_MGMT)) -+ goto nla_put_failure; - stypes >>= 1; - i++; - } -@@ -996,21 +1049,29 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - goto nla_put_failure; - - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_ANY) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_ANY); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_DISCONNECT) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE)) -+ goto nla_put_failure; - if (dev->wiphy.wowlan.n_patterns) { - struct nl80211_wowlan_pattern_support pat = { - .max_patterns = dev->wiphy.wowlan.n_patterns, -@@ -1019,8 +1080,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - .max_pattern_len = - dev->wiphy.wowlan.pattern_max_len, - }; -- NLA_PUT(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN, -- sizeof(pat), &pat); -+ if (nla_put(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN, -+ sizeof(pat), &pat)) -+ goto nla_put_failure; - } - - nla_nest_end(msg, nl_wowlan); -@@ -1034,10 +1096,12 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, - goto nla_put_failure; - - if (dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) -- NLA_PUT_U32(msg, NL80211_ATTR_DEVICE_AP_SME, -- dev->wiphy.ap_sme_capa); -+ if (nla_put_u32(msg, NL80211_ATTR_DEVICE_AP_SME, -+ dev->wiphy.ap_sme_capa)) -+ goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_FEATURE_FLAGS, dev->wiphy.features); -+ if (nla_put_u32(msg, NL80211_ATTR_FEATURE_FLAGS, dev->wiphy.features)) -+ goto nla_put_failure; - - return genlmsg_end(msg, hdr); - -@@ -1480,14 +1544,19 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, - if (!hdr) - return -1; - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name); -- NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype)) -+ goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, -+ if (nla_put_u32(msg, NL80211_ATTR_GENERATION, - rdev->devlist_generation ^ -- (cfg80211_rdev_list_generation << 2)); -+ (cfg80211_rdev_list_generation << 2))) -+ goto nla_put_failure; - - return genlmsg_end(msg, hdr); - -@@ -1769,34 +1838,41 @@ static void get_key_callback(void *c, struct key_params *params) - struct get_key_cookie *cookie = c; - - if (params->key) -- NLA_PUT(cookie->msg, NL80211_ATTR_KEY_DATA, -- params->key_len, params->key); -+ if (nla_put(cookie->msg, NL80211_ATTR_KEY_DATA, -+ params->key_len, params->key)) -+ goto nla_put_failure; - - if (params->seq) -- NLA_PUT(cookie->msg, NL80211_ATTR_KEY_SEQ, -- params->seq_len, params->seq); -+ if (nla_put(cookie->msg, NL80211_ATTR_KEY_SEQ, -+ params->seq_len, params->seq)) -+ goto nla_put_failure; - - if (params->cipher) -- NLA_PUT_U32(cookie->msg, NL80211_ATTR_KEY_CIPHER, -- params->cipher); -+ if (nla_put_u32(cookie->msg, NL80211_ATTR_KEY_CIPHER, -+ params->cipher)) -+ goto nla_put_failure; - - key = nla_nest_start(cookie->msg, NL80211_ATTR_KEY); - if (!key) - goto nla_put_failure; - - if (params->key) -- NLA_PUT(cookie->msg, NL80211_KEY_DATA, -- params->key_len, params->key); -+ if (nla_put(cookie->msg, NL80211_KEY_DATA, -+ params->key_len, params->key)) -+ goto nla_put_failure; - - if (params->seq) -- NLA_PUT(cookie->msg, NL80211_KEY_SEQ, -- params->seq_len, params->seq); -+ if (nla_put(cookie->msg, NL80211_KEY_SEQ, -+ params->seq_len, params->seq)) -+ goto nla_put_failure; - - if (params->cipher) -- NLA_PUT_U32(cookie->msg, NL80211_KEY_CIPHER, -- params->cipher); -+ if (nla_put_u32(cookie->msg, NL80211_KEY_CIPHER, -+ params->cipher)) -+ goto nla_put_failure; - -- NLA_PUT_U8(cookie->msg, NL80211_ATTR_KEY_IDX, cookie->idx); -+ if (nla_put_u8(cookie->msg, NL80211_ATTR_KEY_IDX, cookie->idx)) -+ goto nla_put_failure; - - nla_nest_end(cookie->msg, key); - -@@ -1854,10 +1930,13 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) - cookie.msg = msg; - cookie.idx = key_idx; - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_ATTR_KEY_IDX, key_idx)) -+ goto nla_put_failure; - if (mac_addr) -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr)) -+ goto nla_put_failure; - - if (pairwise && mac_addr && - !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) -@@ -2373,14 +2452,18 @@ static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info, - /* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */ - bitrate = cfg80211_calculate_bitrate(info); - if (bitrate > 0) -- NLA_PUT_U16(msg, NL80211_RATE_INFO_BITRATE, bitrate); -+ if (nla_put_u16(msg, NL80211_RATE_INFO_BITRATE, bitrate)) -+ goto nla_put_failure; - - if (info->flags & RATE_INFO_FLAGS_MCS) -- NLA_PUT_U8(msg, NL80211_RATE_INFO_MCS, info->mcs); -+ if (nla_put_u8(msg, NL80211_RATE_INFO_MCS, info->mcs)) -+ goto nla_put_failure; - if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) -- NLA_PUT_FLAG(msg, NL80211_RATE_INFO_40_MHZ_WIDTH); -+ if (nla_put_flag(msg, NL80211_RATE_INFO_40_MHZ_WIDTH)) -+ goto nla_put_failure; - if (info->flags & RATE_INFO_FLAGS_SHORT_GI) -- NLA_PUT_FLAG(msg, NL80211_RATE_INFO_SHORT_GI); -+ if (nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI)) -+ goto nla_put_failure; - - nla_nest_end(msg, rate); - return true; -@@ -2400,41 +2483,53 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, - if (!hdr) - return -1; - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr)) -+ goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, sinfo->generation); -+ if (nla_put_u32(msg, NL80211_ATTR_GENERATION, sinfo->generation)) -+ goto nla_put_failure; - - sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO); - if (!sinfoattr) - goto nla_put_failure; - if (sinfo->filled & STATION_INFO_CONNECTED_TIME) -- NLA_PUT_U32(msg, NL80211_STA_INFO_CONNECTED_TIME, -- sinfo->connected_time); -+ if (nla_put_u32(msg, NL80211_STA_INFO_CONNECTED_TIME, -+ sinfo->connected_time)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_INACTIVE_TIME) -- NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME, -- sinfo->inactive_time); -+ if (nla_put_u32(msg, NL80211_STA_INFO_INACTIVE_TIME, -+ sinfo->inactive_time)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_RX_BYTES) -- NLA_PUT_U32(msg, NL80211_STA_INFO_RX_BYTES, -- sinfo->rx_bytes); -+ if (nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES, -+ sinfo->rx_bytes)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_TX_BYTES) -- NLA_PUT_U32(msg, NL80211_STA_INFO_TX_BYTES, -- sinfo->tx_bytes); -+ if (nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES, -+ sinfo->tx_bytes)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_LLID) -- NLA_PUT_U16(msg, NL80211_STA_INFO_LLID, -- sinfo->llid); -+ if (nla_put_u16(msg, NL80211_STA_INFO_LLID, -+ sinfo->llid)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_PLID) -- NLA_PUT_U16(msg, NL80211_STA_INFO_PLID, -- sinfo->plid); -+ if (nla_put_u16(msg, NL80211_STA_INFO_PLID, -+ sinfo->plid)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_PLINK_STATE) -- NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE, -- sinfo->plink_state); -+ if (nla_put_u8(msg, NL80211_STA_INFO_PLINK_STATE, -+ sinfo->plink_state)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_SIGNAL) -- NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL, -- sinfo->signal); -+ if (nla_put_u8(msg, NL80211_STA_INFO_SIGNAL, -+ sinfo->signal)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_SIGNAL_AVG) -- NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL_AVG, -- sinfo->signal_avg); -+ if (nla_put_u8(msg, NL80211_STA_INFO_SIGNAL_AVG, -+ sinfo->signal_avg)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_TX_BITRATE) { - if (!nl80211_put_sta_rate(msg, &sinfo->txrate, - NL80211_STA_INFO_TX_BITRATE)) -@@ -2446,45 +2541,56 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, - goto nla_put_failure; - } - if (sinfo->filled & STATION_INFO_RX_PACKETS) -- NLA_PUT_U32(msg, NL80211_STA_INFO_RX_PACKETS, -- sinfo->rx_packets); -+ if (nla_put_u32(msg, NL80211_STA_INFO_RX_PACKETS, -+ sinfo->rx_packets)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_TX_PACKETS) -- NLA_PUT_U32(msg, NL80211_STA_INFO_TX_PACKETS, -- sinfo->tx_packets); -+ if (nla_put_u32(msg, NL80211_STA_INFO_TX_PACKETS, -+ sinfo->tx_packets)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_TX_RETRIES) -- NLA_PUT_U32(msg, NL80211_STA_INFO_TX_RETRIES, -- sinfo->tx_retries); -+ if (nla_put_u32(msg, NL80211_STA_INFO_TX_RETRIES, -+ sinfo->tx_retries)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_TX_FAILED) -- NLA_PUT_U32(msg, NL80211_STA_INFO_TX_FAILED, -- sinfo->tx_failed); -+ if (nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED, -+ sinfo->tx_failed)) -+ goto nla_put_failure; - if (sinfo->filled & STATION_INFO_BSS_PARAM) { - bss_param = nla_nest_start(msg, NL80211_STA_INFO_BSS_PARAM); - if (!bss_param) - goto nla_put_failure; - - if (sinfo->bss_param.flags & BSS_PARAM_FLAGS_CTS_PROT) -- NLA_PUT_FLAG(msg, NL80211_STA_BSS_PARAM_CTS_PROT); -+ if (nla_put_flag(msg, NL80211_STA_BSS_PARAM_CTS_PROT)) -+ goto nla_put_failure; - if (sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_PREAMBLE) -- NLA_PUT_FLAG(msg, NL80211_STA_BSS_PARAM_SHORT_PREAMBLE); -+ if (nla_put_flag(msg, NL80211_STA_BSS_PARAM_SHORT_PREAMBLE)) -+ goto nla_put_failure; - if (sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_SLOT_TIME) -- NLA_PUT_FLAG(msg, -- NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME); -- NLA_PUT_U8(msg, NL80211_STA_BSS_PARAM_DTIM_PERIOD, -- sinfo->bss_param.dtim_period); -- NLA_PUT_U16(msg, NL80211_STA_BSS_PARAM_BEACON_INTERVAL, -- sinfo->bss_param.beacon_interval); -+ if (nla_put_flag(msg, -+ NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_STA_BSS_PARAM_DTIM_PERIOD, -+ sinfo->bss_param.dtim_period)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_STA_BSS_PARAM_BEACON_INTERVAL, -+ sinfo->bss_param.beacon_interval)) -+ goto nla_put_failure; - - nla_nest_end(msg, bss_param); - } - if (sinfo->filled & STATION_INFO_STA_FLAGS) -- NLA_PUT(msg, NL80211_STA_INFO_STA_FLAGS, -+ if (nla_put(msg, NL80211_STA_INFO_STA_FLAGS, - sizeof(struct nl80211_sta_flag_update), -- &sinfo->sta_flags); -+ &sinfo->sta_flags)) -+ goto nla_put_failure; - nla_nest_end(msg, sinfoattr); - - if (sinfo->filled & STATION_INFO_ASSOC_REQ_IES) -- NLA_PUT(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len, -- sinfo->assoc_req_ies); -+ if (nla_put(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len, -+ sinfo->assoc_req_ies)) -+ goto nla_put_failure; - - return genlmsg_end(msg, hdr); - -@@ -2872,36 +2978,47 @@ static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq, - if (!hdr) - return -1; - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst); -- NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dst)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop)) -+ goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, pinfo->generation); -+ if (nla_put_u32(msg, NL80211_ATTR_GENERATION, pinfo->generation)) -+ goto nla_put_failure; - - pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO); - if (!pinfoattr) - goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_FRAME_QLEN) -- NLA_PUT_U32(msg, NL80211_MPATH_INFO_FRAME_QLEN, -- pinfo->frame_qlen); -+ if (nla_put_u32(msg, NL80211_MPATH_INFO_FRAME_QLEN, -+ pinfo->frame_qlen)) -+ goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_SN) -- NLA_PUT_U32(msg, NL80211_MPATH_INFO_SN, -- pinfo->sn); -+ if (nla_put_u32(msg, NL80211_MPATH_INFO_SN, -+ pinfo->sn)) -+ goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_METRIC) -- NLA_PUT_U32(msg, NL80211_MPATH_INFO_METRIC, -- pinfo->metric); -+ if (nla_put_u32(msg, NL80211_MPATH_INFO_METRIC, -+ pinfo->metric)) -+ goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_EXPTIME) -- NLA_PUT_U32(msg, NL80211_MPATH_INFO_EXPTIME, -- pinfo->exptime); -+ if (nla_put_u32(msg, NL80211_MPATH_INFO_EXPTIME, -+ pinfo->exptime)) -+ goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_FLAGS) -- NLA_PUT_U8(msg, NL80211_MPATH_INFO_FLAGS, -- pinfo->flags); -+ if (nla_put_u8(msg, NL80211_MPATH_INFO_FLAGS, -+ pinfo->flags)) -+ goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT) -- NLA_PUT_U32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT, -- pinfo->discovery_timeout); -+ if (nla_put_u32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT, -+ pinfo->discovery_timeout)) -+ goto nla_put_failure; - if (pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES) -- NLA_PUT_U8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES, -- pinfo->discovery_retries); -+ if (nla_put_u8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES, -+ pinfo->discovery_retries)) -+ goto nla_put_failure; - - nla_nest_end(msg, pinfoattr); - -@@ -3227,41 +3344,59 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, - pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_CONFIG); - if (!pinfoattr) - goto nla_put_failure; -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT_U16(msg, NL80211_MESHCONF_RETRY_TIMEOUT, -- cur_params.dot11MeshRetryTimeout); -- NLA_PUT_U16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT, -- cur_params.dot11MeshConfirmTimeout); -- NLA_PUT_U16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT, -- cur_params.dot11MeshHoldingTimeout); -- NLA_PUT_U16(msg, NL80211_MESHCONF_MAX_PEER_LINKS, -- cur_params.dot11MeshMaxPeerLinks); -- NLA_PUT_U8(msg, NL80211_MESHCONF_MAX_RETRIES, -- cur_params.dot11MeshMaxRetries); -- NLA_PUT_U8(msg, NL80211_MESHCONF_TTL, -- cur_params.dot11MeshTTL); -- NLA_PUT_U8(msg, NL80211_MESHCONF_ELEMENT_TTL, -- cur_params.element_ttl); -- NLA_PUT_U8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS, -- cur_params.auto_open_plinks); -- NLA_PUT_U8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, -- cur_params.dot11MeshHWMPmaxPREQretries); -- NLA_PUT_U32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME, -- cur_params.path_refresh_time); -- NLA_PUT_U16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, -- cur_params.min_discovery_timeout); -- NLA_PUT_U32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, -- cur_params.dot11MeshHWMPactivePathTimeout); -- NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, -- cur_params.dot11MeshHWMPpreqMinInterval); -- NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, -- cur_params.dot11MeshHWMPnetDiameterTraversalTime); -- NLA_PUT_U8(msg, NL80211_MESHCONF_HWMP_ROOTMODE, -- cur_params.dot11MeshHWMPRootMode); -- NLA_PUT_U16(msg, NL80211_MESHCONF_HWMP_RANN_INTERVAL, -- cur_params.dot11MeshHWMPRannInterval); -- NLA_PUT_U8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, -- cur_params.dot11MeshGateAnnouncementProtocol); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_RETRY_TIMEOUT, -+ cur_params.dot11MeshRetryTimeout)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT, -+ cur_params.dot11MeshConfirmTimeout)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT, -+ cur_params.dot11MeshHoldingTimeout)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS, -+ cur_params.dot11MeshMaxPeerLinks)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_MAX_RETRIES, -+ cur_params.dot11MeshMaxRetries)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_TTL, -+ cur_params.dot11MeshTTL)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_ELEMENT_TTL, -+ cur_params.element_ttl)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS, -+ cur_params.auto_open_plinks)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, -+ cur_params.dot11MeshHWMPmaxPREQretries)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME, -+ cur_params.path_refresh_time)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, -+ cur_params.min_discovery_timeout)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, -+ cur_params.dot11MeshHWMPactivePathTimeout)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, -+ cur_params.dot11MeshHWMPpreqMinInterval)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, -+ cur_params.dot11MeshHWMPnetDiameterTraversalTime)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_HWMP_ROOTMODE, -+ cur_params.dot11MeshHWMPRootMode)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_MESHCONF_HWMP_RANN_INTERVAL, -+ cur_params.dot11MeshHWMPRannInterval)) -+ goto nla_put_failure; -+ if (nla_put_u8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, -+ cur_params.dot11MeshGateAnnouncementProtocol)) -+ goto nla_put_failure; - nla_nest_end(msg, pinfoattr); - genlmsg_end(msg, hdr); - return genlmsg_reply(msg, info); -@@ -3482,8 +3617,9 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info) - if (!hdr) - goto put_failure; - -- NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, -- cfg80211_regdomain->alpha2); -+ if (nla_put_string(msg, NL80211_ATTR_REG_ALPHA2, -+ cfg80211_regdomain->alpha2)) -+ goto nla_put_failure; - - nl_reg_rules = nla_nest_start(msg, NL80211_ATTR_REG_RULES); - if (!nl_reg_rules) -@@ -3503,18 +3639,24 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info) - if (!nl_reg_rule) - goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_REG_RULE_FLAGS, -- reg_rule->flags); -- NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_START, -- freq_range->start_freq_khz); -- NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_END, -- freq_range->end_freq_khz); -- NLA_PUT_U32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW, -- freq_range->max_bandwidth_khz); -- NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, -- power_rule->max_antenna_gain); -- NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP, -- power_rule->max_eirp); -+ if (nla_put_u32(msg, NL80211_ATTR_REG_RULE_FLAGS, -+ reg_rule->flags)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_START, -+ freq_range->start_freq_khz)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_END, -+ freq_range->end_freq_khz)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW, -+ freq_range->max_bandwidth_khz)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, -+ power_rule->max_antenna_gain)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP, -+ power_rule->max_eirp)) -+ goto nla_put_failure; - - nla_nest_end(msg, nl_reg_rule); - } -@@ -4081,37 +4223,49 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, - - genl_dump_check_consistent(cb, hdr, &nl80211_fam); - -- NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex)) -+ goto nla_put_failure; - - bss = nla_nest_start(msg, NL80211_ATTR_BSS); - if (!bss) - goto nla_put_failure; - if (!is_zero_ether_addr(res->bssid)) -- NLA_PUT(msg, NL80211_BSS_BSSID, ETH_ALEN, res->bssid); -+ if (nla_put(msg, NL80211_BSS_BSSID, ETH_ALEN, res->bssid)) -+ goto nla_put_failure; - if (res->information_elements && res->len_information_elements) -- NLA_PUT(msg, NL80211_BSS_INFORMATION_ELEMENTS, -+ if (nla_put(msg, NL80211_BSS_INFORMATION_ELEMENTS, - res->len_information_elements, -- res->information_elements); -+ res->information_elements)) -+ goto nla_put_failure; - if (res->beacon_ies && res->len_beacon_ies && - res->beacon_ies != res->information_elements) -- NLA_PUT(msg, NL80211_BSS_BEACON_IES, -- res->len_beacon_ies, res->beacon_ies); -+ if (nla_put(msg, NL80211_BSS_BEACON_IES, -+ res->len_beacon_ies, res->beacon_ies)) -+ goto nla_put_failure; - if (res->tsf) -- NLA_PUT_U64(msg, NL80211_BSS_TSF, res->tsf); -+ if (nla_put_u64(msg, NL80211_BSS_TSF, res->tsf)) -+ goto nla_put_failure; - if (res->beacon_interval) -- NLA_PUT_U16(msg, NL80211_BSS_BEACON_INTERVAL, res->beacon_interval); -- NLA_PUT_U16(msg, NL80211_BSS_CAPABILITY, res->capability); -- NLA_PUT_U32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq); -- NLA_PUT_U32(msg, NL80211_BSS_SEEN_MS_AGO, -- jiffies_to_msecs(jiffies - intbss->ts)); -+ if (nla_put_u16(msg, NL80211_BSS_BEACON_INTERVAL, res->beacon_interval)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_BSS_CAPABILITY, res->capability)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_BSS_SEEN_MS_AGO, -+ jiffies_to_msecs(jiffies - intbss->ts))) -+ goto nla_put_failure; - - switch (rdev->wiphy.signal_type) { - case CFG80211_SIGNAL_TYPE_MBM: -- NLA_PUT_U32(msg, NL80211_BSS_SIGNAL_MBM, res->signal); -+ if (nla_put_u32(msg, NL80211_BSS_SIGNAL_MBM, res->signal)) -+ goto nla_put_failure; - break; - case CFG80211_SIGNAL_TYPE_UNSPEC: -- NLA_PUT_U8(msg, NL80211_BSS_SIGNAL_UNSPEC, res->signal); -+ if (nla_put_u8(msg, NL80211_BSS_SIGNAL_UNSPEC, res->signal)) -+ goto nla_put_failure; - break; - default: - break; -@@ -4121,20 +4275,23 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, - case NL80211_IFTYPE_P2P_CLIENT: - case NL80211_IFTYPE_STATION: - if (intbss == wdev->current_bss) -- NLA_PUT_U32(msg, NL80211_BSS_STATUS, -- NL80211_BSS_STATUS_ASSOCIATED); -+ if (nla_put_u32(msg, NL80211_BSS_STATUS, -+ NL80211_BSS_STATUS_ASSOCIATED)) -+ goto nla_put_failure; - else for (i = 0; i < MAX_AUTH_BSSES; i++) { - if (intbss != wdev->auth_bsses[i]) - continue; -- NLA_PUT_U32(msg, NL80211_BSS_STATUS, -- NL80211_BSS_STATUS_AUTHENTICATED); -+ if (nla_put_u32(msg, NL80211_BSS_STATUS, -+ NL80211_BSS_STATUS_AUTHENTICATED)) -+ goto nla_put_failure; - break; - } - break; - case NL80211_IFTYPE_ADHOC: - if (intbss == wdev->current_bss) -- NLA_PUT_U32(msg, NL80211_BSS_STATUS, -- NL80211_BSS_STATUS_IBSS_JOINED); -+ if (nla_put_u32(msg, NL80211_BSS_STATUS, -+ NL80211_BSS_STATUS_IBSS_JOINED)) -+ goto nla_put_failure; - break; - default: - break; -@@ -4205,34 +4362,43 @@ static int nl80211_send_survey(struct sk_buff *msg, u32 pid, u32 seq, - if (!hdr) - return -ENOMEM; - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; - - infoattr = nla_nest_start(msg, NL80211_ATTR_SURVEY_INFO); - if (!infoattr) - goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_SURVEY_INFO_FREQUENCY, -- survey->channel->center_freq); -+ if (nla_put_u32(msg, NL80211_SURVEY_INFO_FREQUENCY, -+ survey->channel->center_freq)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_NOISE_DBM) -- NLA_PUT_U8(msg, NL80211_SURVEY_INFO_NOISE, -- survey->noise); -+ if (nla_put_u8(msg, NL80211_SURVEY_INFO_NOISE, -+ survey->noise)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_IN_USE) -- NLA_PUT_FLAG(msg, NL80211_SURVEY_INFO_IN_USE); -+ if (nla_put_flag(msg, NL80211_SURVEY_INFO_IN_USE)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_CHANNEL_TIME) -- NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME, -- survey->channel_time); -+ if (nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME, -+ survey->channel_time)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_CHANNEL_TIME_BUSY) -- NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY, -- survey->channel_time_busy); -+ if (nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY, -+ survey->channel_time_busy)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) -- NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY, -- survey->channel_time_ext_busy); -+ if (nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY, -+ survey->channel_time_ext_busy)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_CHANNEL_TIME_RX) -- NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_RX, -- survey->channel_time_rx); -+ if (nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_RX, -+ survey->channel_time_rx)) -+ goto nla_put_failure; - if (survey->filled & SURVEY_INFO_CHANNEL_TIME_TX) -- NLA_PUT_U64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_TX, -- survey->channel_time_tx); -+ if (nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_TX, -+ survey->channel_time_tx)) -+ goto nla_put_failure; - - nla_nest_end(msg, infoattr); - -@@ -4900,7 +5066,8 @@ __cfg80211_testmode_alloc_skb(struct cfg80211_registered_device *rdev, - return NULL; - } - -- NLA_PUT_U32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -+ if (nla_put_u32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; - data = nla_nest_start(skb, NL80211_ATTR_TESTDATA); - - ((void **)skb->cb)[0] = rdev; -@@ -5274,7 +5441,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, - if (err) - goto free_msg; - -- NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); -+ if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -5558,7 +5726,8 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) - goto free_msg; - - if (msg) { -- NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); -+ if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - return genlmsg_reply(msg, info); -@@ -5663,7 +5832,8 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info) - else - ps_state = NL80211_PS_DISABLED; - -- NLA_PUT_U32(msg, NL80211_ATTR_PS_STATE, ps_state); -+ if (nla_put_u32(msg, NL80211_ATTR_PS_STATE, ps_state)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - return genlmsg_reply(msg, info); -@@ -5841,19 +6011,26 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) - goto nla_put_failure; - - if (rdev->wowlan->any) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_ANY); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) -+ goto nla_put_failure; - if (rdev->wowlan->disconnect) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_DISCONNECT); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) -+ goto nla_put_failure; - if (rdev->wowlan->magic_pkt) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) -+ goto nla_put_failure; - if (rdev->wowlan->gtk_rekey_failure) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) -+ goto nla_put_failure; - if (rdev->wowlan->eap_identity_req) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) -+ goto nla_put_failure; - if (rdev->wowlan->four_way_handshake) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) -+ goto nla_put_failure; - if (rdev->wowlan->rfkill_release) -- NLA_PUT_FLAG(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE); -+ if (nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE)) -+ goto nla_put_failure; - if (rdev->wowlan->n_patterns) { - struct nlattr *nl_pats, *nl_pat; - int i, pat_len; -@@ -5868,12 +6045,14 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) - if (!nl_pat) - goto nla_put_failure; - pat_len = rdev->wowlan->patterns[i].pattern_len; -- NLA_PUT(msg, NL80211_WOWLAN_PKTPAT_MASK, -+ if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK, - DIV_ROUND_UP(pat_len, 8), -- rdev->wowlan->patterns[i].mask); -- NLA_PUT(msg, NL80211_WOWLAN_PKTPAT_PATTERN, -+ rdev->wowlan->patterns[i].mask)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN, - pat_len, -- rdev->wowlan->patterns[i].pattern); -+ rdev->wowlan->patterns[i].pattern)) -+ goto nla_put_failure; - nla_nest_end(msg, nl_pat); - } - nla_nest_end(msg, nl_pats); -@@ -6146,7 +6325,8 @@ static int nl80211_probe_client(struct sk_buff *skb, - if (err) - goto free_msg; - -- NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); -+ if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -6843,18 +7023,21 @@ static int nl80211_add_scan_req(struct sk_buff *msg, - if (!nest) - goto nla_put_failure; - for (i = 0; i < req->n_ssids; i++) -- NLA_PUT(msg, i, req->ssids[i].ssid_len, req->ssids[i].ssid); -+ if (nla_put(msg, i, req->ssids[i].ssid_len, req->ssids[i].ssid)) -+ goto nla_put_failure; - nla_nest_end(msg, nest); - - nest = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES); - if (!nest) - goto nla_put_failure; - for (i = 0; i < req->n_channels; i++) -- NLA_PUT_U32(msg, i, req->channels[i]->center_freq); -+ if (nla_put_u32(msg, i, req->channels[i]->center_freq)) -+ goto nla_put_failure; - nla_nest_end(msg, nest); - - if (req->ie) -- NLA_PUT(msg, NL80211_ATTR_IE, req->ie_len, req->ie); -+ if (nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) -+ goto nla_put_failure; - - return 0; - nla_put_failure: -@@ -6873,8 +7056,10 @@ static int nl80211_send_scan_msg(struct sk_buff *msg, - if (!hdr) - return -1; - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - - /* ignore errors and send incomplete event anyway */ - nl80211_add_scan_req(msg, rdev); -@@ -6898,8 +7083,10 @@ nl80211_send_sched_scan_msg(struct sk_buff *msg, - if (!hdr) - return -1; - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - - return genlmsg_end(msg, hdr); - -@@ -7022,26 +7209,33 @@ void nl80211_send_reg_change_event(struct regulatory_request *request) - } - - /* Userspace can always count this one always being set */ -- NLA_PUT_U8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator); -+ if (nla_put_u8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator)) -+ goto nla_put_failure; - - if (request->alpha2[0] == '0' && request->alpha2[1] == '0') -- NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, -- NL80211_REGDOM_TYPE_WORLD); -+ if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, -+ NL80211_REGDOM_TYPE_WORLD)) -+ goto nla_put_failure; - else if (request->alpha2[0] == '9' && request->alpha2[1] == '9') -- NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, -- NL80211_REGDOM_TYPE_CUSTOM_WORLD); -+ if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, -+ NL80211_REGDOM_TYPE_CUSTOM_WORLD)) -+ goto nla_put_failure; - else if ((request->alpha2[0] == '9' && request->alpha2[1] == '8') || - request->intersect) -- NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, -- NL80211_REGDOM_TYPE_INTERSECTION); -+ if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, -+ NL80211_REGDOM_TYPE_INTERSECTION)) -+ goto nla_put_failure; - else { -- NLA_PUT_U8(msg, NL80211_ATTR_REG_TYPE, -- NL80211_REGDOM_TYPE_COUNTRY); -- NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, request->alpha2); -+ if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE, -+ NL80211_REGDOM_TYPE_COUNTRY)) -+ goto nla_put_failure; -+ if (nla_put_string(msg, NL80211_ATTR_REG_ALPHA2, request->alpha2)) -+ goto nla_put_failure; - } - - if (wiphy_idx_valid(request->wiphy_idx)) -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7075,9 +7269,12 @@ static void nl80211_send_mlme_event(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_FRAME, len, buf)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7155,10 +7352,14 @@ static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT_FLAG(msg, NL80211_ATTR_TIMED_OUT); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_flag(msg, NL80211_ATTR_TIMED_OUT)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7206,15 +7407,21 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - if (bssid) -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); -- NLA_PUT_U16(msg, NL80211_ATTR_STATUS_CODE, status); -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) -+ goto nla_put_failure; -+ if (nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, status)) -+ goto nla_put_failure; - if (req_ie) -- NLA_PUT(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie); -+ if (nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) -+ goto nla_put_failure; - if (resp_ie) -- NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); -+ if (nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7246,13 +7453,18 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) -+ goto nla_put_failure; - if (req_ie) -- NLA_PUT(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie); -+ if (nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) -+ goto nla_put_failure; - if (resp_ie) -- NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); -+ if (nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7283,14 +7495,19 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - if (from_ap && reason) -- NLA_PUT_U16(msg, NL80211_ATTR_REASON_CODE, reason); -+ if (nla_put_u16(msg, NL80211_ATTR_REASON_CODE, reason)) -+ goto nla_put_failure; - if (from_ap) -- NLA_PUT_FLAG(msg, NL80211_ATTR_DISCONNECTED_BY_AP); -+ if (nla_put_flag(msg, NL80211_ATTR_DISCONNECTED_BY_AP)) -+ goto nla_put_failure; - if (ie) -- NLA_PUT(msg, NL80211_ATTR_IE, ie_len, ie); -+ if (nla_put(msg, NL80211_ATTR_IE, ie_len, ie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7321,9 +7538,12 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7354,11 +7574,15 @@ void nl80211_send_new_peer_candidate(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr)) -+ goto nla_put_failure; - if (ie_len && ie) -- NLA_PUT(msg, NL80211_ATTR_IE, ie_len , ie); -+ if (nla_put(msg, NL80211_ATTR_IE, ie_len , ie)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7389,15 +7613,21 @@ void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - if (addr) -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); -- NLA_PUT_U32(msg, NL80211_ATTR_KEY_TYPE, key_type); -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_KEY_TYPE, key_type)) -+ goto nla_put_failure; - if (key_id != -1) -- NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_id); -+ if (nla_put_u8(msg, NL80211_ATTR_KEY_IDX, key_id)) -+ goto nla_put_failure; - if (tsc) -- NLA_PUT(msg, NL80211_ATTR_KEY_SEQ, 6, tsc); -+ if (nla_put(msg, NL80211_ATTR_KEY_SEQ, 6, tsc)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7432,7 +7662,8 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy, - * Since we are applying the beacon hint to a wiphy we know its - * wiphy_idx is valid - */ -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy)); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy))) -+ goto nla_put_failure; - - /* Before */ - nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_BEFORE); -@@ -7484,14 +7715,20 @@ static void nl80211_send_remain_on_chan_event( - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, channel_type); -- NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, channel_type)) -+ goto nla_put_failure; -+ if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) -+ goto nla_put_failure; - - if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL) -- NLA_PUT_U32(msg, NL80211_ATTR_DURATION, duration); -+ if (nla_put_u32(msg, NL80211_ATTR_DURATION, duration)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7561,8 +7798,10 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7632,9 +7871,12 @@ static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd, - return true; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) -+ goto nla_put_failure; - - err = genlmsg_end(msg, hdr); - if (err < 0) { -@@ -7682,10 +7924,14 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, - return -ENOMEM; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); -- NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_FRAME, len, buf)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7715,12 +7961,17 @@ void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); -- NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_FRAME, len, buf)) -+ goto nla_put_failure; -+ if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) -+ goto nla_put_failure; - if (ack) -- NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); -+ if (nla_put_flag(msg, NL80211_ATTR_ACK)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7752,15 +8003,18 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - - pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); - if (!pinfoattr) - goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT, -- rssi_event); -+ if (nla_put_u32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT, -+ rssi_event)) -+ goto nla_put_failure; - - nla_nest_end(msg, pinfoattr); - -@@ -7793,16 +8047,20 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) -+ goto nla_put_failure; - - rekey_attr = nla_nest_start(msg, NL80211_ATTR_REKEY_DATA); - if (!rekey_attr) - goto nla_put_failure; - -- NLA_PUT(msg, NL80211_REKEY_DATA_REPLAY_CTR, -- NL80211_REPLAY_CTR_LEN, replay_ctr); -+ if (nla_put(msg, NL80211_REKEY_DATA_REPLAY_CTR, -+ NL80211_REPLAY_CTR_LEN, replay_ctr)) -+ goto nla_put_failure; - - nla_nest_end(msg, rekey_attr); - -@@ -7835,17 +8093,22 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; - - attr = nla_nest_start(msg, NL80211_ATTR_PMKSA_CANDIDATE); - if (!attr) - goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_PMKSA_CANDIDATE_INDEX, index); -- NLA_PUT(msg, NL80211_PMKSA_CANDIDATE_BSSID, ETH_ALEN, bssid); -+ if (nla_put_u32(msg, NL80211_PMKSA_CANDIDATE_INDEX, index)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_PMKSA_CANDIDATE_BSSID, ETH_ALEN, bssid)) -+ goto nla_put_failure; - if (preauth) -- NLA_PUT_FLAG(msg, NL80211_PMKSA_CANDIDATE_PREAUTH); -+ if (nla_put_flag(msg, NL80211_PMKSA_CANDIDATE_PREAUTH)) -+ goto nla_put_failure; - - nla_nest_end(msg, attr); - -@@ -7877,9 +8140,12 @@ void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, type); -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, type)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - -@@ -7961,15 +8227,19 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, peer); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) -+ goto nla_put_failure; - - pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); - if (!pinfoattr) - goto nla_put_failure; - -- NLA_PUT_U32(msg, NL80211_ATTR_CQM_PKT_LOSS_EVENT, num_packets); -+ if (nla_put_u32(msg, NL80211_ATTR_CQM_PKT_LOSS_EVENT, num_packets)) -+ goto nla_put_failure; - - nla_nest_end(msg, pinfoattr); - -@@ -8003,12 +8273,17 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); -- NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); -- NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; -+ if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) -+ goto nla_put_failure; -+ if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie)) -+ goto nla_put_failure; - if (acked) -- NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); -+ if (nla_put_flag(msg, NL80211_ATTR_ACK)) -+ goto nla_put_failure; - - err = genlmsg_end(msg, hdr); - if (err < 0) { -@@ -8048,10 +8323,13 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy, - return; - } - -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx)) -+ goto nla_put_failure; - if (freq) -- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); -- NLA_PUT(msg, NL80211_ATTR_FRAME, len, frame); -+ if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) -+ goto nla_put_failure; -+ if (nla_put(msg, NL80211_ATTR_FRAME, len, frame)) -+ goto nla_put_failure; - - genlmsg_end(msg, hdr); - diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0002-atheros-update-renamed-struct-members.patch b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0002-atheros-update-renamed-struct-members.patch deleted file mode 100644 index 767bca0cf..000000000 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/0002-atheros-update-renamed-struct-members.patch +++ /dev/null @@ -1,235 +0,0 @@ -From: Javier Viguera -Date: Fri, 13 Sep 2013 11:12:04 +0200 -Subject: [PATCH] atheros: update renamed struct members - -struct genl_info: s/snd_pid/snd_portid -struct netlink_notify: s/pid/portid -struct netlink_skb_parms: s/pid/portid - -Signed-off-by: Javier Viguera ---- - compat-wireless/net/wireless/nl80211.c | 50 ++++++++++++++++---------------- - 1 file changed, 25 insertions(+), 25 deletions(-) - -diff --git a/compat-wireless/net/wireless/nl80211.c b/compat-wireless/net/wireless/nl80211.c -index c219a2ca027f..2cba63866a90 100644 ---- a/compat-wireless/net/wireless/nl80211.c -+++ b/compat-wireless/net/wireless/nl80211.c -@@ -1122,7 +1122,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb) - continue; - if (++idx <= start) - continue; -- if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).pid, -+ if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - dev) < 0) { - idx--; -@@ -1145,7 +1145,7 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- if (nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev) < 0) { -+ if (nl80211_send_wiphy(msg, info->snd_portid, info->snd_seq, 0, dev) < 0) { - nlmsg_free(msg); - return -ENOBUFS; - } -@@ -1590,7 +1590,7 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * - if_idx++; - continue; - } -- if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, -+ if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - rdev, wdev->netdev) < 0) { - mutex_unlock(&rdev->devlist_mtx); -@@ -1621,7 +1621,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, -+ if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, - dev, netdev) < 0) { - nlmsg_free(msg); - return -ENOBUFS; -@@ -1922,7 +1922,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_NEW_KEY); - if (IS_ERR(hdr)) - return PTR_ERR(hdr); -@@ -2628,7 +2628,7 @@ static int nl80211_dump_station(struct sk_buff *skb, - goto out_err; - - if (nl80211_send_station(skb, -- NETLINK_CB(cb->skb).pid, -+ NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - netdev, mac_addr, - &sinfo) < 0) -@@ -2674,7 +2674,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0, -+ if (nl80211_send_station(msg, info->snd_portid, info->snd_seq, 0, - dev, mac_addr, &sinfo) < 0) { - nlmsg_free(msg); - return -ENOBUFS; -@@ -3062,7 +3062,7 @@ static int nl80211_dump_mpath(struct sk_buff *skb, - if (err) - goto out_err; - -- if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid, -+ if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - netdev, dst, next_hop, - &pinfo) < 0) -@@ -3111,7 +3111,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0, -+ if (nl80211_send_mpath(msg, info->snd_portid, info->snd_seq, 0, - dev, dst, next_hop, &pinfo) < 0) { - nlmsg_free(msg); - return -ENOBUFS; -@@ -3337,7 +3337,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_GET_MESH_CONFIG); - if (!hdr) - goto out; -@@ -3612,7 +3612,7 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info) - goto out; - } - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_GET_REG); - if (!hdr) - goto put_failure; -@@ -4216,7 +4216,7 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, - - ASSERT_WDEV_LOCK(wdev); - -- hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).pid, seq, flags, -+ hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags, - NL80211_CMD_NEW_SCAN_RESULTS); - if (!hdr) - return -1; -@@ -4451,7 +4451,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, - } - - if (nl80211_send_survey(skb, -- NETLINK_CB(cb->skb).pid, -+ NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - netdev, - &survey) < 0) -@@ -5010,7 +5010,7 @@ static int nl80211_testmode_dump(struct sk_buff *skb, - } - - while (1) { -- void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).pid, -+ void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - NL80211_CMD_TESTMODE); - struct nlattr *tmdata; -@@ -5090,7 +5090,7 @@ struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, - return NULL; - - return __cfg80211_testmode_alloc_skb(rdev, approxlen, -- rdev->testmode_info->snd_pid, -+ rdev->testmode_info->snd_portid, - rdev->testmode_info->snd_seq, - GFP_KERNEL); - } -@@ -5427,7 +5427,7 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, - if (!msg) - return -ENOMEM; - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_REMAIN_ON_CHANNEL); - - if (IS_ERR(hdr)) { -@@ -5638,7 +5638,7 @@ static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) - if (!rdev->ops->mgmt_tx) - return -EOPNOTSUPP; - -- return cfg80211_mlme_register_mgmt(dev->ieee80211_ptr, info->snd_pid, -+ return cfg80211_mlme_register_mgmt(dev->ieee80211_ptr, info->snd_portid, - frame_type, - nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]), - nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH])); -@@ -5708,7 +5708,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_FRAME); - - if (IS_ERR(hdr)) { -@@ -5820,7 +5820,7 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_GET_POWER_SAVE); - if (!hdr) { - err = -ENOBUFS; -@@ -5998,7 +5998,7 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info) - if (!msg) - return -ENOMEM; - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_GET_WOWLAN); - if (!hdr) - goto nla_put_failure; -@@ -6281,7 +6281,7 @@ static int nl80211_register_unexpected_frame(struct sk_buff *skb, - if (wdev->ap_unexpected_nlpid) - return -EBUSY; - -- wdev->ap_unexpected_nlpid = info->snd_pid; -+ wdev->ap_unexpected_nlpid = info->snd_portid; - return 0; - } - -@@ -6311,7 +6311,7 @@ static int nl80211_probe_client(struct sk_buff *skb, - if (!msg) - return -ENOMEM; - -- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, -+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, - NL80211_CMD_PROBE_CLIENT); - - if (IS_ERR(hdr)) { -@@ -6349,7 +6349,7 @@ static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info) - if (rdev->ap_beacons_nlpid) - return -EBUSY; - -- rdev->ap_beacons_nlpid = info->snd_pid; -+ rdev->ap_beacons_nlpid = info->snd_portid; - - return 0; - } -@@ -8357,8 +8357,8 @@ static int nl80211_netlink_notify(struct notifier_block * nb, - - list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { - list_for_each_entry_rcu(wdev, &rdev->netdev_list, list) -- cfg80211_mlme_unregister_socket(wdev, notify->pid); -- if (rdev->ap_beacons_nlpid == notify->pid) -+ cfg80211_mlme_unregister_socket(wdev, notify->portid); -+ if (rdev->ap_beacons_nlpid == notify->portid) - rdev->ap_beacons_nlpid = 0; - } - diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/Makefile b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/Makefile deleted file mode 100644 index 260054a7a..000000000 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -ATH_DRV_BASEDIR := compat-wireless - -ifneq ($(KERNELRELEASE),) - -ATH_DEFINES += \ - -DCOMPAT_BASE_TREE="\"$(shell cat $(src)/$(ATH_DRV_BASEDIR)/compat_base_tree)\"" \ - -DCOMPAT_BASE_TREE_VERSION="\"$(shell cat $(src)/$(ATH_DRV_BASEDIR)/compat_base_tree_version)\"" \ - -DCOMPAT_PROJECT="\"Compat-wireless\"" \ - -DCOMPAT_VERSION="\"$(shell cat $(src)/$(ATH_DRV_BASEDIR)/compat_version)\"" - -NOSTDINC_FLAGS := -I$(M)/$(ATH_DRV_BASEDIR)/include/ \ - -include $(M)/$(ATH_DRV_BASEDIR)/include/linux/compat-2.6.h \ - $(ATH_DEFINES) - -include $(src)/$(ATH_DRV_BASEDIR)/config.mk - -SHELL_EXPORT := PATH=$(src)/$(ATH_DRV_BASEDIR)/scripts:$${PATH} \ - COMPAT_CONFIG=$(src)/$(ATH_DRV_BASEDIR)/config.mk \ - CONFIG_CHECK=.$(COMPAT_CONFIG)_md5sum.txt \ - COMPAT_AUTOCONF=$(src)/$(ATH_DRV_BASEDIR)/include/linux/compat_autoconf.h - -dummy := $(shell $(SHELL_EXPORT) bash -c "cd $(src)/$(ATH_DRV_BASEDIR) && ./scripts/check_config.sh || true") - -obj-y := $(ATH_DRV_BASEDIR)/compat/ -obj-y += $(ATH_DRV_BASEDIR)/net/wireless/ -obj-y += $(ATH_DRV_BASEDIR)/drivers/net/wireless/ath/ath6kl/ - -else #ifneq ($(KERNELRELEASE),) - -SRC := $(shell pwd) - -all: - $(MAKE) -C $(KERNEL_SRC) M=$(SRC) - -modules_install: - $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install - # Fix installation directory of the modules. - find $(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/extra/$(ATH_DRV_BASEDIR) -type f -name '*.ko' | \ - xargs -I modfile mv -f modfile $(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/extra/ - rm -rf $(INSTALL_MOD_PATH)/lib/modules/*/extra/$(ATH_DRV_BASEDIR) - -endif #ifneq ($(KERNELRELEASE),) diff --git a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/atheros-pre-up b/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/atheros-pre-up deleted file mode 100644 index 78e776de3..000000000 --- a/meta-digi-arm/recipes-kernel/kernel-module-atheros/kernel-module-atheros/atheros-pre-up +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/sh -#=============================================================================== -# -# 10-atheros_pre-up -# -# Copyright (C) 2012 by Digi International Inc. -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# -# !Description: Load Atheros' wireless driver -# -#=============================================================================== - -set -e - -[ "${IFACE}" != "wlan0" ] && exit 0 - -FIRMWARE_DIR="/lib/firmware/ath6k/AR6003/hw2.1.1" - -ATH6KL_DBG_NONE=0x0 -ATH6KL_DBG_CREDIT=0x00000001 -ATH6KL_DBG_WLAN_TX=0x00000004 -ATH6KL_DBG_WLAN_RX=0x00000008 -ATH6KL_DBG_BMI=0x00000010 -ATH6KL_DBG_HTC=0x00000020 -ATH6KL_DBG_HIF=0x00000040 -ATH6KL_DBG_IRQ=0x00000080 -ATH6KL_DBG_WMI=0x00000400 -ATH6KL_DBG_TRC=0x00000800 -ATH6KL_DBG_SCATTER=0x00001000 -ATH6KL_DBG_WLAN_CFG=0x00002000 -ATH6KL_DBG_RAW_BYTES=0x00004000 -ATH6KL_DBG_AGGR=0x00008000 -ATH6KL_DBG_SDIO=0x00010000 -ATH6KL_DBG_SDIO_DUMP=0x00020000 -ATH6KL_DBG_BOOT=0x00040000 -ATH6KL_DBG_WMI_DUMP=0x00080000 -ATH6KL_DBG_SUSPEND=0x00100000 -ATH6KL_DBG_USB=0x00200000 -ATH6KL_DBG_RECOVERY=0x00400000 -ATH6KL_DBG_ANY=0xffffffff - -ATH6KL_DEBUG_MASK="${ATH6KL_DBG_NONE}" - -# -# Get the wlan MAC address from kernel command line. Use a default -# value if the address has not been set. -# -if [ -f "/proc/device-tree/wireless/mac-address" ]; then - MAC_ADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/wireless/mac-address | sed 's/:$//g')" -else - MAC_ADDR="$(sed -ne 's,^.*ethaddr2=\([^[:blank:]]\+\)[:blank:]*.*,\1,g;T;p' /proc/cmdline)" -fi -if [ -z "${MAC_ADDR}" -o "${MAC_ADDR}" = "00:00:00:00:00:00" ]; then - MAC_ADDR="00:04:F3:4C:B1:D3" -fi - -# We need to write the WLAN MAC address to softmac in the ath6k firmware -# directory. However, we don't want to rewrite the file if it already exists -# and the address is the same because we don't want to wear out NAND flash. -# -# So create the file on the RAM DRIVE first and compare the two. Only update -# the copy on NAND if the address has changed. -# -mac1="$(echo ${MAC_ADDR} | cut -d':' -f1)" -mac2="$(echo ${MAC_ADDR} | cut -d':' -f2)" -mac3="$(echo ${MAC_ADDR} | cut -d':' -f3)" -mac4="$(echo ${MAC_ADDR} | cut -d':' -f4)" -mac5="$(echo ${MAC_ADDR} | cut -d':' -f5)" -mac6="$(echo ${MAC_ADDR} | cut -d':' -f6)" - -TMP_MACFILE="$(mktemp -t softmac.XXXXXX)" -printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${TMP_MACFILE} -if ! cmp -s ${TMP_MACFILE} ${FIRMWARE_DIR}/softmac; then - cp ${TMP_MACFILE} ${FIRMWARE_DIR}/softmac -fi -rm -f ${TMP_MACFILE} - -# Figure out which wireless region we are in. The US has rules for -# what channels can be used and at what power level. We use a different set of -# rules for the other regions in the world that we sell into. The mod_cert field -# in OTP will be set to 0x0 for the US. Once we know the region, make sure the -# appropriate calibration file is loaded. -# -MACHINE="$(cat /proc/device-tree/digi,machine,name 2>/dev/null || \ - cat /sys/kernel/machine/name)" -MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant 2>/dev/null || \ - cat /sys/kernel/${MACHINE}/mod_variant)" -REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null || \ - cat /sys/kernel/${MACHINE}/mod_cert)" - -# 'ccimx6sbc' variants 0x05, 0x07 and 0x0a do not have bluetooth -# and use a different calibration file -US_CODE="0x0" -case "${MACHINE}:${MOD_VARIANT}:${REGION_CODE}" in - ccimx6sbc:0x05:${US_CODE}|ccimx6sbc:0x07:${US_CODE}|ccimx6sbc:0x0a:${US_CODE}) - BDATA_SOURCE="Digi_6203_2_ANT-US.bin" - logger -t atheros "Setting US wireless region (no bluetooth)";; - ccimx6sbc:0x05:*|ccimx6sbc:0x07:*|ccimx6sbc:0x0a:*) - BDATA_SOURCE="Digi_6203_2_ANT-World.bin" - logger -t atheros "Setting non-US (world) wireless region (no bluetooth)";; - *:*:${US_CODE}) - BDATA_SOURCE="Digi_6203-6233-US.bin" - logger -t atheros "Setting US wireless region";; - *:*:*) - BDATA_SOURCE="Digi_6203-6233-World.bin" - logger -t atheros "Setting non-US (world) wireless region";; -esac - -# We don't want to rewrite NAND every time we boot so only -# change the link if it is wrong. -BDATA_LINK="${FIRMWARE_DIR}/bdata.bin" -if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${FIRMWARE_DIR}/${BDATA_SOURCE}"; then - ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}" -fi - -# Load 'cfg80211' and let it settle down (needed by 'ath6kl_sdio') -modprobe -q cfg80211 && sleep 0.2 - -# ath6kl_sdio.ko -if ! grep -qs ath6kl_sdio /proc/modules; then - RETRIES="5" - while [ "${RETRIES}" -gt "0" ]; do - modprobe --ignore-install -q ath6kl_sdio debug_mask="${ATH6KL_DEBUG_MASK}" || true - [ -d "/sys/class/net/wlan0" ] && break - RETRIES="$((RETRIES - 1))" - rmmod ath6kl_sdio > /dev/null - echo "Retrying to load wireless" - sleep 2 - done - [ "${RETRIES}" -eq "0" ] && echo "Loading ath6kl_sdio module: [FAILED]" -fi - -# Delay required for the interface 'wlan0' to settle down before trying to configure it. -sleep 0.5 diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey-3.10/ccardimx28js/defconfig b/meta-digi-arm/recipes-kernel/linux/linux-dey-3.10/ccardimx28js/defconfig deleted file mode 100644 index 2699f0629..000000000 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey-3.10/ccardimx28js/defconfig +++ /dev/null @@ -1,212 +0,0 @@ -# CONFIG_SWAP is not set -CONFIG_SYSVIPC=y -CONFIG_NO_HZ=y -CONFIG_HIGH_RES_TIMERS=y -CONFIG_IKCONFIG=y -CONFIG_IKCONFIG_PROC=y -# CONFIG_UTS_NS is not set -# CONFIG_IPC_NS is not set -# CONFIG_PID_NS is not set -# CONFIG_NET_NS is not set -CONFIG_RELAY=y -CONFIG_BLK_DEV_INITRD=y -CONFIG_PERF_EVENTS=y -# CONFIG_COMPAT_BRK is not set -CONFIG_MODULES=y -CONFIG_MODULE_FORCE_LOAD=y -CONFIG_MODULE_UNLOAD=y -CONFIG_MODVERSIONS=y -CONFIG_BLK_DEV_INTEGRITY=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set -# CONFIG_ARCH_MULTI_V7 is not set -CONFIG_ARCH_MXS=y -# CONFIG_ARM_THUMB is not set -CONFIG_PREEMPT_VOLUNTARY=y -CONFIG_AEABI=y -CONFIG_CPU_FREQ=y -CONFIG_CPU_FREQ_GOV_POWERSAVE=y -CONFIG_CPU_FREQ_GOV_USERSPACE=y -CONFIG_CPU_FREQ_GOV_ONDEMAND=y -CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y -CONFIG_FPE_NWFPE=y -CONFIG_NET=y -CONFIG_PACKET=y -CONFIG_UNIX=y -CONFIG_INET=y -CONFIG_IP_PNP=y -CONFIG_IP_PNP_DHCP=y -CONFIG_SYN_COOKIES=y -# CONFIG_INET_XFRM_MODE_TRANSPORT is not set -# CONFIG_INET_XFRM_MODE_TUNNEL is not set -# CONFIG_INET_XFRM_MODE_BEET is not set -# CONFIG_INET_LRO is not set -# CONFIG_INET_DIAG is not set -# CONFIG_IPV6 is not set -CONFIG_BRIDGE=y -CONFIG_NET_SCHED=y -CONFIG_CAN=y -# CONFIG_CAN_GW is not set -CONFIG_CAN_FLEXCAN=y -CONFIG_BT=y -CONFIG_BT_RFCOMM=y -CONFIG_BT_RFCOMM_TTY=y -CONFIG_BT_BNEP=y -CONFIG_BT_BNEP_MC_FILTER=y -CONFIG_BT_BNEP_PROTO_FILTER=y -CONFIG_BT_HIDP=y -CONFIG_BT_HCIUART=y -CONFIG_BT_HCIUART_ATH3K=y -CONFIG_WIRELESS_EXT=y -CONFIG_RFKILL=y -CONFIG_DEVTMPFS=y -CONFIG_DEVTMPFS_MOUNT=y -# CONFIG_FIRMWARE_IN_KERNEL is not set -# CONFIG_FW_LOADER_USER_HELPER is not set -CONFIG_MTD=y -CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_BLOCK=y -CONFIG_MTD_SST25L=y -CONFIG_MTD_NAND=y -CONFIG_MTD_NAND_GPMI_NAND=y -CONFIG_MTD_UBI=y -CONFIG_PROC_DEVICETREE=y -CONFIG_BLK_DEV_LOOP=y -CONFIG_BLK_DEV_RAM=y -CONFIG_BLK_DEV_RAM_SIZE=16384 -CONFIG_SRAM=y -CONFIG_EEPROM_AT24=y -CONFIG_SCSI=y -CONFIG_BLK_DEV_SD=y -# CONFIG_SCSI_LOWLEVEL is not set -CONFIG_NETDEVICES=y -# CONFIG_NET_CADENCE is not set -# CONFIG_NET_VENDOR_BROADCOM is not set -# CONFIG_NET_VENDOR_CIRRUS is not set -# CONFIG_NET_VENDOR_FARADAY is not set -# CONFIG_NET_VENDOR_INTEL is not set -# CONFIG_NET_VENDOR_MARVELL is not set -# CONFIG_NET_VENDOR_MICREL is not set -# CONFIG_NET_VENDOR_MICROCHIP is not set -# CONFIG_NET_VENDOR_NATSEMI is not set -# CONFIG_NET_VENDOR_SEEQ is not set -# CONFIG_NET_VENDOR_SMSC is not set -# CONFIG_NET_VENDOR_STMICRO is not set -# CONFIG_NET_VENDOR_WIZNET is not set -CONFIG_SMSC_PHY=y -CONFIG_ICPLUS_PHY=y -CONFIG_REALTEK_PHY=y -CONFIG_MICREL_PHY=y -CONFIG_USB_USBNET=y -CONFIG_USB_NET_SMSC95XX=y -# CONFIG_WLAN is not set -# CONFIG_INPUT_MOUSEDEV_PSAUX is not set -CONFIG_INPUT_EVDEV=y -# CONFIG_KEYBOARD_ATKBD is not set -CONFIG_KEYBOARD_MXS_PSWITCH=y -# CONFIG_INPUT_MOUSE is not set -# CONFIG_SERIO is not set -CONFIG_VT_HW_CONSOLE_BINDING=y -CONFIG_DEVPTS_MULTIPLE_INSTANCES=y -# CONFIG_LEGACY_PTYS is not set -# CONFIG_DEVKMEM is not set -CONFIG_SERIAL_AMBA_PL011=y -CONFIG_SERIAL_AMBA_PL011_CONSOLE=y -CONFIG_SERIAL_MXS_AUART=y -# CONFIG_HW_RANDOM is not set -CONFIG_I2C=y -# CONFIG_I2C_COMPAT is not set -CONFIG_I2C_CHARDEV=y -CONFIG_I2C_MXS=y -CONFIG_SPI=y -CONFIG_SPI_GPIO=y -CONFIG_SPI_MXS=y -CONFIG_SPI_SPIDEV=y -CONFIG_GPIO_SYSFS=y -CONFIG_W1=y -CONFIG_W1_MASTER_DS2482=y -CONFIG_W1_SLAVE_DS2431=y -# CONFIG_HWMON is not set -CONFIG_WATCHDOG=y -CONFIG_STMP3XXX_RTC_WATCHDOG=y -CONFIG_REGULATOR=y -CONFIG_REGULATOR_FIXED_VOLTAGE=y -CONFIG_FB=y -CONFIG_FB_MXS=y -CONFIG_BACKLIGHT_LCD_SUPPORT=y -CONFIG_LCD_CLASS_DEVICE=y -CONFIG_BACKLIGHT_CLASS_DEVICE=y -CONFIG_BACKLIGHT_PWM=y -CONFIG_FRAMEBUFFER_CONSOLE=y -CONFIG_FONTS=y -CONFIG_LOGO=y -CONFIG_FB_LOGO_CENTERED=y -CONFIG_SOUND=y -CONFIG_SND=y -CONFIG_SND_MIXER_OSS=y -CONFIG_SND_PCM_OSS=y -CONFIG_SND_DYNAMIC_MINORS=y -# CONFIG_SND_DRIVERS is not set -# CONFIG_SND_ARM is not set -# CONFIG_SND_SPI is not set -# CONFIG_SND_USB is not set -CONFIG_SND_SOC=y -CONFIG_SND_MXS_SOC=y -CONFIG_SND_SOC_MXS_SGTL5000=y -CONFIG_USB=y -CONFIG_USB_EHCI_HCD=y -CONFIG_USB_STORAGE=y -CONFIG_USB_CHIPIDEA=y -CONFIG_USB_CHIPIDEA_UDC=y -CONFIG_USB_CHIPIDEA_HOST=y -CONFIG_USB_PHY=y -CONFIG_USB_MXS_PHY=y -CONFIG_USB_GADGET=y -CONFIG_USB_ETH=m -CONFIG_USB_MASS_STORAGE=m -CONFIG_USB_G_SERIAL=m -CONFIG_MMC=y -CONFIG_MMC_UNSAFE_RESUME=y -CONFIG_MMC_MXS=y -CONFIG_RTC_CLASS=y -CONFIG_RTC_DRV_STMP=y -CONFIG_DMADEVICES=y -CONFIG_MXS_DMA=y -CONFIG_STAGING=y -CONFIG_MXS_LRADC=y -CONFIG_IIO_SYSFS_TRIGGER=y -CONFIG_COMMON_CLK_DEBUG=y -CONFIG_IIO=y -CONFIG_PWM=y -CONFIG_PWM_MXS=y -CONFIG_EXT2_FS=y -CONFIG_EXT2_FS_XATTR=y -CONFIG_EXT3_FS=y -CONFIG_EXT4_FS=y -# CONFIG_DNOTIFY is not set -CONFIG_VFAT_FS=y -CONFIG_TMPFS=y -CONFIG_TMPFS_POSIX_ACL=y -CONFIG_JFFS2_FS=y -CONFIG_JFFS2_COMPRESSION_OPTIONS=y -CONFIG_JFFS2_LZO=y -CONFIG_JFFS2_RUBIN=y -CONFIG_UBIFS_FS=y -CONFIG_UBIFS_FS_ADVANCED_COMPR=y -CONFIG_NFS_FS=y -CONFIG_NFS_V3_ACL=y -CONFIG_NFS_V4=y -CONFIG_ROOT_NFS=y -CONFIG_NLS_CODEPAGE_437=y -CONFIG_NLS_CODEPAGE_850=y -CONFIG_NLS_ISO8859_1=y -CONFIG_NLS_ISO8859_15=y -CONFIG_PRINTK_TIME=y -CONFIG_FRAME_WARN=2048 -CONFIG_UNUSED_SYMBOLS=y -CONFIG_DEBUG_KERNEL=y -# CONFIG_FTRACE is not set -# CONFIG_ARM_UNWIND is not set -# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set -# CONFIG_CRYPTO_ANSI_CPRNG is not set -# CONFIG_CRYPTO_HW is not set diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_3.10.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_3.10.bb deleted file mode 100644 index 6d7e0ec69..000000000 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey_3.10.bb +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2012 Digi International - -require recipes-kernel/linux/linux-dey.inc -require recipes-kernel/linux/linux-dtb.inc - -SRCBRANCH = "v3.10/dey-1.4/maint" -SRCREV = "${AUTOREV}" - -config_dts() { - for DTB in ${KERNEL_DEVICETREE}; do - if [ "${1}" = "enable" ]; then - sed -i -e "/${2}/{s,^///include,/include,g}" ${S}/arch/arm/boot/dts/${DTB%b}s - elif [ "${1}" = "disable" ]; then - sed -i -e "/${2}/{s,^/include,///include,g}" ${S}/arch/arm/boot/dts/${DTB%b}s - fi - done -} - -do_update_dts() { - if [ -n "${HAVE_WIFI}" ]; then - config_dts enable '_ssp2_mmc_wifi.dtsi' - else - config_dts disable '_ssp2_mmc_wifi.dtsi' - fi - if [ -n "${HAVE_SECOND_ETH}" ]; then - config_dts enable '_ethernet1.dtsi' - else - config_dts disable '_ethernet1.dtsi' - fi - if [ -n "${HAVE_BT}" ]; then - config_dts enable '_auart0_bluetooth.dtsi' - else - config_dts disable '_auart0_bluetooth.dtsi' - fi - if [ -n "${HAVE_1WIRE}" ]; then - config_dts enable '_onewire_i2c1.dtsi' - config_dts disable '_auart2_4wires.dtsi' - else - config_dts disable '_onewire_i2c1.dtsi' - fi - if [ -n "${HAVE_GUI}" ]; then - # Enable LCD - config_dts enable '_display_' - config_dts disable '_auart1_' - # Enable touch - config_dts enable '_lradc_touchscreen' - config_dts disable '_ssp1_' - config_dts disable '_auart1_4wires' - config_dts disable '_ethernet0_leds' - else - # spidev conflicts with touchscreen, thus enable it only - # when touch is disabled - if [ -n "${HAVE_EXAMPLE}" ]; then - config_dts enable 'ssp1_spi_gpio.dtsi' - config_dts enable 'ssp1_spi_gpio_spidev.dtsi' - fi - fi -} -addtask update_dts before do_install after do_sizecheck - -COMPATIBLE_MACHINE = "(ccardimx28)" diff --git a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0001-enable-libnl3.patch b/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0001-enable-libnl3.patch deleted file mode 100644 index 1cd5ac29c..000000000 --- a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0001-enable-libnl3.patch +++ /dev/null @@ -1,74 +0,0 @@ -From: Javier Viguera -Date: Thu, 31 Jan 2013 11:23:37 +0100 -Subject: [PATCH] enable-libnl3 - -Signed-off-by: Javier Viguera ---- - Makefile | 7 ++++++- - nl80211_utils.c | 4 ++-- - nl80211_utils.h | 2 +- - 3 files changed, 9 insertions(+), 4 deletions(-) - -diff --git a/Makefile b/Makefile -index 115ad33..6c21413 100644 ---- a/Makefile -+++ b/Makefile -@@ -56,17 +56,22 @@ LIBS= -ldbus-1 -lpthread -lrt -lbluetooth - - NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) - NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y) -+NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y) - - ifeq ($(NL1FOUND),Y) -+CFLAGS += -DCONFIG_LIBNL1 - NLLIBNAME = libnl-1 - endif - - ifeq ($(NL2FOUND),Y) --CFLAGS += -DCONFIG_LIBNL20 - LIBS += -lnl-genl - NLLIBNAME = libnl-2.0 - endif - -+ifeq ($(NL3FOUND),Y) -+NLLIBNAME = libnl-3.0 -+endif -+ - #ifeq ($(NLLIBNAME),) - #$(error Cannot find development files for any supported version of libnl) - #endif -diff --git a/nl80211_utils.c b/nl80211_utils.c -index 4689044..2957f2e 100644 ---- a/nl80211_utils.c -+++ b/nl80211_utils.c -@@ -9,7 +9,7 @@ - #include - #include "nl80211_utils.h" - --#ifndef CONFIG_LIBNL20 -+#ifdef CONFIG_LIBNL1 - /* libnl 2.0 compatibility code */ - - static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct nl_cache **cache) -@@ -24,7 +24,7 @@ static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct nl_cache **c - #define nl_socket_alloc nl_handle_alloc - #define nl_socket_free nl_handle_destroy - --#endif /* CONFIG_LIBNL20 */ -+#endif /* CONFIG_LIBNL1 */ - - int iw_debug = 0; - -diff --git a/nl80211_utils.h b/nl80211_utils.h -index 6a0dbd7..6bbeb2c 100644 ---- a/nl80211_utils.h -+++ b/nl80211_utils.h -@@ -11,7 +11,7 @@ - #include - #include - --#ifndef CONFIG_LIBNL20 -+#ifdef CONFIG_LIBNL1 - #define nl_sock nl_handle - #endif - diff --git a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0002-cross-compile.patch b/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0002-cross-compile.patch deleted file mode 100644 index 98b1a3aac..000000000 --- a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0002-cross-compile.patch +++ /dev/null @@ -1,85 +0,0 @@ -From: Javier Viguera -Date: Tue, 16 Apr 2013 18:46:31 +0200 -Subject: [PATCH] cross-compile - -Signed-off-by: Javier Viguera ---- - Makefile | 43 +++++++++++++++++++++++++++---------------- - 1 file changed, 27 insertions(+), 16 deletions(-) - -diff --git a/Makefile b/Makefile -index 6c21413..91659dd 100644 ---- a/Makefile -+++ b/Makefile -@@ -25,13 +25,13 @@ SBINDIR ?= $(PREFIX)/sbin - MANDIR ?= $(PREFIX)/share/man - - PKG_CONFIG ?= pkg-config --ifdef V210 --CC= $(ATH_CROSS_COMPILE_TYPE)gcc --LD= $(ATH_CROSS_COMPILE_TYPE)ld --else --CC= $(ATH_CROSSS_COMPILE_TYPE)gcc --LD= $(ATH_CROSSS_COMPILE_TYPE)ld --endif -+# ifdef V210 -+# CC= $(ATH_CROSS_COMPILE_TYPE)gcc -+# LD= $(ATH_CROSS_COMPILE_TYPE)ld -+# else -+# CC= $(ATH_CROSSS_COMPILE_TYPE)gcc -+# LD= $(ATH_CROSSS_COMPILE_TYPE)ld -+# endif - SOURCES=abtfilt_main.c \ - abtfilt_wlan.c \ - abtfilt_core.c \ -@@ -40,19 +40,19 @@ SOURCES=abtfilt_main.c \ - nl80211_utils.c\ - btfilter_core.c - --INCLUDES= -Iinclude \ -+override INCLUDES += -Iinclude \ - -Ios/linux/include \ -- -Icommon/include \ -- -I$(V210_DIR)/usr/include/dbus-1.0/ \ -- -I$(V210_DIR)/usr/lib/dbus-1.0/include \ -- -I$(V210_DIR)/usr/local/include/dbus-1.0 \ -- -I$(V210_DIR)/usr/local/lib/dbus-1.0/include \ -- -I$(V210_DIR)/usr/include/bluetooth \ -- -I$(V210_DIR)/usr/local/include/bluetooth \ -+ -Icommon/include -+# -I$(V210_DIR)/usr/include/dbus-1.0/ \ -+# -I$(V210_DIR)/usr/lib/dbus-1.0/include \ -+# -I$(V210_DIR)/usr/local/include/dbus-1.0 \ -+# -I$(V210_DIR)/usr/local/lib/dbus-1.0/include \ -+# -I$(V210_DIR)/usr/include/bluetooth \ -+# -I$(V210_DIR)/usr/local/include/bluetooth \ - - CFLAGS= -Wall -g -DABF_DEBUG - #LIBS= -ldbus-1 -lpthread -lbtfilt -lrt -lbluetooth --LIBS= -ldbus-1 -lpthread -lrt -lbluetooth -+# LIBS= -ldbus-1 -lpthread -lrt -lbluetooth - - NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y) - NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y) -@@ -79,6 +79,13 @@ endif - LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME)) - CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME)) - -+# dbus -+LIBS += $(shell $(PKG_CONFIG) --libs --static dbus-1) -+CFLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1) -+ -+# BlueZ -+LIBS += $(shell $(PKG_CONFIG) --libs bluez) -+CFLAGS += $(shell $(PKG_CONFIG) --cflags bluez) - - ifdef BOARD_HAS_ATH_WLAN_AR6004 - CFLAGS += -DMULTI_WLAN_CHAN_SUPPORT -@@ -124,3 +131,7 @@ all: $(OBJECTS) - - clean: - rm -f $(FILTERAPP) $(OBJECTS) -+ -+install: -+ mkdir -p $(DESTDIR)$(SBINDIR) -+ install -m 0755 $(FILTERAPP) $(DESTDIR)$(SBINDIR) diff --git a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0003-abtfilt_wan-Rewrite-the-netlink-listener.patch b/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0003-abtfilt_wan-Rewrite-the-netlink-listener.patch deleted file mode 100644 index 955fe6df7..000000000 --- a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0003-abtfilt_wan-Rewrite-the-netlink-listener.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 641f02fe3638d291a0ef53c076bda7e68e2f7d28 Mon Sep 17 00:00:00 2001 -From: Alex Gonzalez -Date: Tue, 26 Aug 2014 16:57:14 +0200 -Subject: [PATCH] abtfilt_wan: Rewrite the netlink listener. - -Not sure how old this code is but it is not working properly any more. - -Not only it incorrectly detects the netlink messages as corrupted, but it -also assumes an RTM_DELLINK will be issued for the link down event which -is not correct. - -I have updated the code trying to touch as little things as possible. - -Signed-off-by: Alex Gonzalez ---- - abtfilt_wlan.c | 87 +++++++++++++++++++++++++++++++++++++--------------------- - 1 file changed, 56 insertions(+), 31 deletions(-) - -diff --git a/abtfilt_wlan.c b/abtfilt_wlan.c -index b1966cef7ef2..64dffde37f19 100644 ---- a/abtfilt_wlan.c -+++ b/abtfilt_wlan.c -@@ -232,6 +232,59 @@ Abf_WlanDispatchIO(ATHBT_FILTER_INFO *pInfo, unsigned long int req, - return A_OK; - } - -+static void -+print_link(struct ifinfomsg *ifi, int len, int up) -+{ -+ struct rtattr *attrib; -+ -+ for(attrib = IFLA_RTA(ifi); RTA_OK(attrib, len); -+ attrib = RTA_NEXT(attrib, len)) { -+ switch(attrib->rta_type) { -+ case IFLA_IFNAME: -+ A_DEBUG("[%d:%s] Link %s\n", ifi->ifi_index, -+ (char *)RTA_DATA(attrib), up ? "UP" : "DOWN"); -+ break; -+ default: -+ break; -+ } -+ } -+} -+ -+static void -+parse_message(ATH_BT_FILTER_INSTANCE *pInstance, int len, char *buf) -+{ -+ struct nlmsghdr *msg_ptr; -+ struct ifinfomsg *ifi; -+ int len1; -+ -+ for(msg_ptr = (struct nlmsghdr *)buf; NLMSG_OK(msg_ptr, len); -+ msg_ptr = NLMSG_NEXT(msg_ptr, len)) { -+ /* Finish reading */ -+ if(msg_ptr->nlmsg_type == NLMSG_DONE) -+ break; -+ -+ /* Message is some kind of error */ -+ if(msg_ptr->nlmsg_type == NLMSG_ERROR) { -+ A_ERR("Message is an error.\n"); -+ break; -+ } -+ -+ if(msg_ptr->nlmsg_type == RTM_NEWLINK) { -+ ifi = NLMSG_DATA(msg_ptr); -+ len1 = msg_ptr->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi)); -+ if(ifi->ifi_flags & IFF_RUNNING){ -+ print_link(ifi, len1, 1); -+ NewLinkEvent(pInstance, msg_ptr, len1); -+ } -+ else { -+ print_link(ifi, len1, 0); -+ DelLinkEvent(pInstance, msg_ptr, len1); -+ } -+ break; -+ } -+ } -+} -+ - /* Internal functions */ - static void * - WlanEventThread(void *arg) -@@ -322,41 +375,13 @@ WlanEventThread(void *arg) - } while (left == -1 && errno == EINTR); - - if (left < 0) { -- A_ERR("[%s] recvfrom(netlink)\n", __FUNCTION__); -+ A_ERR("[%s] recvfrom(netlink) error %d\n", __FUNCTION__, -+ left); - continue; - // break; - } - -- h = (struct nlmsghdr *) buf; -- while (left >= (int)sizeof(*h)) { -- int len, plen; -- -- len = h->nlmsg_len; -- plen = len - sizeof(*h); -- if (len > left || plen < 0) { -- A_ERR("[%s] malformed netlink message\n", __FUNCTION__); -- continue; -- } -- -- //A_DEBUG("RTM Message Type: %s\n", -- // ((h->nlmsg_type == RTM_NEWLINK) ? -- // "RTM_NEWLINK" : ((h->nlmsg_type == RTM_DELLINK) ? -- // "RTM_DELLINK" : "RTM_OTHER"))); -- switch (h->nlmsg_type) { -- case RTM_NEWLINK: -- NewLinkEvent(pInstance, h, plen); -- break; -- case RTM_DELLINK: -- DelLinkEvent(pInstance, h, plen); -- break; -- default: -- break; -- } -- -- len = NLMSG_ALIGN(len); -- left -= len; -- h = (struct nlmsghdr *) ((char *) h + len); -- } -+ parse_message(pInstance, left, buf); - } - } - diff --git a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0004-add-fgnu89-flag-for-gcc5.patch b/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0004-add-fgnu89-flag-for-gcc5.patch deleted file mode 100644 index ee131ad1b..000000000 --- a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/0004-add-fgnu89-flag-for-gcc5.patch +++ /dev/null @@ -1,29 +0,0 @@ -From d631ddd830cfacf610a562b52fc953b14dff7962 Mon Sep 17 00:00:00 2001 -From: Isaac Hermida -Date: Fri, 6 Nov 2015 17:46:33 +0100 -Subject: [PATCH] add -fgnu89-inline flag for gcc5 - -The problem is the change of the default C standard from gnu89 to gnu11 - which changes the semantics of 'inline'. The issue is described in the - Porting guide at https://gcc.gnu.org/gcc-5/porting_to.html. - ---- - Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index 91659ddb788c..1e2e1d6b0584 100644 ---- a/Makefile -+++ b/Makefile -@@ -50,7 +50,7 @@ override INCLUDES += -Iinclude \ - # -I$(V210_DIR)/usr/include/bluetooth \ - # -I$(V210_DIR)/usr/local/include/bluetooth \ - --CFLAGS= -Wall -g -DABF_DEBUG -+CFLAGS= -Wall -g -DABF_DEBUG -fgnu89-inline - #LIBS= -ldbus-1 -lpthread -lbtfilt -lrt -lbluetooth - # LIBS= -ldbus-1 -lpthread -lrt -lbluetooth - --- -1.9.1 - diff --git a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/btfilter-init b/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/btfilter-init deleted file mode 100755 index 530a125ce..000000000 --- a/meta-digi-dey/recipes-connectivity/btfilter/btfilter-v3.4p4-b3.4.0.158/btfilter-init +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -#=============================================================================== -# -# btfilter -# -# Copyright (C) 2015 by Digi International Inc. -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# -# !Description: Configure Bluetooth -# -#=============================================================================== - -set -e - -if [ "${1}" != "start" ]; then - exit 0 -fi - -SCRIPTNAME="$(basename "${0}")" - -# Check if this hardware does support Bluetooth -if [ -d "/proc/device-tree/bluetooth" ]; then - echo "Starting btfilter service." - if ! abtfilt -b -x -s -w wlan0 1>/dev/null; then - echo "${SCRIPTNAME}: FAILED (abtfilt)" - exit - fi -fi diff --git a/meta-digi-dey/recipes-connectivity/btfilter/btfilter_v3.4p4-b3.4.0.158.bb b/meta-digi-dey/recipes-connectivity/btfilter/btfilter_v3.4p4-b3.4.0.158.bb deleted file mode 100644 index a381020d2..000000000 --- a/meta-digi-dey/recipes-connectivity/btfilter/btfilter_v3.4p4-b3.4.0.158.bb +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2013 Digi International. - -SUMMARY = "Atheros BT/wlan coexistance daemon" -SECTION = "network" -LICENSE = "ISC" -LIC_FILES_CHKSUM = "file://Makefile;beginline=1;endline=14;md5=8f6614b37751445a5f6a9bdc69be26b3" - -inherit bluetooth -inherit update-rc.d - -DEPENDS = "${BLUEZ} dbus libnl" - -SRC_URI = " \ - ${DIGI_PKG_SRC}/${PN}-${PV}.tar.bz2 \ - file://0001-enable-libnl3.patch \ - file://0002-cross-compile.patch \ - file://0003-abtfilt_wan-Rewrite-the-netlink-listener.patch \ - file://0004-add-fgnu89-flag-for-gcc5.patch \ - file://btfilter-init \ -" - -SRC_URI[md5sum] = "06a26d3a368c33b508d660ea84d476ee" -SRC_URI[sha256sum] = "b1af73003b622189b66d51911d429d6d205ac9227ec8278c8572ca0c68c7d5f3" - -EXTRA_OEMAKE = "INCLUDES=-I${STAGING_INCDIR}/bluetooth" - -do_install() { - install -d ${D}${bindir} ${D}${sysconfdir}/init.d/ - install -m 0755 abtfilt ${D}${bindir} - install -m 0755 ${WORKDIR}/btfilter-init ${D}${sysconfdir}/init.d/btfilter -} - -INITSCRIPT_NAME = "btfilter" -INITSCRIPT_PARAMS = "start 11 5 ."