fedoraproject@6speed.de / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
e336be
From 76202e874f06ab641fbe1caaddd4cfcf7158f174 Mon Sep 17 00:00:00 2001
e336be
From: Hans de Goede <hdegoede@redhat.com>
e336be
Date: Wed, 10 Oct 2018 13:00:58 +0200
e336be
Subject: [PATCH 1/5] brcmfmac: Remove firmware-loading code duplication
e336be
e336be
brcmf_fw_request_next_item and brcmf_fw_request_done both have identical
e336be
code to complete the fw-request depending on the item-type.
e336be
e336be
This commit adds a new brcmf_fw_complete_request helper removing this code
e336be
duplication.
e336be
e336be
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e336be
---
e336be
 .../broadcom/brcm80211/brcmfmac/firmware.c    | 62 +++++++++----------
e336be
 1 file changed, 31 insertions(+), 31 deletions(-)
e336be
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
index 9095b830ae4d..784c84f0e9e7 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
@@ -504,6 +504,34 @@ static int brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
e336be
 	return -ENOENT;
e336be
 }
e336be
 
e336be
+static int brcmf_fw_complete_request(const struct firmware *fw,
e336be
+				     struct brcmf_fw *fwctx)
e336be
+{
e336be
+	struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
e336be
+	int ret = 0;
e336be
+
e336be
+	brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path, fw ? "" : "not ");
e336be
+
e336be
+	switch (cur->type) {
e336be
+	case BRCMF_FW_TYPE_NVRAM:
e336be
+		ret = brcmf_fw_request_nvram_done(fw, fwctx);
e336be
+		break;
e336be
+	case BRCMF_FW_TYPE_BINARY:
e336be
+		if (fw)
e336be
+			cur->binary = fw;
e336be
+		else
e336be
+			ret = -ENOENT;
e336be
+		break;
e336be
+	default:
e336be
+		/* something fishy here so bail out early */
e336be
+		brcmf_err("unknown fw type: %d\n", cur->type);
e336be
+		release_firmware(fw);
e336be
+		ret = -EINVAL;
e336be
+	}
e336be
+
e336be
+	return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
e336be
+}
e336be
+
e336be
 static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
e336be
 {
e336be
 	struct brcmf_fw_item *cur;
e336be
@@ -525,15 +553,7 @@ static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
e336be
 	if (ret < 0) {
e336be
 		brcmf_fw_request_done(NULL, fwctx);
e336be
 	} else if (!async && fw) {
e336be
-		brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path,
e336be
-			  fw ? "" : "not ");
e336be
-		if (cur->type == BRCMF_FW_TYPE_BINARY)
e336be
-			cur->binary = fw;
e336be
-		else if (cur->type == BRCMF_FW_TYPE_NVRAM)
e336be
-			brcmf_fw_request_nvram_done(fw, fwctx);
e336be
-		else
e336be
-			release_firmware(fw);
e336be
-
e336be
+		brcmf_fw_complete_request(fw, fwctx);
e336be
 		return -EAGAIN;
e336be
 	}
e336be
 	return 0;
e336be
@@ -547,28 +567,8 @@ static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
e336be
 
e336be
 	cur = &fwctx->req->items[fwctx->curpos];
e336be
 
e336be
-	brcmf_dbg(TRACE, "enter: firmware %s %sfound\n", cur->path,
e336be
-		  fw ? "" : "not ");
e336be
-
e336be
-	if (!fw)
e336be
-		ret = -ENOENT;
e336be
-
e336be
-	switch (cur->type) {
e336be
-	case BRCMF_FW_TYPE_NVRAM:
e336be
-		ret = brcmf_fw_request_nvram_done(fw, fwctx);
e336be
-		break;
e336be
-	case BRCMF_FW_TYPE_BINARY:
e336be
-		cur->binary = fw;
e336be
-		break;
e336be
-	default:
e336be
-		/* something fishy here so bail out early */
e336be
-		brcmf_err("unknown fw type: %d\n", cur->type);
e336be
-		release_firmware(fw);
e336be
-		ret = -EINVAL;
e336be
-		goto fail;
e336be
-	}
e336be
-
e336be
-	if (ret < 0 && !(cur->flags & BRCMF_FW_REQF_OPTIONAL))
e336be
+	ret = brcmf_fw_complete_request(fw, fwctx);
e336be
+	if (ret < 0)
e336be
 		goto fail;
e336be
 
e336be
 	do {
e336be
-- 
e336be
2.19.1
e336be
e336be
From a3c4b522bff976360fb21c9205fcb37a121d4074 Mon Sep 17 00:00:00 2001
e336be
From: Hans de Goede <hdegoede@redhat.com>
e336be
Date: Wed, 10 Oct 2018 13:00:59 +0200
e336be
Subject: [PATCH 2/5] brcmfmac: Remove recursion from firmware load error
e336be
 handling
e336be
e336be
Before this commit brcmf_fw_request_done would call
e336be
brcmf_fw_request_next_item to load the next item, which on an error would
e336be
call brcmf_fw_request_done, which if the error is recoverable (*) will
e336be
then continue calling brcmf_fw_request_next_item for the next item again
e336be
which on an error will call brcmf_fw_request_done again...
e336be
e336be
This does not blow up because we only have a limited number of items so
e336be
we never recurse too deep. But the recursion is still quite ugly and
e336be
frankly is giving me a headache, so lets fix this.
e336be
e336be
This commit fixes this by removing brcmf_fw_request_next_item and by
e336be
making brcmf_fw_get_firmwares and brcmf_fw_request_done directly call
e336be
firmware_request_nowait resp. firmware_request themselves.
e336be
e336be
*) brcmf_fw_request_nvram_done fallback path succeeds or
e336be
   BRCMF_FW_REQF_OPTIONAL is set
e336be
e336be
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e336be
---
e336be
 .../broadcom/brcm80211/brcmfmac/firmware.c    | 65 ++++++-------------
e336be
 1 file changed, 19 insertions(+), 46 deletions(-)
e336be
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
index 784c84f0e9e7..08aaf99fee34 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
@@ -532,33 +532,6 @@ static int brcmf_fw_complete_request(const struct firmware *fw,
e336be
 	return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
e336be
 }
e336be
 
e336be
-static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
e336be
-{
e336be
-	struct brcmf_fw_item *cur;
e336be
-	const struct firmware *fw = NULL;
e336be
-	int ret;
e336be
-
e336be
-	cur = &fwctx->req->items[fwctx->curpos];
e336be
-
e336be
-	brcmf_dbg(TRACE, "%srequest for %s\n", async ? "async " : "",
e336be
-		  cur->path);
e336be
-
e336be
-	if (async)
e336be
-		ret = request_firmware_nowait(THIS_MODULE, true, cur->path,
e336be
-					      fwctx->dev, GFP_KERNEL, fwctx,
e336be
-					      brcmf_fw_request_done);
e336be
-	else
e336be
-		ret = request_firmware(&fw, cur->path, fwctx->dev);
e336be
-
e336be
-	if (ret < 0) {
e336be
-		brcmf_fw_request_done(NULL, fwctx);
e336be
-	} else if (!async && fw) {
e336be
-		brcmf_fw_complete_request(fw, fwctx);
e336be
-		return -EAGAIN;
e336be
-	}
e336be
-	return 0;
e336be
-}
e336be
-
e336be
 static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
e336be
 {
e336be
 	struct brcmf_fw *fwctx = ctx;
e336be
@@ -568,26 +541,19 @@ static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
e336be
 	cur = &fwctx->req->items[fwctx->curpos];
e336be
 
e336be
 	ret = brcmf_fw_complete_request(fw, fwctx);
e336be
-	if (ret < 0)
e336be
-		goto fail;
e336be
-
e336be
-	do {
e336be
-		if (++fwctx->curpos == fwctx->req->n_items) {
e336be
-			ret = 0;
e336be
-			goto done;
e336be
-		}
e336be
 
e336be
-		ret = brcmf_fw_request_next_item(fwctx, false);
e336be
-	} while (ret == -EAGAIN);
e336be
-
e336be
-	return;
e336be
+	while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) {
e336be
+		cur = &fwctx->req->items[fwctx->curpos];
e336be
+		request_firmware(&fw, cur->path, fwctx->dev);
e336be
+		ret = brcmf_fw_complete_request(fw, ctx);
e336be
+	}
e336be
 
e336be
-fail:
e336be
-	brcmf_dbg(TRACE, "failed err=%d: dev=%s, fw=%s\n", ret,
e336be
-		  dev_name(fwctx->dev), cur->path);
e336be
-	brcmf_fw_free_request(fwctx->req);
e336be
-	fwctx->req = NULL;
e336be
-done:
e336be
+	if (ret) {
e336be
+		brcmf_dbg(TRACE, "failed err=%d: dev=%s, fw=%s\n", ret,
e336be
+			  dev_name(fwctx->dev), cur->path);
e336be
+		brcmf_fw_free_request(fwctx->req);
e336be
+		fwctx->req = NULL;
e336be
+	}
e336be
 	fwctx->done(fwctx->dev, ret, fwctx->req);
e336be
 	kfree(fwctx);
e336be
 }
e336be
@@ -611,7 +577,9 @@ int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
e336be
 			   void (*fw_cb)(struct device *dev, int err,
e336be
 					 struct brcmf_fw_request *req))
e336be
 {
e336be
+	struct brcmf_fw_item *first = &req->items[0];
e336be
 	struct brcmf_fw *fwctx;
e336be
+	int ret;
e336be
 
e336be
 	brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
e336be
 	if (!fw_cb)
e336be
@@ -628,7 +596,12 @@ int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
e336be
 	fwctx->req = req;
e336be
 	fwctx->done = fw_cb;
e336be
 
e336be
-	brcmf_fw_request_next_item(fwctx, true);
e336be
+	ret = request_firmware_nowait(THIS_MODULE, true, first->path,
e336be
+				      fwctx->dev, GFP_KERNEL, fwctx,
e336be
+				      brcmf_fw_request_done);
e336be
+	if (ret < 0)
e336be
+		brcmf_fw_request_done(NULL, fwctx);
e336be
+
e336be
 	return 0;
e336be
 }
e336be
 
e336be
-- 
e336be
2.19.1
e336be
e336be
From c2c41d3f837ed492369607940af950ef554b8685 Mon Sep 17 00:00:00 2001
e336be
From: Hans de Goede <hdegoede@redhat.com>
e336be
Date: Wed, 10 Oct 2018 13:01:00 +0200
e336be
Subject: [PATCH 3/5] brcmfmac: Add support for first trying to get a board
e336be
 specific nvram file
e336be
e336be
The nvram files which some brcmfmac chips need are board-specific. To be
e336be
able to distribute these as part of linux-firmware, so that devices with
e336be
such a wifi chip will work OOTB, multiple (one per board) versions must
e336be
co-exist under /lib/firmware.
e336be
e336be
This commit adds support for callers of the brcmfmac/firmware.c code to
e336be
pass in a board_type parameter through the request structure.
e336be
e336be
If that parameter is set then the code will first try to load
e336be
chipmodel.board_type.txt before falling back to the old chipmodel.txt name.
e336be
e336be
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e336be
---
e336be
 .../broadcom/brcm80211/brcmfmac/firmware.c    | 27 ++++++++++++++++++-
e336be
 .../broadcom/brcm80211/brcmfmac/firmware.h    |  1 +
e336be
 2 files changed, 27 insertions(+), 1 deletion(-)
e336be
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
index 08aaf99fee34..6755b2388fbc 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
@@ -532,6 +532,31 @@ static int brcmf_fw_complete_request(const struct firmware *fw,
e336be
 	return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
e336be
 }
e336be
 
e336be
+static int brcmf_fw_request_firmware(const struct firmware **fw,
e336be
+				     struct brcmf_fw *fwctx)
e336be
+{
e336be
+	struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
e336be
+	int ret;
e336be
+
e336be
+	/* nvram files are board-specific, first try a board-specific path */
e336be
+	if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) {
e336be
+		char alt_path[BRCMF_FW_NAME_LEN];
e336be
+
e336be
+		strlcpy(alt_path, cur->path, BRCMF_FW_NAME_LEN);
e336be
+		/* strip .txt at the end */
e336be
+		alt_path[strlen(alt_path) - 4] = 0;
e336be
+		strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
e336be
+		strlcat(alt_path, fwctx->req->board_type, BRCMF_FW_NAME_LEN);
e336be
+		strlcat(alt_path, ".txt", BRCMF_FW_NAME_LEN);
e336be
+
e336be
+		ret = request_firmware(fw, alt_path, fwctx->dev);
e336be
+		if (ret == 0)
e336be
+			return ret;
e336be
+	}
e336be
+
e336be
+	return request_firmware(fw, cur->path, fwctx->dev);
e336be
+}
e336be
+
e336be
 static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
e336be
 {
e336be
 	struct brcmf_fw *fwctx = ctx;
e336be
@@ -544,7 +569,7 @@ static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
e336be
 
e336be
 	while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) {
e336be
 		cur = &fwctx->req->items[fwctx->curpos];
e336be
-		request_firmware(&fw, cur->path, fwctx->dev);
e336be
+		brcmf_fw_request_firmware(&fw, fwctx);
e336be
 		ret = brcmf_fw_complete_request(fw, ctx);
e336be
 	}
e336be
 
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
e336be
index 2893e56910f0..a0834be8864e 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
e336be
@@ -70,6 +70,7 @@ struct brcmf_fw_request {
e336be
 	u16 domain_nr;
e336be
 	u16 bus_nr;
e336be
 	u32 n_items;
e336be
+	const char *board_type;
e336be
 	struct brcmf_fw_item items[0];
e336be
 };
e336be
 
e336be
-- 
e336be
2.19.1
e336be
e336be
From 282477a8e4034ee2ea906d2eb234ce9c86f5685f Mon Sep 17 00:00:00 2001
e336be
From: Peter Robinson <pbrobinson@gmail.com>
e336be
Date: Sat, 17 Nov 2018 15:18:35 +0000
e336be
Subject: [PATCH 4/5] brcmfmac: Set board_type used for nvram file selection to
e336be
 machine-compatible
e336be
e336be
For of/devicetree using machines, set the board_type used for nvram file
e336be
selection to the first string listed in the top-level's node compatible
e336be
string, aka the machine-compatible as used by of_machine_is_compatible().
e336be
e336be
The board_type setting is used to load the board-specific nvram file with
e336be
a board-specific name so that we can ship files for each supported board
e336be
in linux-firmware.
e336be
e336be
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e336be
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
e336be
---
e336be
 .../broadcom/brcm80211/brcmfmac/Makefile      |   2 +
e336be
 .../broadcom/brcm80211/brcmfmac/common.c      |   3 +-
e336be
 .../broadcom/brcm80211/brcmfmac/common.h      |   8 ++
e336be
 .../broadcom/brcm80211/brcmfmac/dmi.c         | 116 ++++++++++++++++++
e336be
 .../wireless/broadcom/brcm80211/brcmfmac/of.c |  11 +-
e336be
 .../broadcom/brcm80211/brcmfmac/pcie.c        |   1 +
e336be
 .../broadcom/brcm80211/brcmfmac/sdio.c        |   1 +
e336be
 7 files changed, 140 insertions(+), 2 deletions(-)
e336be
 create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c
e336be
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
e336be
index 1f5a9b948abf..22fd95a736a8 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile
e336be
@@ -54,3 +54,5 @@ brcmfmac-$(CONFIG_BRCM_TRACING) += \
e336be
 		tracepoint.o
e336be
 brcmfmac-$(CONFIG_OF) += \
e336be
 		of.o
e336be
+brcmfmac-$(CONFIG_DMI) += \
e336be
+		dmi.o
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
e336be
index cd3651069d0c..b93b1e797333 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
e336be
@@ -450,7 +450,8 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
e336be
 		}
e336be
 	}
e336be
 	if (!found) {
e336be
-		/* No platform data for this device, try OF (Open Firwmare) */
e336be
+		/* No platform data for this device, try OF and DMI data */
e336be
+		brcmf_dmi_probe(settings, chip, chiprev);
e336be
 		brcmf_of_probe(dev, bus_type, settings);
e336be
 	}
