From patchwork Wed Aug 28 07:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacobe Zang X-Patchwork-Id: 13780836 X-Patchwork-Delegate: kvalo@adurom.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2117.outbound.protection.outlook.com [40.107.255.117]) (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 16FBE15E5DC; Wed, 28 Aug 2024 07:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.117 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724830887; cv=fail; b=sThBTBgM3fDafU5YGxMiY9+Rfw+fII07seoa/IionE+7ICH4Z1gLfNq3yaha5L+bNpH6QXoU7Np/tA/GXOrDG3kJNoGjtgmpPW9LQvIMxoYx5Fz0+rpVCb+tvzK6Azjh+mkfPgP7yWGeDZghXxp+se0azAMBeF7H0RfyScYICXo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724830887; c=relaxed/simple; bh=1EIqUH68e2yHYUoqfpobt6Hzt4qoimWdTYOf3QUUDbM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Zlyr7j2skr3z0rDDH1CNxhKGkdSa7YB0QUNW4AuReKK+rQ5Fs2FR+cfBvY2+AZDVFlTvmWj3LHLLXZhLxjk5V9clUPY3n1pzgI95gQweMLrfOljvVtHmI/ohofGS8BOsLzEQwM7yHgYGJ7GOjRro2Qi1AqVFPwtQvCytxHiwmeY= 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.117 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=EDXH4E7wJyx3mKmeqbEmSuAy2Tp/784dwZnXvg1+UF8B6NPBOk5il1l0xDXAqyWY8SYVOsTZcdg30jUrzRKuOLjutXv7igeTDBo+k0LxpbrYJ1j4nxpAr4rfSBSwX37IJcnzELNHpxGaeacCRGF6nDxnAIYELvVNYfgjWcYro0lkCKU3YWpWRLDMfk4/UHDlUaMQcKqZ66PMGVe9TeXgXMhGZ3p0o0EBiucnETl5x27LQQzKAJfE831qedq8G5Y8qtbXU8yk2gl8pm0D1KvfgRY7YmCcGL8lmJBVOc15ft5sADoRgBA06YqUp7Iaip3VXCwIdQpD/iP1iz6/a16+jA== 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=xlpp3oox8tLYxz6TyL3i7Joq2cepMbm6CkxqGzFixa8=; b=HH6Bv6DzrhykAkYJh7KRuc3HZB36z02SbNfSYNUN1vWjvg6cOuzTOrcEo+je3YFP3U6iK03/j7NSK4BLbplBvgXPEfvKvP2lV1HlcUQMpGKnnsoKeEo3ULZwK3iTmM4FEFc+bBcQTtwwPz7/i/TVVfZRe+hmeqM/7u3MxyRsb07Ijf1zNZE8m87f2Vfxftuk2/m08E0gHftCZcgcCX+q8NKhpr44iRgL+tKqQ+RJni0OyD6NG7XtcBdCQ9pXPavOp2YTPMR1+pgl/1DPo9bYyYm0gRne11mqNGCj9+TT+bX0G5zbumQd1RA3WzrR8USA1RjL2fPU5dpA+Y2l4oz/eA== 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 KL1PR03MB7765.apcprd03.prod.outlook.com (2603:1096:820:ec::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.25; Wed, 28 Aug 2024 07:41:19 +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.7875.019; Wed, 28 Aug 2024 07:41:19 +0000 From: Jacobe Zang Date: Wed, 28 Aug 2024 15:40:51 +0800 Subject: [PATCH v12 4/5] wifi: brcmfmac: Add optional lpo clock enable support Message-Id: <20240828-wireless-mainline-v12-4-9064ac7acf1d@wesion.com> References: <20240828-wireless-mainline-v12-0-9064ac7acf1d@wesion.com> In-Reply-To: <20240828-wireless-mainline-v12-0-9064ac7acf1d@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, Jacobe Zang , Ondrej Jirman , Sai Krishna X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724830868; l=10253; i=jacobe.zang@wesion.com; s=20240828; h=from:subject:message-id; bh=1EIqUH68e2yHYUoqfpobt6Hzt4qoimWdTYOf3QUUDbM=; b=OxKV0cu8Ty/Fbd2PhjlpUjPVUTIh+eph+/peCxTe93A6LF/sUsfkHknsMRsmL67qu/5lqcbjD ggiYgQa298JATgyYec7I1L1pc8TXq1U6LmTweIYpDqX/zcJDR/i1pDQ X-Developer-Key: i=jacobe.zang@wesion.com; a=ed25519; pk=CkP5TjIqHSwHJwZXTGtadoXZucYvakXcO3HjbR6FoeU= X-ClientProxiedBy: TYCP286CA0372.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:79::20) 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_|KL1PR03MB7765:EE_ X-MS-Office365-Filtering-Correlation-Id: bfef1b6c-e23b-4adf-a280-08dcc734ce45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|1800799024|376014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?KytE4kWeflW6T+eFkbSPq790vYsqYQ/?= =?utf-8?q?AwW9EaoJ7wMS0ijkiZgoFQ74jF/PYThLX5Xtb56aX8oZ73jRkcdZJDvnD10YO4ZE6?= =?utf-8?q?imIfv4g+18CndEIvgAppqjOsgbOqIjJ7XAFV2aKmZ9LxcRWg8CJ4D0GytmUAoV9hj?= =?utf-8?q?81dBiSkMyLNoMRvH4k/LBOOGATz7GuKE+7UF17pFUz6W3TceTKRg9IUITJDj7b+EY?= =?utf-8?q?tdky1rQY/U1Y7QmR3SbCXTYDYKe9XBt4DWpsSOBVb84omMwIDCWW/i9ah/CSjFdcl?= =?utf-8?q?rnsEz5VBPobvf7hXGA7VA77cVQdgibu0KCAhag7DeSctBEmOObsLVsgUwC3IufNB6?= =?utf-8?q?Y53wJf/UzcTnW1MwvJ7Gw58vaxPc/Uuc8oBmCERN/FZfhTuMueDRzB7CYq9WiLzGR?= =?utf-8?q?xo9Lb6WGyWXqQClr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qgwibgv44K3LPjMAxjg14LK7if7tFmLE7srxXQURUt0?= =?utf-8?q?qbGpTcyMmLfGQU9roK5vnhd/hC9gSxxOqnu29BEcrs2Rgd7Wx6fmZDE=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)(52116014)(366016)(1800799024)(376014)(7416014)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?YLQq/Kdrplgh5huhuCr/P3MPZO/m?= =?utf-8?q?QLElc6PsgUZeAe/4vR7mr2ksZqu4OK38BwTyGIZkpdi0sC1f5dGEElnKasu+Ig0y3?= =?utf-8?q?qYOlSsJtmjmilIX4BUFtQ+uTNEW9ekk6GBjxe2g8sPZ4o1tNKUIyRbmsh1J8H8oOj?= =?utf-8?q?+NCiyzLGdRmy9Cuc93g3C4IzJ+cbUM1w0QZJOKgbFr/sOFYmdNIQz0CofdPIP5Vql?= =?utf-8?q?h9sJ6NC5pPaDMz7FBorrV3entVf7gRHgnHBmDjhSmAmZ2eRohR04DrWYutPJIgbnf?= =?utf-8?q?M3PAf6XvWI447sVAjipXDTXDzQJPXIPtLOAFSrs596r0/TlbdMWdv2QZ8XqJPZXXz?= =?utf-8?q?uNgJgmB3EFYXB5OoU9f4egNzf4kRpA3snHaeKCobi3exMGZl1YuOZSF7TR9Ag311k?= =?utf-8?q?jOdCBej4BKlQFEgY0aZECVJR089ZwtNd0GhXVGr2g7z3PtIRYEIL1nf3RzUgBUiJP?= =?utf-8?q?32mUDcyLQC8RR0hYkrmWR9mwmm2vhLNVnVQc9RUG8TdUFzb/9ATpwZl/bh43okgeA?= =?utf-8?q?UM+EzvLQup+1wmaXnbPQON1kdKzqdWThEimTdRznuer1c0W8F9FkcliNievW3O9tD?= =?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7r6s5qwIk6hq0k1+yGzxFb85zgzz+1btGCELbMoaU67hGzH76CfyAysJknLoB?= =?utf-8?q?+1MgS7PqHYGt?= X-OriginatorOrg: wesion.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfef1b6c-e23b-4adf-a280-08dcc734ce45 X-MS-Exchange-CrossTenant-AuthSource: TYZPR03MB7001.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 07:41:19.3490 (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: CoHdBJhJwJzdUsPP6QPHBTbSgFOo2A2IImOh9BmVCMsUYsvMeqjmrkLsKgmZ5218kke928BZ3UYh3U+NICfFsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR03MB7765 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 --- .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 4 +-- .../wireless/broadcom/brcm80211/brcmfmac/common.c | 3 ++- .../net/wireless/broadcom/brcm80211/brcmfmac/of.c | 29 +++++++++++++++------- .../net/wireless/broadcom/brcm80211/brcmfmac/of.h | 9 ++++--- .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 3 +++ .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 20 +++++++++------ .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 3 +++ 7 files changed, 48 insertions(+), 23 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..c1285adabf72b 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,18 +66,22 @@ 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; u32 irqf; u32 val; + if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac")) + return 0; + /* Apple ARM64 platforms have their own idea of board type, passed in * via the device tree. They also have an antenna SKU parameter */ @@ -106,7 +111,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,33 +119,39 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, of_node_put(root); } - if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac")) - return; - err = brcmf_of_get_country_codes(dev, settings); if (err) brcmf_err("failed to get OF country code map (err=%d)\n", err); of_get_mac_address(np, settings->mac); + 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 (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..59c77645e2183 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 @@ -4452,7 +4454,9 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) /* Allocate private bus interface state */ bus = kzalloc(sizeof(*bus), GFP_ATOMIC); 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);