Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp530793ybt; Wed, 1 Jul 2020 04:22:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLW4qvxmfEsqi0n3N1rqWK72vqGwsdx0EMogKwibl4ePjUWxVlzkKGEJRMfFTI4cwU8MuP X-Received: by 2002:a17:906:492:: with SMTP id f18mr22321585eja.279.1593602570047; Wed, 01 Jul 2020 04:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593602570; cv=none; d=google.com; s=arc-20160816; b=yosLSIbcq7EYRkPtDT5PoIJ6OlamN45kTmagX3QfTxshQdMsgGmYM4FfyXSz9hS/fl xGIUxAs+NRUwzLG06L6KeJ64HJzqbScnR7jeZ8PDDDOzpx7UhfGvJ2HWGoOVSSq1qOA2 6G52fZaJWtol4OvAmY3lTzL/0mynwHmK25tFpzsasLOdbYTGd/Q1v6zm0eliuKAsTp2B fvHpnq758U08hRQBY8/0e/nKgywZDMsJkJXGbpWsHPoPm1EbCN4O3Pf3CHc1kVK0gGg8 EovsOnHW+h/OyZXsyr8NYm/Qm8o6rIw3N0PYE1CDj4YeOZKh0hsPvG/v/u1c5E8w9+Ts yguA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sEcl95i4y1q0BXj1vRLqPn5FKNWCAidmG2odhqYo1vk=; b=UF+/583I9Ka8/pmKMNanGIWLxAJlf92tO5egBSKQ2FfoVTcTtjgrbRJDFRE46zDT8t ee8PJl035s6wRuQ6Y+dOOwmJb0GmSGFkM9r6Fe6C9uEbyBs2a2cOfxVxMRtkFoeG2voh dHHuG69OoiOzZovboqOQwLJK1QJZ3ruhLqaB1aFOPWh5m9eEqKjSx0CDWjMjYThVY1Ao ZCOWbjKZMzAEhSgB22d2sfLyrNxljr47yiZyyN+eH4kptXH00Z4RcL1dlmY4+E81p7Yr WmJByQq9h4IltYLJXqxvl39KND9VIFtQ6o/Zd+eKE4m02Pd3U17eWKYeBML8Pme6OQ8C 4org== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oSO9TszI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si3714626ejc.200.2020.07.01.04.22.26; Wed, 01 Jul 2020 04:22:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oSO9TszI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730275AbgGALWK (ORCPT + 99 others); Wed, 1 Jul 2020 07:22:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:32924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730234AbgGALWJ (ORCPT ); Wed, 1 Jul 2020 07:22:09 -0400 Received: from ziggy.cz (unknown [213.195.114.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A67C20702; Wed, 1 Jul 2020 11:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593602528; bh=S1NAV77dXwv+fjwoqyD9mo/JlNrWtWQH78lHIrJHCRA=; h=From:To:Cc:Subject:Date:From; b=oSO9TszIlrcVn+okb5AAX78/ETthqH1FmT2U+ld2nI39STpo0xmVnUM1NsXTTlPVo k6S182Y6hNn284JH0svEkZikLvr5bOP8qVu1K6raiVyLBPr+OKaK9/HgARfWT2Qn8W zMol/oRSi/kXaGFAwPZW24eO3GE9kWGV/OUt/7cI= From: matthias.bgg@kernel.org To: arend.vanspriel@broadcom.com, kvalo@codeaurora.org, davem@davemloft.net, kuba@kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com, mbrugger@suse.com, netdev@vger.kernel.org, chi-hsien.lin@cypress.com, linux-wireless@vger.kernel.org, hante.meuleman@broadcom.com, linux-kernel@vger.kernel.org, hdegoede@redhat.com, wright.feng@cypress.com, matthias.bgg@kernel.org, brcm80211-dev-list@cypress.com, franky.lin@broadcom.com Subject: [PATCH v3] brcmfmac: Transform compatible string for FW loading Date: Wed, 1 Jul 2020 13:22:00 +0200 Message-Id: <20200701112201.6449-1-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias Brugger 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 --- 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(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c index b886b56a5e5a..a7554265f95f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c @@ -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); } -- 2.27.0