From patchwork Fri Jan 16 19:59:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 5650221 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 1B9DE9F3A0 for ; Fri, 16 Jan 2015 20:00:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E6132028D for ; Fri, 16 Jan 2015 19:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A2AD20274 for ; Fri, 16 Jan 2015 19:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754850AbbAPT74 (ORCPT ); Fri, 16 Jan 2015 14:59:56 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:42132 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754794AbbAPT7z (ORCPT ); Fri, 16 Jan 2015 14:59:55 -0500 Received: by mail-wi0-f178.google.com with SMTP id z2so6083558wiv.5 for ; Fri, 16 Jan 2015 11:59:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=rvS1G+LGrxPlTm+N5oMApwG0WiT4qUgYDcTlpgNoNOU=; b=zo2gZcKjEdG8/gqVev9ISwEg2hcAIHK/yoBbRjDoqoya8k/++yDQ/Pic2P4j50HnLM eXbfuw27n0nlf1OZba+DhCqlzJxWtrZn2GUEvzV1cfvyVBmok+sMRbwxjAHDptueaCNZ pOJOcIgUXxjAybldOcIcFz/PRVGmHYICxIvoFBr1cpfeSWhZz06/HoF1GKNJiNVQouAG jyDP2SMSd7lr/aYxAtCdIyz2pfhl7OzVs/ehUrIalIasgAH3W4/aTtGcUZZUCyyIzd9A Sg2hP535vtPwSvGDR1qBvPEiXhSzJUkCg7pcTrGa7LRMKt07+Eq83xEnLtY99kGNWnZO muPA== X-Received: by 10.180.73.101 with SMTP id k5mr9353831wiv.43.1421438394473; Fri, 16 Jan 2015 11:59:54 -0800 (PST) Received: from linux-tdhb.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPSA id x2sm7332166wjx.9.2015.01.16.11.59.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jan 2015 11:59:53 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo , linux-wireless@vger.kernel.org Cc: Hauke Mehrtens , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V2] bcma: clean bus initialization code Date: Fri, 16 Jan 2015 20:59:39 +0100 Message-Id: <1421438379-26211-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1421435929-21499-1-git-send-email-zajec5@gmail.com> References: <1421435929-21499-1-git-send-email-zajec5@gmail.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This moves main bus init code to the main.c and renames old function to make its purpose clear. Thanks to this change we'll also be able to separate scanning from registration (and support PCIe Gen 2 devices) in the future. Signed-off-by: Rafa? Mi?ecki Signed-off-by: Hauke Mehrtens --- V2: Fix typo (s/initialiation/initialization/) Put bcma_detect_chip earlier in .h to match order in .c --- drivers/bcma/bcma_private.h | 3 ++- drivers/bcma/main.c | 16 ++++++++++++---- drivers/bcma/scan.c | 5 +---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h index 314ae40..59422b5 100644 --- a/drivers/bcma/bcma_private.h +++ b/drivers/bcma/bcma_private.h @@ -25,6 +25,7 @@ struct bcma_bus; bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value, int timeout); void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core); +void bcma_init_bus(struct bcma_bus *bus); int bcma_bus_register(struct bcma_bus *bus); void bcma_bus_unregister(struct bcma_bus *bus); int __init bcma_bus_early_register(struct bcma_bus *bus, @@ -36,11 +37,11 @@ int bcma_bus_resume(struct bcma_bus *bus); #endif /* scan.c */ +void bcma_detect_chip(struct bcma_bus *bus); int bcma_bus_scan(struct bcma_bus *bus); int __init bcma_bus_scan_early(struct bcma_bus *bus, struct bcma_device_id *match, struct bcma_device *core); -void bcma_init_bus(struct bcma_bus *bus); /* sprom.c */ int bcma_sprom_get(struct bcma_bus *bus); diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index 534e133..c166d44 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -268,6 +268,18 @@ void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) } } +void bcma_init_bus(struct bcma_bus *bus) +{ + mutex_lock(&bcma_buses_mutex); + bus->num = bcma_bus_next_num++; + mutex_unlock(&bcma_buses_mutex); + + INIT_LIST_HEAD(&bus->cores); + bus->nr_cores = 0; + + bcma_detect_chip(bus); +} + static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core) { int err; @@ -369,10 +381,6 @@ int bcma_bus_register(struct bcma_bus *bus) int err; struct bcma_device *core; - mutex_lock(&bcma_buses_mutex); - bus->num = bcma_bus_next_num++; - mutex_unlock(&bcma_buses_mutex); - /* Scan for devices (cores) */ err = bcma_bus_scan(bus); if (err) { diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c index 9175207..5328ee5 100644 --- a/drivers/bcma/scan.c +++ b/drivers/bcma/scan.c @@ -435,15 +435,12 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr, return 0; } -void bcma_init_bus(struct bcma_bus *bus) +void bcma_detect_chip(struct bcma_bus *bus) { s32 tmp; struct bcma_chipinfo *chipinfo = &(bus->chipinfo); char chip_id[8]; - INIT_LIST_HEAD(&bus->cores); - bus->nr_cores = 0; - bcma_scan_switch_core(bus, BCMA_ADDR_BASE); tmp = bcma_scan_read32(bus, 0, BCMA_CC_ID);