From patchwork Sat Jan 28 22:11:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9543515 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3243360415 for ; Sat, 28 Jan 2017 22:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C2602808F for ; Sat, 28 Jan 2017 22:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F4AB28338; Sat, 28 Jan 2017 22:18:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BF772808F for ; Sat, 28 Jan 2017 22:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752424AbdA1WSY (ORCPT ); Sat, 28 Jan 2017 17:18:24 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34727 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752352AbdA1WSW (ORCPT ); Sat, 28 Jan 2017 17:18:22 -0500 Received: by mail-lf0-f67.google.com with SMTP id q89so28613736lfi.1 for ; Sat, 28 Jan 2017 14:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6VFe/5itrRdAg1P04Eop7uyLsclCSolmCDBWVyRBTEs=; b=AJ4egUz470D6O2iqmnSGgFyvsQv/cqjtzC4uWIxVsofZbIRZ8t0ibjQYp5B0dq4yHc AjMR79vzIP8nyoqG5imZ1cwMWJZDQ3LoN5jGJmLA4fuiD1jqTlIf+W9gg9FGJI4ze2CZ QfTH2YTCcXgssORz4chiZpP9+FPxDP0CG9jtSFEd8TUAFE1o+Vq4Z+7cqTGFiVyXrQp0 lzg40LFG1q2+DRa94+wAeB+Zqt4eqjTjI4Jv00jZrNaz1VpT6gsS2hwZbJycUEh0/gQ2 vYorNCkNQtnBilJMLN0XDQ/q+7WWy8d5Q4v2ZOmlSm3E7XkWGmqs9Kjg94/9UxBYHkI2 Ph6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6VFe/5itrRdAg1P04Eop7uyLsclCSolmCDBWVyRBTEs=; b=CFHx3fhRyAn70PX8VhKzAN/GOggOOYP5qrcN5SWEMllTHHULdeK81Wv4yBIusnGyaF uGeMyJf7VXyeAwBmCerMgBRrfED7tDLAlFd1IWL310XPPnBbQvgyae48PzHXF+PpVSYN XNcBsxOXk4FcgWYiOt9owc7tf1MOnE7Bc4QZUApO2AVoJD3aDMjzaBXH/PNjZMd/zn09 B3HpTKVsVY19cTafo2CXhmmDsFVSIp8ENhr6Wcmly5RmDeieV2tn9VqMb7jlZ3rGpgIm QRnoaUCZP7LIor3A1H++UJKNrtxANXkemIW/LeWq3E/Gh2q6Ukr+KeeZsML6Sy20zc8a 5k+w== X-Gm-Message-State: AIkVDXJgD6Q2VMF4NW2HHeIBrlExBfmGTBMuA0bemxQlpLkbh08QjJt1lJqeNsMVXQYXgQ== X-Received: by 10.25.34.196 with SMTP id i187mr4897437lfi.176.1485641510031; Sat, 28 Jan 2017 14:11:50 -0800 (PST) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id u18sm2356344lff.48.2017.01.28.14.11.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jan 2017 14:11:49 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo , linux-wireless@vger.kernel.org Cc: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH] bcma: make OF code more generic (not platform_device specific) Date: Sat, 28 Jan 2017 23:11:34 +0100 Message-Id: <20170128221134.9028-1-zajec5@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafał Miłecki OF allows not only specifying platform devices but also describing devices on standard buses like PCI or USB. This change will allow reading info from DT for bcma buses hosted on PCI cards. Signed-off-by: Rafał Miłecki --- drivers/bcma/main.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index 38688236b3cd..12da68ec48ba 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -136,17 +136,17 @@ static bool bcma_is_core_needed_early(u16 core_id) return false; } -static struct device_node *bcma_of_find_child_device(struct platform_device *parent, +static struct device_node *bcma_of_find_child_device(struct device *parent, struct bcma_device *core) { struct device_node *node; u64 size; const __be32 *reg; - if (!parent || !parent->dev.of_node) + if (!parent->of_node) return NULL; - for_each_child_of_node(parent->dev.of_node, node) { + for_each_child_of_node(parent->of_node, node) { reg = of_get_address(node, 0, &size, NULL); if (!reg) continue; @@ -156,7 +156,7 @@ static struct device_node *bcma_of_find_child_device(struct platform_device *par return NULL; } -static int bcma_of_irq_parse(struct platform_device *parent, +static int bcma_of_irq_parse(struct device *parent, struct bcma_device *core, struct of_phandle_args *out_irq, int num) { @@ -169,7 +169,7 @@ static int bcma_of_irq_parse(struct platform_device *parent, return rc; } - out_irq->np = parent->dev.of_node; + out_irq->np = parent->of_node; out_irq->args_count = 1; out_irq->args[0] = num; @@ -177,13 +177,13 @@ static int bcma_of_irq_parse(struct platform_device *parent, return of_irq_parse_raw(laddr, out_irq); } -static unsigned int bcma_of_get_irq(struct platform_device *parent, +static unsigned int bcma_of_get_irq(struct device *parent, struct bcma_device *core, int num) { struct of_phandle_args out_irq; int ret; - if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent || !parent->dev.of_node) + if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent->of_node) return 0; ret = bcma_of_irq_parse(parent, core, &out_irq, num); @@ -196,7 +196,7 @@ static unsigned int bcma_of_get_irq(struct platform_device *parent, return irq_create_of_mapping(&out_irq); } -static void bcma_of_fill_device(struct platform_device *parent, +static void bcma_of_fill_device(struct device *parent, struct bcma_device *core) { struct device_node *node; @@ -227,7 +227,7 @@ unsigned int bcma_core_irq(struct bcma_device *core, int num) return mips_irq <= 4 ? mips_irq + 2 : 0; } if (bus->host_pdev) - return bcma_of_get_irq(bus->host_pdev, core, num); + return bcma_of_get_irq(&bus->host_pdev->dev, core, num); return 0; case BCMA_HOSTTYPE_SDIO: return 0; @@ -253,7 +253,8 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) { core->dma_dev = &bus->host_pdev->dev; core->dev.parent = &bus->host_pdev->dev; - bcma_of_fill_device(bus->host_pdev, core); + if (core->dev.parent) + bcma_of_fill_device(core->dev.parent, core); } else { core->dev.dma_mask = &core->dev.coherent_dma_mask; core->dma_dev = &core->dev;