From patchwork Tue Sep 10 03:04:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacobe Zang X-Patchwork-Id: 13797796 X-Patchwork-Delegate: kvalo@adurom.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2097.outbound.protection.outlook.com [40.107.255.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A84C914F122; Tue, 10 Sep 2024 03:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.97 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725937549; cv=fail; b=V54lweI+OEFYrVdon1tr1A8DoLIfvv+XGOwi5IyFjJ0psQTByq1/m/gaRiNkCeZUIeJ9QFhAwTt2vHZnBQZK0NrwTwbU83u3Vd1tDl/jhcX3x92clEluHejf0pzNPqzl4aGDE56hSkB4OtJty/hRzSAXUs33Gmcv00/nMBoYW80= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725937549; c=relaxed/simple; bh=6rKptISgX+yTYN/ILXeFCE7UDdObYAJtbyRJTS9NOTM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=PAlM68szBXgaGPlsjJDe+kTSWTIdKcwgrnexR9EC+p9oczGScWr72Q2bpplmh83PKejhTNKnNjT87t7YHecyUWkgA/Y/XSmBIBmfZ4W2vj8uSuVUqksaa8B5m5vCWAQmgt4DkfuT0F2yWT2jC+P4yP3dVCd6n0Biyar1DZU6s00= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wesion.com; spf=pass smtp.mailfrom=wesion.com; arc=fail smtp.client-ip=40.107.255.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wesion.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wesion.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AMhTvLpd+kaGoU5P37pY4eOi/51uX9zcuI032ZXes/bQoLFhXCpTpXsDc9Esp4Z71brRPnsuhtJgMhtB0zDg0t44mxbjCErfh7vfAswTvVqTiMMbd1XYTJa90MtII8AVq/xSbwK9xawkC7iSE01vwfaKLpGHY2QHRZ/8JfSU2cu9TOixMmUml6lvwG76orfrZJDg3KNeUrwXeFVm/QKSqYLXn0vFJkQedtwuucLwLX2Xa2pPBOTRuGDz3KyYGrWHjfUv0db2OHDaoToaXZz+Sgrd3jky0TX+ifE7KGoWxRliEtqLq6c+QwrE9Xak1oKB0a/YH9Cf5qCrMIZjozkN3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xydvwPU1NKoa0szBoqrw+5ACxascr/GdnlvKtAfEmlc=; b=aHbtFmI3e1GNd9pSv4q2u7Dg59uIKgbROW7XhirmoaVUV1QmLbmkqgP3OdSUC17CBEzmsDpnFricfq4BsADnDc9vqKk7nrP728ukTtr0dPIzC3eHnKYXYmwbn8xwhuVZSV4XbJm21LNJmuD5EJJ2329s5nv5O5vraRE009x6fF10N3/3Fme/iI5FYkSOJUfRvzfhErcZdSRNzLxXewbIR8z6Yy863AfOka8lhfAYcr107oZL/scLP1dfxFddO/SGLJ//oYoEDcpnH5rC3s28jKYwEA/EIvBpBYmGEW1VQtXYhqgvDhQrH65vuRytvNV/rtsoWrQG+E798ze6642MBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wesion.com; dmarc=pass action=none header.from=wesion.com; dkim=pass header.d=wesion.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wesion.com; Received: from TYZPR03MB7001.apcprd03.prod.outlook.com (2603:1096:400:26a::14) by SEZPR03MB8442.apcprd03.prod.outlook.com (2603:1096:101:21d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Tue, 10 Sep 2024 03:05:42 +0000 Received: from TYZPR03MB7001.apcprd03.prod.outlook.com ([fe80::78dd:5e68:1a9c:36c0]) by TYZPR03MB7001.apcprd03.prod.outlook.com ([fe80::78dd:5e68:1a9c:36c0%4]) with mapi id 15.20.7939.022; Tue, 10 Sep 2024 03:05:42 +0000 From: Jacobe Zang Date: Tue, 10 Sep 2024 11:04:13 +0800 Subject: [PATCH v14 3/4] wifi: brcmfmac: Add optional lpo clock enable support Message-Id: <20240910-wireless-mainline-v14-3-9d80fea5326d@wesion.com> References: <20240910-wireless-mainline-v14-0-9d80fea5326d@wesion.com> In-Reply-To: <20240910-wireless-mainline-v14-0-9d80fea5326d@wesion.com> To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , van Spriel , Arend van Spriel Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com, nick@khadas.com, Jacobe Zang , Ondrej Jirman , Sai Krishna X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1725937530; l=10056; i=jacobe.zang@wesion.com; s=20240828; h=from:subject:message-id; bh=6rKptISgX+yTYN/ILXeFCE7UDdObYAJtbyRJTS9NOTM=; b=tPcsDlzGN/GthEJ/1dklyATX5NUY5tSDnxEV1V8freOXZlIqwyDDa3SwijABin6QOTvA/AA38 S0RkqJl6MqLCbEzv/fMEZ8vhym8aQ+jwMHRnJZlb1wMDhpZfhuiu4j7 X-Developer-Key: i=jacobe.zang@wesion.com; a=ed25519; pk=CkP5TjIqHSwHJwZXTGtadoXZucYvakXcO3HjbR6FoeU= X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) To TYZPR03MB7001.apcprd03.prod.outlook.com (2603:1096:400:26a::14) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR03MB7001:EE_|SEZPR03MB8442:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d2c5905-06a4-4d32-7f31-08dcd14574d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|52116014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?T4hE5zUZnW1ldOORKEot3QskS4DN/K/?= =?utf-8?q?qRv5IeFs5wlyGF2VbIa/ug/3vUM1VK1a0R9WECLLNffWwVnJ/vtuB0iEvYr2X9+dw?= =?utf-8?q?TU+DS2Rb4KuWIQqU+sNQEB3Pai/Xyu+tGIYv4ct9bNSbE8JbDQDieMTNdDeRVrSBs?= =?utf-8?q?eQxqPYOIFDWH313KImVIRa6UfvO9wtZexG4DNnpWrzsrMHI6q21+UqNky4SpEXJJz?= =?utf-8?q?F2mXhR83gpFrxHOVV07ZIetMSJbZV00SbcZMJAgo8hk6rL9wWfQjTO+U2LLI6vCVv?= =?utf-8?q?rIjhLeI5R2tAq/HQ4c/nz4S/VbzEpmFtMtx8KiuxfvMFHY9IoTgPuckG1lZ5rnexY?= =?utf-8?q?ulzaAbD8L8mA7uFY6mKl6t3e9XJ7oltzDHMkNxu4Oh5s0nV1YkD4Qdm/MX891x89i?= =?utf-8?q?aaZPzRvQqIaqZsQXrTHXzBZw1OnYoSz+YSGueCS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IW7tZCn3XN0AsS1Iq5K?= =?utf-8?q?aDes0eWrius3KXLPUDIFd31uhmSnihqqFi5TF014kyZASC/LSbT7YEQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR03MB7001.apcprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(376014)(52116014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lSb2s+BIO1KpW403YKpFCJqyZ7aH?= =?utf-8?q?GrqtQ1SL0Icw7O9UZo1QppErLJ6248uHScKLOkXVwQCCCOqIDyNnWxJ27JTmwhzqT?= =?utf-8?q?EKzuzKw7JV57QSty/hCpFG1SqMAoeM4+e+CajGvlhPz0TC9GCdWP4SLWgrSGTa7Hd?= =?utf-8?q?03BDs3dItiaNYidxKBx0Q/QJY+0w+6ltKKSaorfZ8itAsTxlkcPDi+L3ifwPLKGUS?= =?utf-8?q?rADKxdHW1lES19b63MrHkskcJEV0Q4KklG5/kMFX8Ul6zSPgGwu0hyFUdLeAO2LBF?= =?utf-8?q?SIKECeGga5HsYYuSPsz7m9NmRLULnmgqkgXHCdYjMUFgHQ0UUSAwZwcEy9/dy3Ztx?= =?utf-8?q?RnHhSHSyfYWt7aPf71zmz7nt5U36DbCxM8vnYTwhh4S81BhXE3fxJ4DWgXtxV5e+L?= =?utf-8?q?PbOqaNepYPeggL1cidxRLBroEpw9jHPrFF8EJyBUuyURuwZl/lElU/bLIG7FRYjme?= =?utf-8?q?Bjk5a5C1W2vFe0Xd3pwH82LZHMkNi10ecDIn+IO5SVYVQrg3+33IlCq8U4N6B+UY2?= =?utf-8?q?A7x8v6HlS1UkXCkG4eJuxnc4XVEkR9IBN9r9Et5/yGls84XeZArhKQCCYKj85rlmb?= =?utf-8?q?nHmCNvvxJXjcvP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yvqSOYvuUoO25Fzs1orxUUTTp+qC9iGMn3b+G9vTLP65UUtxAWqNUGHpA?= =?utf-8?q?iK2/JmZMI2lx?= X-OriginatorOrg: wesion.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d2c5905-06a4-4d32-7f31-08dcd14574d8 X-MS-Exchange-CrossTenant-AuthSource: TYZPR03MB7001.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 03:05:42.4386 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 2dc3bd76-7ac2-4780-a5b7-6c6cc6b5af9b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: spXNor9TBsnaslc2DKD7jgHPiRpnkU661dckIMn5O6jQi8joDIFhmeQfDunVJQ8oEnCo9qKNqy3K8q9uj6MEJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR03MB8442 WiFi modules often require 32kHz clock to function. Add support to enable the clock to PCIe driver and move "brcm,bcm4329-fmac" check to the top of brcmf_of_probe. Change function prototypes from void to int and add appropriate errno's for return values that will be send to bus when error occurred. Co-developed-by: Ondrej Jirman Signed-off-by: Ondrej Jirman Co-developed-by: Arend van Spriel Signed-off-by: Arend van Spriel Reviewed-by: Sai Krishna Signed-off-by: Jacobe Zang Reviewed-by: Sebastian Reichel Tested-by: Sebastian Reichel # On RK3588 EVB1 Acked-by: Arend van Spriel --- .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 4 ++-- .../wireless/broadcom/brcm80211/brcmfmac/common.c | 3 ++- .../net/wireless/broadcom/brcm80211/brcmfmac/of.c | 25 ++++++++++++++++------ .../net/wireless/broadcom/brcm80211/brcmfmac/of.h | 9 ++++---- .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 3 +++ .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 22 ++++++++++++------- .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 3 +++ 7 files changed, 47 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c index d35262335eaf7..17f6b33beabd8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c @@ -947,8 +947,8 @@ int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev) /* try to attach to the target device */ sdiodev->bus = brcmf_sdio_probe(sdiodev); - if (!sdiodev->bus) { - ret = -ENODEV; + if (IS_ERR(sdiodev->bus)) { + ret = PTR_ERR(sdiodev->bus); goto out; } brcmf_sdiod_host_fixup(sdiodev->func2->card->host); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c index b24faae35873d..58d50918dd177 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c @@ -561,7 +561,8 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev, if (!found) { /* No platform data for this device, try OF and DMI data */ brcmf_dmi_probe(settings, chip, chiprev); - brcmf_of_probe(dev, bus_type, settings); + if (brcmf_of_probe(dev, bus_type, settings) == -EPROBE_DEFER) + return ERR_PTR(-EPROBE_DEFER); brcmf_acpi_probe(dev, bus_type, settings); } return settings; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c index fe4f657561056..6d90be9529012 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "debug.h" @@ -65,12 +66,13 @@ static int brcmf_of_get_country_codes(struct device *dev, return 0; } -void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, - struct brcmf_mp_device *settings) +int brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, + struct brcmf_mp_device *settings) { struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio; struct device_node *root, *np = dev->of_node; struct of_phandle_args oirq; + struct clk *clk; const char *prop; int irq; int err; @@ -106,7 +108,7 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, board_type = devm_kstrdup(dev, tmp, GFP_KERNEL); if (!board_type) { of_node_put(root); - return; + return 0; } strreplace(board_type, '/', '-'); settings->board_type = board_type; @@ -114,8 +116,15 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, of_node_put(root); } + clk = devm_clk_get_optional_enabled(dev, "lpo"); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + brcmf_dbg(INFO, "%s LPO clock\n", clk ? "enable" : "no"); + clk_set_rate(clk, 32768); + if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac")) - return; + return 0; err = brcmf_of_get_country_codes(dev, settings); if (err) @@ -124,23 +133,25 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, of_get_mac_address(np, settings->mac); if (bus_type != BRCMF_BUSTYPE_SDIO) - return; + return 0; if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0) sdio->drive_strength = val; /* make sure there are interrupts defined in the node */ if (of_irq_parse_one(np, 0, &oirq)) - return; + return 0; irq = irq_create_of_mapping(&oirq); if (!irq) { brcmf_err("interrupt could not be mapped\n"); - return; + return 0; } irqf = irqd_get_trigger_type(irq_get_irq_data(irq)); sdio->oob_irq_supported = true; sdio->oob_irq_nr = irq; sdio->oob_irq_flags = irqf; + + return 0; } diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h index 10bf52253337e..ae124c73fc3b7 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h @@ -3,11 +3,12 @@ * Copyright (c) 2014 Broadcom Corporation */ #ifdef CONFIG_OF -void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, - struct brcmf_mp_device *settings); +int brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, + struct brcmf_mp_device *settings); #else -static void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, - struct brcmf_mp_device *settings) +static int brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, + struct brcmf_mp_device *settings) { + return 0; } #endif /* CONFIG_OF */ diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index ce482a3877e90..190e8990618c5 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -2452,6 +2452,9 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret = -ENOMEM; goto fail; } + ret = PTR_ERR_OR_ZERO(devinfo->settings); + if (ret < 0) + goto fail; bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (!bus) { diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 1461dc453ac22..a9b4d560cbfc7 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -3943,7 +3943,7 @@ static const struct brcmf_buscore_ops brcmf_sdio_buscore_ops = { .write32 = brcmf_sdio_buscore_write32, }; -static bool +static int brcmf_sdio_probe_attach(struct brcmf_sdio *bus) { struct brcmf_sdio_dev *sdiodev; @@ -3953,6 +3953,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus) u32 reg_val; u32 drivestrength; u32 enum_base; + int ret = -EBADE; sdiodev = bus->sdiodev; sdio_claim_host(sdiodev->func1); @@ -4001,8 +4002,9 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus) BRCMF_BUSTYPE_SDIO, bus->ci->chip, bus->ci->chiprev); - if (!sdiodev->settings) { + if (IS_ERR_OR_NULL(sdiodev->settings)) { brcmf_err("Failed to get device parameters\n"); + ret = PTR_ERR_OR_ZERO(sdiodev->settings); goto fail; } /* platform specific configuration: @@ -4071,7 +4073,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus) /* allocate header buffer */ bus->hdrbuf = kzalloc(MAX_HDR_READ + bus->head_align, GFP_KERNEL); if (!bus->hdrbuf) - return false; + return -ENOMEM; /* Locate an appropriately-aligned portion of hdrbuf */ bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], bus->head_align); @@ -4082,11 +4084,11 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus) if (bus->poll) bus->pollrate = 1; - return true; + return 0; fail: sdio_release_host(sdiodev->func1); - return false; + return ret; } static int @@ -4451,8 +4453,10 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) /* Allocate private bus interface state */ bus = kzalloc(sizeof(*bus), GFP_ATOMIC); - if (!bus) + if (!bus) { + ret = -ENOMEM; goto fail; + } bus->sdiodev = sdiodev; sdiodev->bus = bus; @@ -4467,6 +4471,7 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) dev_name(&sdiodev->func1->dev)); if (!wq) { brcmf_err("insufficient memory to create txworkqueue\n"); + ret = -ENOMEM; goto fail; } brcmf_sdiod_freezer_count(sdiodev); @@ -4474,7 +4479,8 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) bus->brcmf_wq = wq; /* attempt to attach to the dongle */ - if (!(brcmf_sdio_probe_attach(bus))) { + ret = brcmf_sdio_probe_attach(bus); + if (ret < 0) { brcmf_err("brcmf_sdio_probe_attach failed\n"); goto fail; } @@ -4546,7 +4552,7 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) fail: brcmf_sdio_remove(bus); - return NULL; + return ERR_PTR(ret); } /* Detach and free everything */ diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index 8afbf529c7450..2821c27f317ee 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -1272,6 +1272,9 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo, ret = -ENOMEM; goto fail; } + ret = PTR_ERR_OR_ZERO(devinfo->settings); + if (ret < 0) + goto fail; if (!brcmf_usb_dlneeded(devinfo)) { ret = brcmf_alloc(devinfo->dev, devinfo->settings);