[patch 0/1] ipmi: update: add autosensing of ipmi devices on powerpc using of device tree

Arnd Bergmann arnd at arndb.de
Tue Dec 19 09:23:10 EST 2006


On Monday 18 December 2006 22:52, Segher Boessenkool wrote:

> > +static int ipmi_of_probe(struct of_device *dev,
> > +                      const struct of_device_id *match)
> 
> Shouldn't this (and everything else) be some kind of __init?

It should be __devinit.

> > +     regsize = get_property(np, "reg-size", NULL);
> > +     regspacing = get_property(np, "reg-spacing", NULL);
> > +     regshift = get_property(np, "reg-shift", NULL);
> 
> You should check whether you get exactly 4 bytes back or not.
>
> > +     if (!regsize)
> > +             info->io.regsize = DEFAULT_REGSPACING;
> > +     else
> > +             info->io.regsize = *regsize;
> 
> info->io_regsize = regsize ? *regsize : DEFAULT_REGSIZE;
> 
> [Please note that fixes a copy/paste bug, too].

These two changes are contradictory. It's either

    regsize = get_property(np, "reg-size", NULL);
    info->io_regsize = regsize ? *regsize : DEFAULT_REGSIZE;

or

    regsize = get_property(np, "reg-size", &proplen);
    info->io_regsize = (proplen == 4) ? *regsize : DEFAULT_REGSIZE;

> > +static int ipmi_of_remove(struct of_device *dev)
> > +{
> > +     /* should call
> > +      * cleanup_one_si(dev->dev.driver_data); */
> 
> So fix that :-)

That should be a separate patch that fixes the same thing for
pci ipmi devices as well. It needs to move code around for this
(or introduce forward declarations), and the effect is no
different, so it's really just a cleanup.

> > +static struct of_device_id ipmi_match[] =
> > +{
> > +     { .type = "ipmi", .compatible = "ipmi-kcs",  .data = (void*) 
> > SI_KCS },
> > +     { .type = "ipmi", .compatible = "ipmi-smic", .data = (void*) 
> > SI_SMIC },
> > +     { .type = "ipmi", .compatible = "ipmi-bt",   .data = (void*)SI_BT },
> 
> That cast-to-pointer is what gives you that warning when
> casting back.  Is there no better solution?

The one alternative might be something more complicated like:

static const enum si_type __devinitdata of_ipmi_dev_info[] = {
	[SI_KCS] SI_KCS,
	[SI_SMIC] SI_SMIC,
	[SI_BT] SI_BT,
};

static const struct of_device_id of_ipmi_match[] = {
	{ .type = "ipmi", .compatible = "ipmi-kcs",  .data = &of_ipmi_dev_info[SI_KCS] },
	{ .type = "ipmi", .compatible = "ipmi-kcs",  .data = &of_ipmi_dev_info[SI_SMIC] },
	{ .type = "ipmi", .compatible = "ipmi-kcs",  .data = &of_ipmi_dev_info[SI_BT] },
};

Not sure if that's worth it.

	Arnd <><



More information about the Linuxppc-dev mailing list