brcmfmac: Transform compatible string for FW loading
PATCH v3 1/1 brcmfmac: Transform compatible string for FW loading
From: Matthias Brugger <[email protected]>
The driver relies on the compatible string from DT to determine which FW configuration file it should load. The DTS spec allows for '/' as part of the compatible string. We change this to '-' so that we will still be able to load the config file, even when the compatible has a '/'. This fixes explicitly the firmware loading for "solidrun,cubox-i/q".
---
Changes in v3:
- use len variable to store length of string (Hans de Goede)
- fix for loop to stop on first NULL-byte (Hans de Goede)
Changes in v2:
- use strscpy instead of strncpy (Hans de Goede)
- use strlen(tmp) + 1 for allocation (Hans de Goede, kernel test robot)
.../wireless/broadcom/brcm80211/brcmfmac/of.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +16 -3
@@ -17,7 +17,6 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, {struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;struct device_node *root, *np = dev->of_node; -struct property *prop;int irq;u32 irqf;u32 val;
@@ -25,8 +24,22 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,/* Set board-type to the first string of the machine compatible prop */ root =of_find_node_by_path ("/" );if (root) { - prop =of_find_property (root,"compatible" ,NULL ); - settings->board_type =of_prop_next_string (prop,NULL ); +int i, len; +char *board_type; +const char *tmp; + +of_property_read_string_index (root,"compatible" ,0 , &tmp); + +/* get rid of '/' in the compatible string to be able to find the FW */ + len =strlen (tmp) +1 ; + board_type =devm_kzalloc (dev, len,GFP_KERNEL ); +strscpy (board_type, tmp, len); +for (i =0 ; i < board_type[i]; i++) { +if (board_type[i] =='/' ) + board_type[i] ='-' ; + } + settings->board_type = board_type; +of_node_put (root); }
Signature · 1 line
2.27.0
Hi,
Quoted 13 lines · On 7/1/20 1:22 PM, [email protected] wrote:
From: Matthias Brugger <[email protected]>
The driver relies on the compatible string from DT to determine which FW configuration file it should load. The DTS spec allows for '/' as part of the compatible string. We change this to '-' so that we will still be able to load the config file, even when the compatible has a '/'. This fixes explicitly the firmware loading for "solidrun,cubox-i/q".
Signed-off-by Matthias Brugger <[email protected]>---
Quoted 7 lines
Changes in v3:
- use len variable to store length of string (Hans de Goede)
- fix for loop to stop on first NULL-byte (Hans de Goede)Changes in v2:
- use strscpy instead of strncpy (Hans de Goede)
- use strlen(tmp) + 1 for allocation (Hans de Goede, kernel test robot)
v3 looks good to me:
Regards,
Hans
Quoted 42 lines
.../wireless/broadcom/brcm80211/brcmfmac/of.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +16
-3@@ -17,7 +17,6 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, {struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;struct device_node *root, *np = dev->of_node; -struct property *prop;int irq;u32 irqf;u32 val;@@ -25,8 +24,22 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,/* Set board-type to the first string of the machine compatible prop */ root =of_find_node_by_path ("/" );if (root) { - prop =of_find_property (root,"compatible" ,NULL ); - settings->board_type =of_prop_next_string (prop,NULL ); +int i, len; +char *board_type; +const char *tmp; + +of_property_read_string_index (root,"compatible" ,0 , &tmp); + +/* get rid of '/' in the compatible string to be able to find the FW */ + len =strlen (tmp) +1 ; + board_type =devm_kzalloc (dev, len,GFP_KERNEL ); +strscpy (board_type, tmp, len); +for (i =0 ; i < board_type[i]; i++) { +if (board_type[i] =='/' ) + board_type[i] ='-' ; + } + settings->board_type = board_type; +of_node_put (root); }
Quoted 11 lines · [email protected] wrote:
From: Matthias Brugger <[email protected]>
The driver relies on the compatible string from DT to determine which FW configuration file it should load. The DTS spec allows for '/' as part of the compatible string. We change this to '-' so that we will still be able to load the config file, even when the compatible has a '/'. This fixes explicitly the firmware loading for "solidrun,cubox-i/q".
Signed-off-by Matthias Brugger <[email protected]>Reviewed-by Hans deGoede <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
29e354ebeeec brcmfmac: Transform compatible string for FW loading
Signature · 3 lines
https://patchwork.kernel.org/patch/11636153/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches