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

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

 



On 2022/01/04 17:26, Dmitry Osipenko wrote:
> 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

Ack.

> 
>>  	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));

It's a function argument, so that doesn't work and actually throws a
warning. Array function argument notation is informative only; they
behave strictly equivalent to pointers. Try it:

$ cat test.c
#include <stdio.h>

void foo(char x[42])
{
	printf("%ld\n", sizeof(x));
}

int main() {
	char x[42];

	foo(x);
}
$ gcc test.c
test.c: In function ‘foo’:
test.c:5:31: warning: ‘sizeof’ on array function parameter ‘x’ will
return size of ‘char *’ [-Wsizeof-array-argument]
    5 |         printf("%ld\n", sizeof(x));
      |                               ^
test.c:3:15: note: declared here
    3 | void foo(char x[42])
      |          ~~~~~^~~~~
$ ./a.out
8


> 
> ...
>> +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().

Argh, forgot to change this one. I used BRCMF_FW_MAX_ALT_PATHS
elsewhere; ARRAY_SIZE won't work as I explained above.

> 
>> +		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.

First time I hear this one, heh. Sure.

> 
> ...
>> --- 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.

Will do.

-- 
Hector Martin (marcan@xxxxxxxxx)
Public Key: https://mrcn.st/pub



[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