From patchwork Sun Jul 23 18:16:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9858541 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 57610603FD for ; Sun, 23 Jul 2017 18:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5120E281B7 for ; Sun, 23 Jul 2017 18:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 464332845C; Sun, 23 Jul 2017 18:17:37 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 E734728503 for ; Sun, 23 Jul 2017 18:17:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751466AbdGWSQl (ORCPT ); Sun, 23 Jul 2017 14:16:41 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33348 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751458AbdGWSQj (ORCPT ); Sun, 23 Jul 2017 14:16:39 -0400 Received: by mail-wr0-f195.google.com with SMTP id y43so15830767wrd.0 for ; Sun, 23 Jul 2017 11:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DG+76e+HIMXsGUyxdSBJa6R+rqvm+qDVe3Ovfzl0r2U=; b=o5RNv37Qx4T7fbvxXbKWznroMUwnteotVeQnIhF7A6mqwDbxcAoElfhiclw6UC1ytB XyFKF6gh8/1z39aMZGjqUqx+gf4isSwl5H+8sVvXpl9CYxXfB+tZ/b8BS7nfpBrgeDw+ KBiEDgCJsH+kJtmDUBbm14pvx7/4/IhqHUZfFxQ8LN+5pisZHfAlxdROm5hURt0IUmir FHVLD6cVZEPsp2Y1HEf//avFwtWwxcMBYu5Wq4BmnQOALrC/iVvPtGzS343W7IgBzW8Y W8VWxS5glmGz4MHlpMZ36M+hnoiU/HRgzJtTsao8v7mqIoZl9etlRI27lVo4iDj+4ec+ IcRQ== 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:in-reply-to :references; bh=DG+76e+HIMXsGUyxdSBJa6R+rqvm+qDVe3Ovfzl0r2U=; b=VM2Kxsm3pM04y9XVYuSkRzmas8MBwr4OpeF9VZHqJRIuMfa9a7Gv5yjbnzZPVk7GzD KfSfJjFLDswOhHDkZJJh4lD3gUYoAJN2aQqW7ShJAaoCz8JiCNsNQoz9eykAk0YCDxYo KxkVFQr763P40t7l7steo3hiMdVA2QKgy5mmnEUuq9fkPiyL6qGRnm2SshXs19FbaO2X iQiE6E3C2uRFcj7lwn3xe5MrJYWPTjFO91UrpLAfczQvgmgmhYqJZphNRVQWOccghTo2 6uDYSft50OfOV0JadaBFTMGll2TdEE+HQpa+mH+Lzrs9fjj4TlrDiGTquLQFk13cbVzJ UBlg== X-Gm-Message-State: AIVw112fMpF5+J/QDKm3HvbbsRnbkOBR6Om0iejk6K+3g1Zh0M7s9uMF 7jaaKgZUmbtR/D// X-Received: by 10.223.176.42 with SMTP id f39mr10083236wra.237.1500833798329; Sun, 23 Jul 2017 11:16:38 -0700 (PDT) Received: from dvbdev.wuest.de (ip-84-118-193-88.unity-media.net. [84.118.193.88]) by smtp.gmail.com with ESMTPSA id 93sm13247338wra.82.2017.07.23.11.16.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Jul 2017 11:16:37 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Cc: r.scobie@clear.net.nz, jasmin@anw.at, d_spingler@freenet.de, Manfred.Knick@t-online.de, rjkm@metzlerbros.de Subject: [PATCH RESEND 04/14] [media] ddbridge: split I/O related functions off from ddbridge.h Date: Sun, 23 Jul 2017 20:16:20 +0200 Message-Id: <20170723181630.19526-5-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170723181630.19526-1-d.scheller.oss@gmail.com> References: <20170723181630.19526-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller While it seems valid that headers can carry simple oneline static inline annotated functions, move them into their own header file to have the overall code more readable. Also, keep them as header (and don't put in a separate object) and static inline to help the compiler avoid generating function calls. (Thanks to Jasmin J. for valuable input on this!) Cc: Jasmin J. Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Tested-by: Jasmin Jessich Tested-by: Dietmar Spingler Tested-by: Manfred Knick --- drivers/media/pci/ddbridge/ddbridge-core.c | 1 + drivers/media/pci/ddbridge/ddbridge-i2c.c | 1 + drivers/media/pci/ddbridge/ddbridge-io.h | 71 ++++++++++++++++++++++++++++++ drivers/media/pci/ddbridge/ddbridge-main.c | 1 + drivers/media/pci/ddbridge/ddbridge.h | 43 ------------------ 5 files changed, 74 insertions(+), 43 deletions(-) create mode 100644 drivers/media/pci/ddbridge/ddbridge-io.h diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index d12deba635bd..66da4918cd74 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -36,6 +36,7 @@ #include "ddbridge.h" #include "ddbridge-regs.h" +#include "ddbridge-io.h" #include "tda18271c2dd.h" #include "stv6110x.h" diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c b/drivers/media/pci/ddbridge/ddbridge-i2c.c index 540bbd211c19..3d0aefe05cec 100644 --- a/drivers/media/pci/ddbridge/ddbridge-i2c.c +++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c @@ -32,6 +32,7 @@ #include "ddbridge.h" #include "ddbridge-regs.h" +#include "ddbridge-io.h" /******************************************************************************/ diff --git a/drivers/media/pci/ddbridge/ddbridge-io.h b/drivers/media/pci/ddbridge/ddbridge-io.h new file mode 100644 index 000000000000..ce92e9484075 --- /dev/null +++ b/drivers/media/pci/ddbridge/ddbridge-io.h @@ -0,0 +1,71 @@ +/* + * ddbridge-io.h: Digital Devices bridge I/O inline functions + * + * Copyright (C) 2010-2017 Digital Devices GmbH + * Ralph Metzler + * Marcus Metzler + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 only, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __DDBRIDGE_IO_H__ +#define __DDBRIDGE_IO_H__ + +#include + +#include "ddbridge.h" + +/******************************************************************************/ + +static inline u32 ddblreadl(struct ddb_link *link, u32 adr) +{ + return readl((char *) (link->dev->regs + (adr))); +} + +static inline void ddblwritel(struct ddb_link *link, u32 val, u32 adr) +{ + writel(val, (char *) (link->dev->regs + (adr))); +} + +static inline u32 ddbreadl(struct ddb *dev, u32 adr) +{ + return readl((char *) (dev->regs + (adr))); +} + +static inline void ddbwritel(struct ddb *dev, u32 val, u32 adr) +{ + writel(val, (char *) (dev->regs + (adr))); +} + +static inline void ddbcpyto(struct ddb *dev, u32 adr, void *src, long count) +{ + return memcpy_toio((char *) (dev->regs + adr), src, count); +} + +static inline void ddbcpyfrom(struct ddb *dev, void *dst, u32 adr, long count) +{ + return memcpy_fromio(dst, (char *) (dev->regs + adr), count); +} + +static inline u32 safe_ddbreadl(struct ddb *dev, u32 adr) +{ + u32 val = ddbreadl(dev, adr); + + /* (ddb)readl returns (uint)-1 (all bits set) on failure, catch that */ + if (val == ~0) { + dev_err(&dev->pdev->dev, "ddbreadl failure, adr=%08x\n", adr); + return 0; + } + + return val; +} + +#endif /* __DDBRIDGE_IO_H__ */ diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c index 8262979b6257..de9da6077ec6 100644 --- a/drivers/media/pci/ddbridge/ddbridge-main.c +++ b/drivers/media/pci/ddbridge/ddbridge-main.c @@ -34,6 +34,7 @@ #include "ddbridge.h" #include "ddbridge-regs.h" +#include "ddbridge-io.h" /****************************************************************************/ /* module parameters */ diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index 7fe5820a78ff..fa471481a572 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -353,49 +353,6 @@ struct ddb { u8 tsbuf[TS_CAPTURE_LEN]; }; -static inline u32 ddblreadl(struct ddb_link *link, u32 adr) -{ - return readl((char *) (link->dev->regs + (adr))); -} - -static inline void ddblwritel(struct ddb_link *link, u32 val, u32 adr) -{ - writel(val, (char *) (link->dev->regs + (adr))); -} - -static inline u32 ddbreadl(struct ddb *dev, u32 adr) -{ - return readl((char *) (dev->regs + (adr))); -} - -static inline void ddbwritel(struct ddb *dev, u32 val, u32 adr) -{ - writel(val, (char *) (dev->regs + (adr))); -} - -static inline void ddbcpyto(struct ddb *dev, u32 adr, void *src, long count) -{ - return memcpy_toio((char *) (dev->regs + adr), src, count); -} - -static inline void ddbcpyfrom(struct ddb *dev, void *dst, u32 adr, long count) -{ - return memcpy_fromio(dst, (char *) (dev->regs + adr), count); -} - -static inline u32 safe_ddbreadl(struct ddb *dev, u32 adr) -{ - u32 val = ddbreadl(dev, adr); - - /* (ddb)readl returns (uint)-1 (all bits set) on failure, catch that */ - if (val == ~0) { - dev_err(&dev->pdev->dev, "ddbreadl failure, adr=%08x\n", adr); - return 0; - } - - return val; -} - /****************************************************************************/ /****************************************************************************/ /****************************************************************************/