Commit d7f7e04f authored by Hauke Mehrtens's avatar Hauke Mehrtens Committed by Miquel Raynal

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: default avatarHauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-3-hauke@hauke-m.de
parent a4d82940
...@@ -51,13 +51,20 @@ static int parser_trx_parse(struct mtd_info *mtd, ...@@ -51,13 +51,20 @@ static int parser_trx_parse(struct mtd_info *mtd,
const struct mtd_partition **pparts, const struct mtd_partition **pparts,
struct mtd_part_parser_data *data) struct mtd_part_parser_data *data)
{ {
struct device_node *np = mtd_get_of_node(mtd);
struct mtd_partition *parts; struct mtd_partition *parts;
struct mtd_partition *part; struct mtd_partition *part;
struct trx_header trx; struct trx_header trx;
size_t bytes_read; size_t bytes_read;
uint8_t curr_part = 0, i = 0; uint8_t curr_part = 0, i = 0;
uint32_t trx_magic = TRX_MAGIC;
int err; int err;
/* Get different magic from device tree if specified */
err = of_property_read_u32(np, "brcm,trx-magic", &trx_magic);
if (err != 0 && err != -EINVAL)
pr_err("failed to parse \"brcm,trx-magic\" DT attribute, using default: %d\n", err);
parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition), parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition),
GFP_KERNEL); GFP_KERNEL);
if (!parts) if (!parts)
...@@ -70,7 +77,7 @@ static int parser_trx_parse(struct mtd_info *mtd, ...@@ -70,7 +77,7 @@ static int parser_trx_parse(struct mtd_info *mtd,
return err; return err;
} }
if (trx.magic != TRX_MAGIC) { if (trx.magic != trx_magic) {
kfree(parts); kfree(parts);
return -ENOENT; return -ENOENT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment