summaryrefslogtreecommitdiffstats
path: root/polycom_xmit/util.c
blob: 1d44f3de55529cf8094b82027a3c8aef2052ddd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "project.h"


ICACHE_FLASH_ATTR char *
bounded_strstr (char *haystack, uint32_t len, char *needle)
{
  char *end = haystack + len;
  char *hptr, *nptr;

  if (!*needle)
    return NULL;

  for (; (*haystack) && (haystack < end); ++haystack)
    {

      hptr = haystack;
      nptr = needle;

      while ((*hptr) == (*nptr))
        {
          nptr++;
          hptr++;
          if (!*nptr)
            return haystack;
          if (hptr >= end)
            return NULL;
        }
    }

  return NULL;
}


bool
util_isspace (char c)
{
  switch (c)
    {
    case ' ':
    case '\r':
    case '\t':
    case '\n':
      return true;
    default:
      return false;
    }
}

ICACHE_FLASH_ATTR void
crash (void)
{
  char *c = NULL;

  os_printf ("%d", *c);
}
e <linux/kmod.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/magic.h> #include <linux/of.h> #include <linux/err.h> #include "mtdcore.h" +#include "mtdsplit/mtdsplit.h" /* Our partition linked list */ static LIST_HEAD(mtd_partitions); @@ -52,6 +54,8 @@ struct mtd_part { struct list_head list; }; +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part); + /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve * the pointer to that structure. @@ -649,6 +653,7 @@ int mtd_add_partition(struct mtd_info *p mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&new->mtd); + mtd_partition_split(parent, new); mtd_add_partition_attrs(new); @@ -718,6 +723,35 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); +#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME +#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME +#else +#define SPLIT_FIRMWARE_NAME "unused" +#endif + +static void split_firmware(struct mtd_info *master, struct mtd_part *part) +{ +} + +void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, + int offset, int size) +{ +} + +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part) +{ + static int rootfs_found = 0; + + if (rootfs_found) + return; + + if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) && + IS_ENABLED(CONFIG_MTD_SPLIT_FIRMWARE)) + split_firmware(master, part); + + arch_split_mtd_part(master, part->mtd.name, part->offset, + part->mtd.size); +} /* * This function, given a master MTD object and a partition table, creates * and registers slave MTD objects which are bound to the master according to @@ -749,6 +783,7 @@ int add_mtd_partitions(struct mtd_info * mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&slave->mtd); + mtd_partition_split(master, slave); mtd_add_partition_attrs(slave); cur_offset = slave->offset + slave->mtd.size; --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h @@ -102,5 +102,7 @@ int mtd_add_partition(struct mtd_info *m long long offset, long long length); int mtd_del_partition(struct mtd_info *master, int partno); uint64_t mtd_get_device_size(const struct mtd_info *mtd); +extern void __weak arch_split_mtd_part(struct mtd_info *master, + const char *name, int offset, int size); #endif