[PATCH 13/14] spidernet: read firmware from the OF device tree

Milton Miller miltonm at bga.com
Thu Dec 8 04:28:39 EST 2005


On Tue Dec 6 14:52:33 EST 2005, Arnd Bergmann wrote:

> request_firmware() is sometimes problematic, especially
> in initramfs, reading the firmware from Open Firmware
> is much preferrable.
>
> We still try to get the firmware from the file system
> first, in order to support old SLOF releases and to allow
> updates of the spidernet firmware without reflashing
> the system.
>
> From: Jens.Osterkamp at de.ibm.com
> Cc: netdev at vger.kernel.org
> Signed-off-by: Arnd Bergmann <arndb at de.ibm.com>
>
> Index: linux-2.6.15-rc/drivers/net/spider_net.c
> ===================================================================
> --- linux-2.6.15-rc.orig/drivers/net/spider_net.c
> +++ linux-2.6.15-rc/drivers/net/spider_net.c
> @@ -1895,16 +1895,27 @@ spider_net_download_firmware(struct spid
>  static int
>  spider_net_init_firmware(struct spider_net_card *card)
>  {
> -       const struct firmware *firmware;
> +       struct firmware *firmware;
> +       struct device_node *dn;
> +       u8 *fw_prop;
>         int err = -EIO;
>
> -       if (request_firmware(&firmware,
> +       if (request_firmware((const struct firmware **)&firmware,
>                              SPIDER_NET_FIRMWARE_NAME, 
> &card->pdev->dev) < 0) {
>                 if (netif_msg_probe(card))
>                         pr_err("Couldn't read in sequencer data file 
> %s.\n",
>                                SPIDER_NET_FIRMWARE_NAME);
> -               firmware = NULL;
> -               goto out;
> +
> +               dn = pci_device_to_OF_node(card->pdev);
> +               if (!dn)
> +                       goto out;
> +
> +               fw_prop = (u8 *)get_property(dn, "firmware", NULL);
> +               if (!fw_prop)
> +                       goto out;
> +
> +               memcpy(firmware->data, fw_prop, 6 * 
> SPIDER_NET_FIRMWARE_LEN * sizeof(u32));
> +               firmware->size = 6 * SPIDER_NET_FIRMWARE_LEN * 
> sizeof(u32);
>         }
>
>         if (firmware->size != 6 * SPIDER_NET_FIRMWARE_LEN * 
> sizeof(u32)) {
>
>

A person might think that FIRMWARE_LEN was the desired length.
Or at least there would be something defined to that long expression.

Also, how about actually getting the size of the property (that
third NULL argument is to return that), and checking if it is
the desired size?

milton




More information about the Linuxppc64-dev mailing list