of: Add a context pointer to fixup functions
If drivers want to fixup their specific instance they need some context to know which instance they have to fixup. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
91b3761ec8
commit
d7c1612d65
|
@ -229,7 +229,7 @@ static void at91sam9x5ek_devices_detect_one(const char *name)
|
||||||
|
|
||||||
#define NODE_NAME_LEN 128
|
#define NODE_NAME_LEN 128
|
||||||
|
|
||||||
static int cm_cogent_fixup(struct device_node *root)
|
static int cm_cogent_fixup(struct device_node *root, void *unused)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
|
@ -260,5 +260,5 @@ void at91sam9x5ek_devices_detect_hw(void)
|
||||||
armlinux_set_serial(sn);
|
armlinux_set_serial(sn);
|
||||||
|
|
||||||
if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
|
if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
|
||||||
of_register_fixup(cm_cogent_fixup);
|
of_register_fixup(cm_cogent_fixup, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
struct fdt_header *fdt = NULL;
|
struct fdt_header *fdt = NULL;
|
||||||
|
|
||||||
static int hb_fixup(struct device_node *root)
|
static int hb_fixup(struct device_node *root, void *unused)
|
||||||
{
|
{
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
u32 reg = readl(sregs_base + HB_SREG_A9_PWRDOM_DATA);
|
u32 reg = readl(sregs_base + HB_SREG_A9_PWRDOM_DATA);
|
||||||
|
@ -108,7 +108,7 @@ mem_initcall(highbank_mem_init);
|
||||||
|
|
||||||
static int highbank_devices_init(void)
|
static int highbank_devices_init(void)
|
||||||
{
|
{
|
||||||
of_register_fixup(hb_fixup);
|
of_register_fixup(hb_fixup, NULL);
|
||||||
if (!fdt) {
|
if (!fdt) {
|
||||||
highbank_register_gpio(0);
|
highbank_register_gpio(0);
|
||||||
highbank_register_gpio(1);
|
highbank_register_gpio(1);
|
||||||
|
|
|
@ -77,7 +77,7 @@ void __noreturn reset_cpu (unsigned long addr)
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef CONFIG_OFTREE
|
#ifdef CONFIG_OFTREE
|
||||||
static int of_mpc5200_fixup(struct device_node *root)
|
static int of_mpc5200_fixup(struct device_node *root, void *unused)
|
||||||
{
|
{
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ static int of_mpc5200_fixup(struct device_node *root)
|
||||||
|
|
||||||
static int of_register_mpc5200_fixup(void)
|
static int of_register_mpc5200_fixup(void)
|
||||||
{
|
{
|
||||||
return of_register_fixup(of_mpc5200_fixup);
|
return of_register_fixup(of_mpc5200_fixup, NULL);
|
||||||
}
|
}
|
||||||
late_initcall(of_register_mpc5200_fixup);
|
late_initcall(of_register_mpc5200_fixup);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -89,7 +89,7 @@ error:
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fdt_cpu_setup(struct device_node *blob)
|
static int fdt_cpu_setup(struct device_node *blob, void *unused)
|
||||||
{
|
{
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
struct sys_info sysinfo;
|
struct sys_info sysinfo;
|
||||||
|
@ -139,6 +139,6 @@ static int fdt_cpu_setup(struct device_node *blob)
|
||||||
|
|
||||||
static int of_register_mpc85xx_fixup(void)
|
static int of_register_mpc85xx_fixup(void)
|
||||||
{
|
{
|
||||||
return of_register_fixup(fdt_cpu_setup);
|
return of_register_fixup(fdt_cpu_setup, NULL);
|
||||||
}
|
}
|
||||||
late_initcall(of_register_mpc85xx_fixup);
|
late_initcall(of_register_mpc85xx_fixup);
|
||||||
|
|
|
@ -163,7 +163,7 @@ int release_sdram_region(struct resource *res)
|
||||||
|
|
||||||
#ifdef CONFIG_OFTREE
|
#ifdef CONFIG_OFTREE
|
||||||
|
|
||||||
static int of_memory_fixup(struct device_node *node)
|
static int of_memory_fixup(struct device_node *node, void *unused)
|
||||||
{
|
{
|
||||||
struct memory_bank *bank;
|
struct memory_bank *bank;
|
||||||
int err;
|
int err;
|
||||||
|
@ -200,7 +200,7 @@ static int of_memory_fixup(struct device_node *node)
|
||||||
|
|
||||||
static int of_register_memory_fixup(void)
|
static int of_register_memory_fixup(void)
|
||||||
{
|
{
|
||||||
return of_register_fixup(of_memory_fixup);
|
return of_register_fixup(of_memory_fixup, NULL);
|
||||||
}
|
}
|
||||||
late_initcall(of_register_memory_fixup);
|
late_initcall(of_register_memory_fixup);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -113,7 +113,7 @@ void of_print_cmdline(struct device_node *root)
|
||||||
printf("commandline: %s\n", cmdline);
|
printf("commandline: %s\n", cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int of_fixup_bootargs(struct device_node *root)
|
static int of_fixup_bootargs(struct device_node *root, void *unused)
|
||||||
{
|
{
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
@ -135,22 +135,24 @@ static int of_fixup_bootargs(struct device_node *root)
|
||||||
|
|
||||||
static int of_register_bootargs_fixup(void)
|
static int of_register_bootargs_fixup(void)
|
||||||
{
|
{
|
||||||
return of_register_fixup(of_fixup_bootargs);
|
return of_register_fixup(of_fixup_bootargs, NULL);
|
||||||
}
|
}
|
||||||
late_initcall(of_register_bootargs_fixup);
|
late_initcall(of_register_bootargs_fixup);
|
||||||
|
|
||||||
struct of_fixup {
|
struct of_fixup {
|
||||||
int (*fixup)(struct device_node *);
|
int (*fixup)(struct device_node *, void *);
|
||||||
|
void *context;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
static LIST_HEAD(of_fixup_list);
|
static LIST_HEAD(of_fixup_list);
|
||||||
|
|
||||||
int of_register_fixup(int (*fixup)(struct device_node *))
|
int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context)
|
||||||
{
|
{
|
||||||
struct of_fixup *of_fixup = xzalloc(sizeof(*of_fixup));
|
struct of_fixup *of_fixup = xzalloc(sizeof(*of_fixup));
|
||||||
|
|
||||||
of_fixup->fixup = fixup;
|
of_fixup->fixup = fixup;
|
||||||
|
of_fixup->context = context;
|
||||||
|
|
||||||
list_add_tail(&of_fixup->list, &of_fixup_list);
|
list_add_tail(&of_fixup->list, &of_fixup_list);
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ int of_fix_tree(struct device_node *node)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
list_for_each_entry(of_fixup, &of_fixup_list, list) {
|
list_for_each_entry(of_fixup, &of_fixup_list, list) {
|
||||||
ret = of_fixup->fixup(node);
|
ret = of_fixup->fixup(node, of_fixup->context);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct device_d;
|
||||||
struct driver_d;
|
struct driver_d;
|
||||||
|
|
||||||
int of_fix_tree(struct device_node *);
|
int of_fix_tree(struct device_node *);
|
||||||
int of_register_fixup(int (*fixup)(struct device_node *));
|
int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context);
|
||||||
|
|
||||||
int of_match(struct device_d *dev, struct driver_d *drv);
|
int of_match(struct device_d *dev, struct driver_d *drv);
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_OFTREE
|
#ifdef CONFIG_OFTREE
|
||||||
static int eth_of_fixup(struct device_node *root)
|
static int eth_of_fixup(struct device_node *root, void *unused)
|
||||||
{
|
{
|
||||||
struct eth_device *edev;
|
struct eth_device *edev;
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
|
@ -316,7 +316,7 @@ static int eth_of_fixup(struct device_node *root)
|
||||||
|
|
||||||
static int eth_register_of_fixup(void)
|
static int eth_register_of_fixup(void)
|
||||||
{
|
{
|
||||||
return of_register_fixup(eth_of_fixup);
|
return of_register_fixup(eth_of_fixup, NULL);
|
||||||
}
|
}
|
||||||
late_initcall(eth_register_of_fixup);
|
late_initcall(eth_register_of_fixup);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue