From patchwork Wed May 27 17:31:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 6491961 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C19239F399 for ; Wed, 27 May 2015 17:31:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFD3E2064C for ; Wed, 27 May 2015 17:31:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57B4120693 for ; Wed, 27 May 2015 17:31:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752919AbbE0Rbw (ORCPT ); Wed, 27 May 2015 13:31:52 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:39635 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752374AbbE0Rbv (ORCPT ); Wed, 27 May 2015 13:31:51 -0400 X-IronPort-AV: E=Sophos;i="5.13,506,1427785200"; d="scan'208";a="65943757" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 27 May 2015 10:43:14 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.235.1; Wed, 27 May 2015 10:31:48 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.235.1; Wed, 27 May 2015 10:31:48 -0700 Received: from bld-bun-01.bun.broadcom.com (unknown [10.176.128.83]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 0037140FE9; Wed, 27 May 2015 10:29:58 -0700 (PDT) Received: by bld-bun-01.bun.broadcom.com (Postfix, from userid 25152) id 76341B0517E; Wed, 27 May 2015 19:31:45 +0200 (CEST) From: Arend van Spriel To: Kalle Valo CC: linux-wireless , Arend van Spriel , "Fu, Zhonghui" Subject: [PATCH] brcmfmac: fix invalid access to struct acpi_device fields Date: Wed, 27 May 2015 19:31:41 +0200 Message-ID: <1432747901-8472-1-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fields of struct acpi_device are only known when CONFIG_ACPI is defined. Fix this by using a helper function. This will resolve the issue found in linux-next: ../brcmfmac/bcmsdh.c: In function 'brcmf_ops_sdio_probe': ../brcmfmac/bcmsdh.c:1139:7: error: dereferencing pointer to incomplete type adev->flags.power_manageable = 0; ^ Fixes: commit f0992ace680c ("brcmfmac: prohibit ACPI power management ...") Cc: Fu, Zhonghui Reported-by: Stephen Rothwell Signed-off-by: Arend van Spriel --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index b0d0ff5..71779b9 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -1117,6 +1117,18 @@ MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata; +static void brcmf_sdiod_acpi_set_power_manageable(struct device *dev, + int val) +{ +#if IS_ENABLED(CONFIG_ACPI) + struct acpi_device *adev; + + adev = ACPI_COMPANION(dev); + if (adev) + adev->flags.power_manageable = 0; +#endif +} + static int brcmf_ops_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { @@ -1124,7 +1136,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, struct brcmf_sdio_dev *sdiodev; struct brcmf_bus *bus_if; struct device *dev; - struct acpi_device *adev; brcmf_dbg(SDIO, "Enter\n"); brcmf_dbg(SDIO, "Class=%x\n", func->class); @@ -1132,11 +1143,9 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, brcmf_dbg(SDIO, "sdio device ID: 0x%04x\n", func->device); brcmf_dbg(SDIO, "Function#: %d\n", func->num); - /* prohibit ACPI power management for this device */ dev = &func->dev; - adev = ACPI_COMPANION(dev); - if (adev) - adev->flags.power_manageable = 0; + /* prohibit ACPI power management for this device */ + brcmf_sdiod_acpi_set_power_manageable(dev, 0); /* Consume func num 1 but dont do anything with it. */ if (func->num == 1)