From patchwork Sun Jul 23 18:16:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9858527 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 D9E16603B4 for ; Sun, 23 Jul 2017 18:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D30F32855A for ; Sun, 23 Jul 2017 18:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6CA22855D; Sun, 23 Jul 2017 18:17:35 +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 1312628517 for ; Sun, 23 Jul 2017 18:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbdGWSQn (ORCPT ); Sun, 23 Jul 2017 14:16:43 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37701 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751461AbdGWSQl (ORCPT ); Sun, 23 Jul 2017 14:16:41 -0400 Received: by mail-wr0-f194.google.com with SMTP id 12so7845663wrb.4 for ; Sun, 23 Jul 2017 11:16:40 -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=Gv/qGY2kNy0WFfHFkRVovIaq24fxR89V5YrYd7iDdMI=; b=laibR4NXf1yWcqh749teK13+QtoTSVZxg4K0kfpL/Mth5zIfrRlDpnrTnkKxTVuOv2 ut/RkXgiLAv6KK/YYwOZZhi5Vyyf9Afaosv/+XLnLxTBtzSCTALMoUQ1RphJrEp6P2+g /QZRJk9TqLhsYYqWJVKthhYBYwZV86/IvDIZYiRbcuhHn+FQJhSnNp/aTf3QC4rchsOM 6KixXb3ld8x9L6qFPN+WAMBYqZvo+FmYRn2TNkC1WOKeMLvoTXXzi4R5quyQtmwLOqUX v/uJImGTwynKL7L7UDx7qFScsS6MrXL7L+7o7S5gO+faxMX+DPBjKTYdQ+bNT+1DwW70 tkxg== 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=Gv/qGY2kNy0WFfHFkRVovIaq24fxR89V5YrYd7iDdMI=; b=tqcqfFPOZ7HZb1EhBfVDfuehbbjyWPC6DrNqnQkP2wUe9G53RP9xFeGlB9FqI9sjhv dyx4xdO/p3C/P25+6K68JRP0tEIxKQ/o3HlsXEbliVg8OI9S16N9sC/NKie1fUezcSbh hfXw3wYGxTexMhTHr3HDsDsyJ7l3pDUEEg6iEHdpWP7w5TauXEOx45eI5gpMZSU8qryC RkomcQSiRPE+r01Ps4me3wOPtq5n6Cy7VxP6YFGoA0oKSEGG+w2cEeG+MMYaP8ymVQp0 lTAiq+kU2q5h34lfUvPwphFgyUIboSkeBKCDYwMXEvbJJGVlBoM9P+0+CsMEcfp1epaJ rhHA== X-Gm-Message-State: AIVw111hGqt5VKvLMNYWSdAh9iYQvgWdCYatzFqVwEAqhMiDU4qTwty7 0rKmneStseRMhj+w X-Received: by 10.223.163.10 with SMTP id c10mr12138886wrb.164.1500833799356; Sun, 23 Jul 2017 11:16:39 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Jul 2017 11:16:38 -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 05/14] [media] ddbridge: split off IRQ handling Date: Sun, 23 Jul 2017 20:16:21 +0200 Message-Id: <20170723181630.19526-6-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 This not only helps keep the ddbridge-core tidy, but also gets rid of defined-but-unused-function warnings which might be triggered depending of CONFIG_PCI_MSI, without having to clutter the code with #ifdef'ery. 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/Makefile | 3 +- drivers/media/pci/ddbridge/ddbridge-core.c | 130 ----------------------- drivers/media/pci/ddbridge/ddbridge-irq.c | 161 +++++++++++++++++++++++++++++ drivers/media/pci/ddbridge/ddbridge.h | 12 +-- 4 files changed, 168 insertions(+), 138 deletions(-) create mode 100644 drivers/media/pci/ddbridge/ddbridge-irq.c diff --git a/drivers/media/pci/ddbridge/Makefile b/drivers/media/pci/ddbridge/Makefile index fe8ff0c681ad..0a7caa95a3b6 100644 --- a/drivers/media/pci/ddbridge/Makefile +++ b/drivers/media/pci/ddbridge/Makefile @@ -2,7 +2,8 @@ # Makefile for the ddbridge device driver # -ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-i2c.o +ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-i2c.o \ + ddbridge-irq.o obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 66da4918cd74..d46a81b2f80b 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -2690,136 +2690,6 @@ void ddb_ports_release(struct ddb *dev) /****************************************************************************/ /****************************************************************************/ -#define IRQ_HANDLE(_nr) \ - do { if ((s & (1UL << ((_nr) & 0x1f))) && dev->handler[0][_nr]) \ - dev->handler[0][_nr](dev->handler_data[0][_nr]); } \ - while (0) - -#define IRQ_HANDLE_BYTE(_n) { \ - if (s & (0x000000ff << ((_n) & 0x1f))) { \ - IRQ_HANDLE(0 + (_n)); \ - IRQ_HANDLE(1 + (_n)); \ - IRQ_HANDLE(2 + (_n)); \ - IRQ_HANDLE(3 + (_n)); \ - IRQ_HANDLE(4 + (_n)); \ - IRQ_HANDLE(5 + (_n)); \ - IRQ_HANDLE(6 + (_n)); \ - IRQ_HANDLE(7 + (_n)); \ - } \ - } - -static void irq_handle_msg(struct ddb *dev, u32 s) -{ - dev->i2c_irq++; - IRQ_HANDLE(0); - IRQ_HANDLE(1); - IRQ_HANDLE(2); - IRQ_HANDLE(3); -} - -static void irq_handle_io(struct ddb *dev, u32 s) -{ - dev->ts_irq++; - if ((s & 0x000000f0)) { - IRQ_HANDLE(4); - IRQ_HANDLE(5); - IRQ_HANDLE(6); - IRQ_HANDLE(7); - } - if ((s & 0x0000ff00)) { - IRQ_HANDLE(8); - IRQ_HANDLE(9); - IRQ_HANDLE(10); - IRQ_HANDLE(11); - IRQ_HANDLE(12); - IRQ_HANDLE(13); - IRQ_HANDLE(14); - IRQ_HANDLE(15); - } - if ((s & 0x00ff0000)) { - IRQ_HANDLE(16); - IRQ_HANDLE(17); - IRQ_HANDLE(18); - IRQ_HANDLE(19); - IRQ_HANDLE(20); - IRQ_HANDLE(21); - IRQ_HANDLE(22); - IRQ_HANDLE(23); - } - if ((s & 0xff000000)) { - IRQ_HANDLE(24); - IRQ_HANDLE(25); - IRQ_HANDLE(26); - IRQ_HANDLE(27); - IRQ_HANDLE(28); - IRQ_HANDLE(29); - IRQ_HANDLE(30); - IRQ_HANDLE(31); - } -} - -#ifdef DDB_USE_MSI_IRQHANDLERS -irqreturn_t irq_handler0(int irq, void *dev_id) -{ - struct ddb *dev = (struct ddb *) dev_id; - u32 s = ddbreadl(dev, INTERRUPT_STATUS); - - do { - if (s & 0x80000000) - return IRQ_NONE; - if (!(s & 0xfffff00)) - return IRQ_NONE; - ddbwritel(dev, s & 0xfffff00, INTERRUPT_ACK); - irq_handle_io(dev, s); - } while ((s = ddbreadl(dev, INTERRUPT_STATUS))); - - return IRQ_HANDLED; -} - -irqreturn_t irq_handler1(int irq, void *dev_id) -{ - struct ddb *dev = (struct ddb *) dev_id; - u32 s = ddbreadl(dev, INTERRUPT_STATUS); - - do { - if (s & 0x80000000) - return IRQ_NONE; - if (!(s & 0x0000f)) - return IRQ_NONE; - ddbwritel(dev, s & 0x0000f, INTERRUPT_ACK); - irq_handle_msg(dev, s); - } while ((s = ddbreadl(dev, INTERRUPT_STATUS))); - - return IRQ_HANDLED; -} -#endif - -irqreturn_t irq_handler(int irq, void *dev_id) -{ - struct ddb *dev = (struct ddb *) dev_id; - u32 s = ddbreadl(dev, INTERRUPT_STATUS); - int ret = IRQ_HANDLED; - - if (!s) - return IRQ_NONE; - do { - if (s & 0x80000000) - return IRQ_NONE; - ddbwritel(dev, s, INTERRUPT_ACK); - - if (s & 0x0000000f) - irq_handle_msg(dev, s); - if (s & 0x0fffff00) - irq_handle_io(dev, s); - } while ((s = ddbreadl(dev, INTERRUPT_STATUS))); - - return ret; -} - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - static int reg_wait(struct ddb *dev, u32 reg, u32 bit) { u32 count = 0; diff --git a/drivers/media/pci/ddbridge/ddbridge-irq.c b/drivers/media/pci/ddbridge/ddbridge-irq.c new file mode 100644 index 000000000000..9119b984a5e6 --- /dev/null +++ b/drivers/media/pci/ddbridge/ddbridge-irq.c @@ -0,0 +1,161 @@ +/* + * ddbridge-irq.c: Digital Devices bridge irq handlers + * + * 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ddbridge.h" +#include "ddbridge-regs.h" +#include "ddbridge-io.h" + +/******************************************************************************/ + +#define IRQ_HANDLE(_nr) \ + do { if ((s & (1UL << ((_nr) & 0x1f))) && dev->handler[0][_nr]) \ + dev->handler[0][_nr](dev->handler_data[0][_nr]); } \ + while (0) + +#define IRQ_HANDLE_BYTE(_n) { \ + if (s & (0x000000ff << ((_n) & 0x1f))) { \ + IRQ_HANDLE(0 + (_n)); \ + IRQ_HANDLE(1 + (_n)); \ + IRQ_HANDLE(2 + (_n)); \ + IRQ_HANDLE(3 + (_n)); \ + IRQ_HANDLE(4 + (_n)); \ + IRQ_HANDLE(5 + (_n)); \ + IRQ_HANDLE(6 + (_n)); \ + IRQ_HANDLE(7 + (_n)); \ + } \ + } + +static void irq_handle_msg(struct ddb *dev, u32 s) +{ + dev->i2c_irq++; + IRQ_HANDLE(0); + IRQ_HANDLE(1); + IRQ_HANDLE(2); + IRQ_HANDLE(3); +} + +static void irq_handle_io(struct ddb *dev, u32 s) +{ + dev->ts_irq++; + if ((s & 0x000000f0)) { + IRQ_HANDLE(4); + IRQ_HANDLE(5); + IRQ_HANDLE(6); + IRQ_HANDLE(7); + } + if ((s & 0x0000ff00)) { + IRQ_HANDLE(8); + IRQ_HANDLE(9); + IRQ_HANDLE(10); + IRQ_HANDLE(11); + IRQ_HANDLE(12); + IRQ_HANDLE(13); + IRQ_HANDLE(14); + IRQ_HANDLE(15); + } + if ((s & 0x00ff0000)) { + IRQ_HANDLE(16); + IRQ_HANDLE(17); + IRQ_HANDLE(18); + IRQ_HANDLE(19); + IRQ_HANDLE(20); + IRQ_HANDLE(21); + IRQ_HANDLE(22); + IRQ_HANDLE(23); + } + if ((s & 0xff000000)) { + IRQ_HANDLE(24); + IRQ_HANDLE(25); + IRQ_HANDLE(26); + IRQ_HANDLE(27); + IRQ_HANDLE(28); + IRQ_HANDLE(29); + IRQ_HANDLE(30); + IRQ_HANDLE(31); + } +} + +irqreturn_t irq_handler0(int irq, void *dev_id) +{ + struct ddb *dev = (struct ddb *) dev_id; + u32 s = ddbreadl(dev, INTERRUPT_STATUS); + + do { + if (s & 0x80000000) + return IRQ_NONE; + if (!(s & 0xfffff00)) + return IRQ_NONE; + ddbwritel(dev, s & 0xfffff00, INTERRUPT_ACK); + irq_handle_io(dev, s); + } while ((s = ddbreadl(dev, INTERRUPT_STATUS))); + + return IRQ_HANDLED; +} + +irqreturn_t irq_handler1(int irq, void *dev_id) +{ + struct ddb *dev = (struct ddb *) dev_id; + u32 s = ddbreadl(dev, INTERRUPT_STATUS); + + do { + if (s & 0x80000000) + return IRQ_NONE; + if (!(s & 0x0000f)) + return IRQ_NONE; + ddbwritel(dev, s & 0x0000f, INTERRUPT_ACK); + irq_handle_msg(dev, s); + } while ((s = ddbreadl(dev, INTERRUPT_STATUS))); + + return IRQ_HANDLED; +} + +irqreturn_t irq_handler(int irq, void *dev_id) +{ + struct ddb *dev = (struct ddb *) dev_id; + u32 s = ddbreadl(dev, INTERRUPT_STATUS); + int ret = IRQ_HANDLED; + + if (!s) + return IRQ_NONE; + do { + if (s & 0x80000000) + return IRQ_NONE; + ddbwritel(dev, s, INTERRUPT_ACK); + + if (s & 0x0000000f) + irq_handle_msg(dev, s); + if (s & 0x0fffff00) + irq_handle_io(dev, s); + } while ((s = ddbreadl(dev, INTERRUPT_STATUS))); + + return ret; +} diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index fa471481a572..b0064fa7aadf 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -65,10 +65,6 @@ #define DDBRIDGE_VERSION "0.9.29-integrated" -#ifdef CONFIG_PCI_MSI -#define DDB_USE_MSI_IRQHANDLERS -#endif - #define DDB_MAX_I2C 32 #define DDB_MAX_PORT 32 #define DDB_MAX_INPUT 64 @@ -378,9 +374,6 @@ void ddb_ports_detach(struct ddb *dev); void ddb_ports_release(struct ddb *dev); void ddb_buffers_free(struct ddb *dev); void ddb_device_destroy(struct ddb *dev); -irqreturn_t irq_handler0(int irq, void *dev_id); -irqreturn_t irq_handler1(int irq, void *dev_id); -irqreturn_t irq_handler(int irq, void *dev_id); void ddb_ports_init(struct ddb *dev); int ddb_buffers_alloc(struct ddb *dev); int ddb_ports_attach(struct ddb *dev); @@ -409,4 +402,9 @@ int i2c_write_reg(struct i2c_adapter *adap, u8 adr, void ddb_i2c_release(struct ddb *dev); int ddb_i2c_init(struct ddb *dev); +/* ddbridge-irq.c */ +irqreturn_t irq_handler0(int irq, void *dev_id); +irqreturn_t irq_handler1(int irq, void *dev_id); +irqreturn_t irq_handler(int irq, void *dev_id); + #endif /* DDBRIDGE_H */