Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: parsers: trx: Allow to specify brcm, trx-magic in DT

Buffalo uses a different TRX magic for every device, to be able to use
this trx parser, make it possible to specify the TRX magic in device
tree. If no TRX magic is specified in device tree, the standard value
will be used. This value should only be specified if a vendor chooses to
use a non standard TRX magic.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-3-hauke@hauke-m.de

authored by

Hauke Mehrtens and committed by
Miquel Raynal
d7f7e04f a4d82940

+8 -1
+8 -1
drivers/mtd/parsers/parser_trx.c
··· 51 51 const struct mtd_partition **pparts, 52 52 struct mtd_part_parser_data *data) 53 53 { 54 + struct device_node *np = mtd_get_of_node(mtd); 54 55 struct mtd_partition *parts; 55 56 struct mtd_partition *part; 56 57 struct trx_header trx; 57 58 size_t bytes_read; 58 59 uint8_t curr_part = 0, i = 0; 60 + uint32_t trx_magic = TRX_MAGIC; 59 61 int err; 62 + 63 + /* Get different magic from device tree if specified */ 64 + err = of_property_read_u32(np, "brcm,trx-magic", &trx_magic); 65 + if (err != 0 && err != -EINVAL) 66 + pr_err("failed to parse \"brcm,trx-magic\" DT attribute, using default: %d\n", err); 60 67 61 68 parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition), 62 69 GFP_KERNEL); ··· 77 70 return err; 78 71 } 79 72 80 - if (trx.magic != TRX_MAGIC) { 73 + if (trx.magic != trx_magic) { 81 74 kfree(parts); 82 75 return -ENOENT; 83 76 }