From patchwork Fri Mar 28 17:14:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 3905311 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35401BF540 for ; Fri, 28 Mar 2014 17:13:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F50D202FE for ; Fri, 28 Mar 2014 17:13:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7144120108 for ; Fri, 28 Mar 2014 17:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751697AbaC1RNW (ORCPT ); Fri, 28 Mar 2014 13:13:22 -0400 Received: from mail-ee0-f54.google.com ([74.125.83.54]:36165 "EHLO mail-ee0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751526AbaC1RNV (ORCPT ); Fri, 28 Mar 2014 13:13:21 -0400 Received: by mail-ee0-f54.google.com with SMTP id d49so4304682eek.41 for ; Fri, 28 Mar 2014 10:13:20 -0700 (PDT) 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; bh=/ekGd358zc9iUUyYv1dn2Dd+GIhq1Tuoyy5xkbSdqd0=; b=L8KsP4bhQ3QMA68hyX3TKYYtvo3WLYi1Un18mfzrhewRIHTjKttfHIssh2pS4cJOud SWgH4DY6h2NKt6vLkISTwaAVQ3RekWJoviordHrDZHXO8OJ+MRtjWqyueqIY+t5Cehql GcehSgqLGWclOaMhF+cYUkOhLOpsZiBKWE4uH54tZHCdMXkqkwN7WBKaa5j4+JWcZ+WD 7DZhnX5AaSUNIlPX0v/nTYjCaPEA5iBXSMXkfQJlo0dugjsnrt9+vNnqUX3HnZkWKnbi pOloqmb+e/adJ2DmvdG+3aUROePFoun1fgk2vHjh8e8MQ4h6EBsxnbNqMyP2BzK6wQWa 3iSA== X-Received: by 10.15.50.136 with SMTP id l8mr1493852eew.73.1396026800717; Fri, 28 Mar 2014 10:13:20 -0700 (PDT) Received: from localhost.localdomain (host179-124-dynamic.6-79-r.retail.telecomitalia.it. [79.6.124.179]) by mx.google.com with ESMTPSA id m44sm12864444eep.14.2014.03.28.10.13.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 10:13:20 -0700 (PDT) From: Andrea Merello To: dan.carpenter@oracle.com, linville@tuxdriver.com Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org, andrea.merello@gmail.com Subject: [PATCH 2/2] rtl8180: don't use weird trick to access "far" registers Date: Fri, 28 Mar 2014 18:14:28 +0100 Message-Id: <1396026868-5622-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <20140328093038.GD7045@mwanda> References: <20140328093038.GD7045@mwanda> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 In rtl8180/rtl8185/rtl8187se the register space is represented using packed structure type. Register are thus accessed using a pointer of this type. All registers are packed toghether, and only small gaps are present. However Rtl8187se has also some "sparse" registers, very far from the "main register block". It could be possible to access them by simply declare huge reserved blocks inside the register struct (and this causes NO memory waste). However, for various reasons, access to those "far" registers is done with special dedicated macros, without declaring them in the register struct. This is done in an intricate manner, that makes code less readable and caused static analisys tool to produce warnings. This patch keeps the "macro" mechanism, but it changes its implementation in a simplier and more straightforward way. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl818x.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl818x.h b/drivers/net/wireless/rtl818x/rtl818x.h index 99dbc12..45ea4e1 100644 --- a/drivers/net/wireless/rtl818x/rtl818x.h +++ b/drivers/net/wireless/rtl818x/rtl818x.h @@ -17,13 +17,7 @@ struct rtl818x_csr { - union { - u8 MAC[6]; - u8 offset1[6]; /* upper page indexing helpers */ - __le16 offset2[1]; - __le32 offset4[1]; - } __packed; - + u8 MAC[6]; u8 reserved_0[2]; union { @@ -340,9 +334,9 @@ struct rtl818x_csr { * I don't like to introduce a ton of "reserved".. * They are for RTL8187SE */ -#define REG_ADDR1(addr) ((u8 __iomem *)(&priv->map->offset1[(addr)])) -#define REG_ADDR2(addr) ((__le16 __iomem *)(&priv->map->offset2[((addr) >> 1)])) -#define REG_ADDR4(addr) ((__le32 __iomem *)(&priv->map->offset4[((addr) >> 2)])) +#define REG_ADDR1(addr) ((u8 __iomem *)priv->map + addr) +#define REG_ADDR2(addr) ((__le16 __iomem *)priv->map + (addr >> 1)) +#define REG_ADDR4(addr) ((__le32 __iomem *)priv->map + (addr >> 2)) #define FEMR_SE REG_ADDR2(0x1D4) #define ARFR REG_ADDR2(0x1E0)