e336be
 	return settings;
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
e336be
index a34642cb4d2f..4ce56be90b74 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
e336be
@@ -59,6 +59,7 @@ struct brcmf_mp_device {
e336be
 	bool		iapp;
e336be
 	bool		ignore_probe_fail;
e336be
 	struct brcmfmac_pd_cc *country_codes;
e336be
+	const char	*board_type;
e336be
 	union {
e336be
 		struct brcmfmac_sdio_pd sdio;
e336be
 	} bus;
e336be
@@ -74,4 +75,11 @@ void brcmf_release_module_param(struct brcmf_mp_device *module_param);
e336be
 /* Sets dongle media info (drv_version, mac address). */
e336be
 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
e336be
 
e336be
+#ifdef CONFIG_DMI
e336be
+void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev);
e336be
+#else
e336be
+static inline void
e336be
+brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev) {}
e336be
+#endif
e336be
+
e336be
 #endif /* BRCMFMAC_COMMON_H */
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c
e336be
new file mode 100644
e336be
index 000000000000..51d76ac45075
e336be
--- /dev/null
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c
e336be
@@ -0,0 +1,116 @@
e336be
+/*
e336be
+ * Copyright 2018 Hans de Goede <hdegoede@redhat.com>
e336be
+ *
e336be
+ * Permission to use, copy, modify, and/or distribute this software for any
e336be
+ * purpose with or without fee is hereby granted, provided that the above
e336be
+ * copyright notice and this permission notice appear in all copies.
e336be
+ *
e336be
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
e336be
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
e336be
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
e336be
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
e336be
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
e336be
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
e336be
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
e336be
+ */
e336be
+
e336be
+#include <linux/dmi.h>
e336be
+#include <linux/mod_devicetable.h>
e336be
+#include "core.h"
e336be
+#include "common.h"
e336be
+#include "brcm_hw_ids.h"
e336be
+
e336be
+/* The DMI data never changes so we can use a static buf for this */
e336be
+static char dmi_board_type[128];
e336be
+
e336be
+struct brcmf_dmi_data {
e336be
+	u32 chip;
e336be
+	u32 chiprev;
e336be
+	const char *board_type;
e336be
+};
e336be
+
e336be
+/* NOTE: Please keep all entries sorted alphabetically */
e336be
+
e336be
+static const struct brcmf_dmi_data gpd_win_pocket_data = {
e336be
+	BRCM_CC_4356_CHIP_ID, 2, "gpd-win-pocket"
e336be
+};
e336be
+
e336be
+static const struct brcmf_dmi_data jumper_ezpad_mini3_data = {
e336be
+	BRCM_CC_43430_CHIP_ID, 0, "jumper-ezpad-mini3"
e336be
+};
e336be
+
e336be
+static const struct brcmf_dmi_data meegopad_t08_data = {
e336be
+	BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08"
e336be
+};
e336be
+
e336be
+static const struct dmi_system_id dmi_platform_data[] = {
e336be
+	{
e336be
+		/* Match for the GPDwin which unfortunately uses somewhat
e336be
+		 * generic dmi strings, which is why we test for 4 strings.
e336be
+		 * Comparing against 23 other byt/cht boards, board_vendor
e336be
+		 * and board_name are unique to the GPDwin, where as only one
e336be
+		 * other board has the same board_serial and 3 others have
e336be
+		 * the same default product_name. Also the GPDwin is the
e336be
+		 * only device to have both board_ and product_name not set.
e336be
+		 */
e336be
+		.matches = {
e336be
+			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
e336be
+			DMI_MATCH(DMI_BOARD_NAME, "Default string"),
e336be
+			DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
e336be
+			DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
e336be
+		},
e336be
+		.driver_data = (void *)&gpd_win_pocket_data,
e336be
+	},
e336be
+	{
e336be
+		/* Jumper EZpad mini3 */
e336be
+		.matches = {
e336be
+			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
e336be
+			DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
e336be
+			/* jumperx.T87.KFBNEEA02 with the version-nr dropped */
e336be
+			DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
e336be
+		},
e336be
+		.driver_data = (void *)&jumper_ezpad_mini3_data,
e336be
+	},
e336be
+	{
e336be
+		/* Meegopad T08 */
e336be
+		.matches = {
e336be
+			DMI_MATCH(DMI_SYS_VENDOR, "Default string"),
e336be
+			DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
e336be
+			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
e336be
+			DMI_MATCH(DMI_BOARD_VERSION, "V1.1"),
e336be
+		},
e336be
+		.driver_data = (void *)&meegopad_t08_data,
e336be
+	},
e336be
+	{}
e336be
+};
e336be
+
e336be
+void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev)
e336be
+{
e336be
+	const struct dmi_system_id *match;
e336be
+	const struct brcmf_dmi_data *data;
e336be
+	const char *sys_vendor;
e336be
+	const char *product_name;
e336be
+
e336be
+	/* Some models have DMI strings which are too generic, e.g.
e336be
+	 * "Default string", we use a quirk table for these.
e336be
+	 */
e336be
+	for (match = dmi_first_match(dmi_platform_data);
e336be
+	     match;
e336be
+	     match = dmi_first_match(match + 1)) {
e336be
+		data = match->driver_data;
e336be
+
e336be
+		if (data->chip == chip && data->chiprev == chiprev) {
e336be
+			settings->board_type = data->board_type;
e336be
+			return;
e336be
+		}
e336be
+	}
e336be
+
e336be
+	/* Not found in the quirk-table, use sys_vendor-product_name */
e336be
+	sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
e336be
+	product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
e336be
+	if (sys_vendor && product_name) {
e336be
+		snprintf(dmi_board_type, sizeof(dmi_board_type), "%s-%s",
e336be
+			 sys_vendor, product_name);
e336be
+		settings->board_type = dmi_board_type;
e336be
+	}
e336be
+}
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
e336be
index aee6e5937c41..84e3373289eb 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
e336be
@@ -27,11 +27,20 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
e336be
 		    struct brcmf_mp_device *settings)
e336be
 {
e336be
 	struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;
e336be
-	struct device_node *np = dev->of_node;
e336be
+	struct device_node *root, *np = dev->of_node;
e336be
+	struct property *prop;
e336be
 	int irq;
e336be
 	u32 irqf;
e336be
 	u32 val;
e336be
 
e336be
+	/* Set board-type to the first string of the machine compatible prop */
e336be
+	root = of_find_node_by_path("/");
e336be
+	if (root) {
e336be
+		prop = of_find_property(root, "compatible", NULL);
e336be
+		settings->board_type = of_prop_next_string(prop, NULL);
e336be
+		of_node_put(root);
e336be
+	}
e336be
+
e336be
 	if (!np || bus_type != BRCMF_BUSTYPE_SDIO ||
e336be
 	    !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
e336be
 		return;
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
e336be
index 4fffa6988087..b12f3e0ee69c 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
e336be
@@ -1785,6 +1785,7 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
e336be
 	fwreq->items[BRCMF_PCIE_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
e336be
 	fwreq->items[BRCMF_PCIE_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
e336be
 	fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL;
e336be
+	fwreq->board_type = devinfo->settings->board_type;
e336be
 	/* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */
e336be
 	fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
e336be
 	fwreq->bus_nr = devinfo->pdev->bus->number;
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
e336be
index a907d7b065fa..3dbbbb117563 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
e336be
@@ -4177,6 +4177,7 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)
e336be
 
e336be
 	fwreq->items[BRCMF_SDIO_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
e336be
 	fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
e336be
+	fwreq->board_type = bus->sdiodev->settings->board_type;
e336be
 
e336be
 	return fwreq;
e336be
 }
e336be
-- 
e336be
2.19.1
e336be
e336be
From 6351ca678eb1391129cf5afccab518f376d57596 Mon Sep 17 00:00:00 2001
e336be
From: Hans de Goede <hdegoede@redhat.com>
e336be
Date: Wed, 10 Oct 2018 13:01:03 +0200
e336be
Subject: [PATCH 5/5] brcmfmac: Cleanup brcmf_fw_request_done()
e336be
e336be
The "cur" variable is now only used for a debug print and we already
e336be
print the same info from brcmf_fw_complete_request(), so the debug print
e336be
does not provide any extra info and we can remove it.
e336be
e336be
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e336be
---
e336be
 .../net/wireless/broadcom/brcm80211/brcmfmac/firmware.c   | 8 +-------
e336be
 1 file changed, 1 insertion(+), 7 deletions(-)
e336be
e336be
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
index 6755b2388fbc..b38c4b40b235 100644
e336be
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
e336be
@@ -560,22 +560,16 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
e336be
 static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
e336be
 {
e336be
 	struct brcmf_fw *fwctx = ctx;
e336be
-	struct brcmf_fw_item *cur;
e336be
-	int ret = 0;
e336be
-
e336be
-	cur = &fwctx->req->items[fwctx->curpos];
e336be
+	int ret;
e336be
 
e336be
 	ret = brcmf_fw_complete_request(fw, fwctx);
e336be
 
e336be
 	while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) {
e336be
-		cur = &fwctx->req->items[fwctx->curpos];
e336be
 		brcmf_fw_request_firmware(&fw, fwctx);
e336be
 		ret = brcmf_fw_complete_request(fw, ctx);
e336be
 	}
e336be
 
e336be
 	if (ret) {
e336be
-		brcmf_dbg(TRACE, "failed err=%d: dev=%s, fw=%s\n", ret,
e336be
-			  dev_name(fwctx->dev), cur->path);
e336be
 		brcmf_fw_free_request(fwctx->req);
e336be
 		fwctx->req = NULL;
e336be
 	}
e336be
-- 
e336be
2.19.1
e336be