mac80211: backport today's brcmfmac changes
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 374-brcmfmac-fix-invalid-access-to-struct-acpi_device-fi.patch
1 From: Arend van Spriel <arend@broadcom.com>
2 Date: Wed, 27 May 2015 19:31:41 +0200
3 Subject: [PATCH] brcmfmac: fix invalid access to struct acpi_device fields
4
5 The fields of struct acpi_device are only known when CONFIG_ACPI is
6 defined. Fix this by using a helper function. This will resolve the
7 issue found in linux-next:
8
9 ../brcmfmac/bcmsdh.c: In function 'brcmf_ops_sdio_probe':
10 ../brcmfmac/bcmsdh.c:1139:7: error: dereferencing pointer to incomplete type
11 adev->flags.power_manageable = 0;
12 ^
13
14 Fixes: f0992ace680c ("brcmfmac: prohibit ACPI power management ...")
15 Cc: Fu, Zhonghui <zhonghui.fu@linux.intel.com>
16 Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
17 Signed-off-by: Arend van Spriel <arend@broadcom.com>
18 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
19 ---
20
21 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
22 +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
23 @@ -1117,6 +1117,18 @@ MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_id
24 static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata;
25
26
27 +static void brcmf_sdiod_acpi_set_power_manageable(struct device *dev,
28 + int val)
29 +{
30 +#if IS_ENABLED(CONFIG_ACPI)
31 + struct acpi_device *adev;
32 +
33 + adev = ACPI_COMPANION(dev);
34 + if (adev)
35 + adev->flags.power_manageable = 0;
36 +#endif
37 +}
38 +
39 static int brcmf_ops_sdio_probe(struct sdio_func *func,
40 const struct sdio_device_id *id)
41 {
42 @@ -1124,7 +1136,6 @@ static int brcmf_ops_sdio_probe(struct s
43 struct brcmf_sdio_dev *sdiodev;
44 struct brcmf_bus *bus_if;
45 struct device *dev;
46 - struct acpi_device *adev;
47
48 brcmf_dbg(SDIO, "Enter\n");
49 brcmf_dbg(SDIO, "Class=%x\n", func->class);
50 @@ -1132,11 +1143,9 @@ static int brcmf_ops_sdio_probe(struct s
51 brcmf_dbg(SDIO, "sdio device ID: 0x%04x\n", func->device);
52 brcmf_dbg(SDIO, "Function#: %d\n", func->num);
53
54 - /* prohibit ACPI power management for this device */
55 dev = &func->dev;
56 - adev = ACPI_COMPANION(dev);
57 - if (adev)
58 - adev->flags.power_manageable = 0;
59 + /* prohibit ACPI power management for this device */
60 + brcmf_sdiod_acpi_set_power_manageable(dev, 0);
61
62 /* Consume func num 1 but dont do anything with it. */
63 if (func->num == 1)