Re: [PATCH v2 04/35] brcmfmac: firmware: Support having multiple alt paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



04.01.2022 10:26, Hector Martin пишет:
> Apple platforms have firmware and config files identified with multiple
> dimensions. We want to be able to find the most specific firmware
> available for any given platform, progressively trying more general
> firmwares.
> 
> First, add support for having multiple alternate firmware paths.
> 
> Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> Signed-off-by: Hector Martin <marcan@xxxxxxxxx>
> ---
>  .../broadcom/brcm80211/brcmfmac/firmware.c    | 75 ++++++++++++++-----
>  .../broadcom/brcm80211/brcmfmac/firmware.h    |  2 +
>  2 files changed, 59 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> index 0497b721136a..7570dbf22cdd 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> @@ -427,6 +427,8 @@ void brcmf_fw_nvram_free(void *nvram)
>  struct brcmf_fw {
>  	struct device *dev;
>  	struct brcmf_fw_request *req;
> +	const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS];
> +	int alt_index;

unsigned int

>  	u32 curpos;
>  	void (*done)(struct device *dev, int err, struct brcmf_fw_request *req);
>  };
> @@ -592,14 +594,18 @@ static int brcmf_fw_complete_request(const struct firmware *fw,
>  	return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
>  }
>  
> -static char *brcm_alt_fw_path(const char *path, const char *board_type)
> +static int brcm_alt_fw_paths(const char *path, const char *board_type,
> +			     const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS])>  {
>  	char alt_path[BRCMF_FW_NAME_LEN];
>  	const char *suffix;
>  
> +	memset(alt_paths, 0, array_size(sizeof(*alt_paths),
> +					BRCMF_FW_MAX_ALT_PATHS));
You don't need to use array_size() since size of a fixed array is
already known.

memset(alt_paths, 0, sizeof(alt_paths));

...
> +static void
> +brcm_free_alt_fw_paths(const char *alt_paths[BRCMF_FW_MAX_ALT_PATHS])
> +{
> +	unsigned int i;
> +
> +	for (i = 0; alt_paths[i]; i++)

What if array is fully populated and there is no null in the end? Please
don't do this, use BRCMF_FW_MAX_ALT_PATHS or ARRAY_SIZE().

> +		kfree(alt_paths[i]);
>  }
>  
>  static int brcmf_fw_request_firmware(const struct firmware **fw,
> @@ -617,19 +634,25 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
>  {
>  	struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
>  	int ret;
> +	unsigned int i;

Keep reverse Xmas tree coding style.

...
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
> @@ -11,6 +11,8 @@
>  
>  #define BRCMF_FW_DEFAULT_PATH		"brcm/"
>  
> +#define BRCMF_FW_MAX_ALT_PATHS	8

Two tabs are needed here.



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux