From patchwork Mon Apr 2 18:24:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10320179 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 09B8260116 for ; Mon, 2 Apr 2018 18:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE2D128A67 for ; Mon, 2 Apr 2018 18:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2B8828A7C; Mon, 2 Apr 2018 18:25:08 +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 71EC628A67 for ; Mon, 2 Apr 2018 18:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754337AbeDBSZF (ORCPT ); Mon, 2 Apr 2018 14:25:05 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35342 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753314AbeDBSYg (ORCPT ); Mon, 2 Apr 2018 14:24:36 -0400 Received: by mail-wm0-f66.google.com with SMTP id r82so29279275wme.0 for ; Mon, 02 Apr 2018 11:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=H7O3JIQZHOd5XF/m0jO2smRjYqcFfWSpFffnnV4sK24=; b=Njb0EuQ0cifJkvHtNId43B4un45U/c5r+4S34uVmyZghtIIIL1A1brfcj6+qANp0F0 gzCl6AdASJEwjnzoD8JG120Z0/NbGQt6vEbkjfhKXVu1zIpBadPFpnuQvYjc2ZW3zKEW ynpqXpYfT5NcMTISjE8oG00mZqwmoK0viG4MAlSz7aStzF37rCwp8UePlLtSkOJjS/3B nx7ChEqXSX4AaWrUIJy0+No1AS8SssIOdeT2cvahnu+L1tLg9ZoVJZC11hbmruu/t+c5 cOcOz3kZ2CGMaJIP2eq+0xXMAWwKABCOkw9GLRhHP/zVTXTQdBFEWiAz92HJp456IPaT Ee7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=H7O3JIQZHOd5XF/m0jO2smRjYqcFfWSpFffnnV4sK24=; b=SvcAyUpXuNvlxI80P6dwA37LUUf91tiL1K3s2rhJjDaZJffFQMV8j09Ywzi0SJyp7q Vvh/f8NiNCdWmqiopJstYDuHTkLebnLXcjzlmG4WxJFY+/38vBl5sCGDPnKnDjE4TZUU UaL2KOq4VkH5s61Yg87iwue9G76LEhpDdRKqRYMo5Movz/QHWJ4t3qIWhBOWKvLNZiNn Wx0sIEAFKiOs3rYH57ArqFStYaOVRu6NPnn217zn7FAZDpPSlWMAelDDhwUWIjoXuKgB euqyzF4RSd2kcktt8cbe6g6CGD8E2tMSi67pEe483mBK5DC46X66hyfL6/tlnpGfxepU 6DHQ== X-Gm-Message-State: ALQs6tDKhykoj3s0ctEjYMw26ij1qI1qH4mDyNnJuwXqNLXHGGWIQKLp /fgHE13msWJsJNiMzfHcI0M0Fw== X-Google-Smtp-Source: AIpwx48RsJSUuADcL6E70tHfVVTXLhcajTvegO243V1yazyyQgnaXeq1o87gdWR/6zHessm6gfQ9LQ== X-Received: by 10.28.143.132 with SMTP id r126mr1493569wmd.45.1522693474898; Mon, 02 Apr 2018 11:24:34 -0700 (PDT) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id x9sm2368273wrb.18.2018.04.02.11.24.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 11:24:34 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH 05/20] [media] ddbridge: move ddb_wq and the wq+class initialisation to -core Date: Mon, 2 Apr 2018 20:24:12 +0200 Message-Id: <20180402182427.20918-6-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180402182427.20918-1-d.scheller.oss@gmail.com> References: <20180402182427.20918-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 Move the ddbridge module initialisation and cleanup code to ddbridge-core and set up the ddb_wq workqueue there, and create and destroy the ddb device class there aswell. Due to this, the prototypes for ddb_wq, ddb_class_create() and ddb_class_destroy() aren't required in ddbridge.h anymore, so remove them. Also, declare ddb_wq and the ddb_class_*() functions static. Picked up from the upstream dddvb-0.9.33 release. Signed-off-by: Daniel Scheller --- drivers/media/pci/ddbridge/ddbridge-core.c | 32 +++++++++++++++++++++++++++--- drivers/media/pci/ddbridge/ddbridge-main.c | 21 +++++++------------- drivers/media/pci/ddbridge/ddbridge.h | 7 ++----- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 933046d03db5..fb9a2cb758e6 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -100,7 +100,7 @@ MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods"); static DEFINE_MUTEX(redirect_lock); -struct workqueue_struct *ddb_wq; +static struct workqueue_struct *ddb_wq; static struct ddb *ddbs[DDB_MAX_ADAPTER]; @@ -3055,7 +3055,7 @@ static struct class ddb_class = { .devnode = ddb_devnode, }; -int ddb_class_create(void) +static int ddb_class_create(void) { ddb_major = register_chrdev(0, DDB_NAME, &ddb_fops); if (ddb_major < 0) @@ -3065,7 +3065,7 @@ int ddb_class_create(void) return 0; } -void ddb_class_destroy(void) +static void ddb_class_destroy(void) { class_unregister(&ddb_class); unregister_chrdev(ddb_major, DDB_NAME); @@ -3337,3 +3337,29 @@ void ddb_unmap(struct ddb *dev) iounmap(dev->regs); vfree(dev); } + +int ddb_exit_ddbridge(int stage, int error) +{ + switch (stage) { + default: + case 2: + destroy_workqueue(ddb_wq); + /* fall-through */ + case 1: + ddb_class_destroy(); + break; + } + + return error; +} + +int ddb_init_ddbridge(void) +{ + if (ddb_class_create() < 0) + return -1; + ddb_wq = alloc_workqueue("ddbridge", 0, 0); + if (!ddb_wq) + return ddb_exit_ddbridge(1, -1); + + return 0; +} diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c index bde04dc39080..7088162af9d3 100644 --- a/drivers/media/pci/ddbridge/ddbridge-main.c +++ b/drivers/media/pci/ddbridge/ddbridge-main.c @@ -282,32 +282,25 @@ static struct pci_driver ddb_pci_driver = { static __init int module_init_ddbridge(void) { - int stat = -1; + int stat; pr_info("Digital Devices PCIE bridge driver " DDBRIDGE_VERSION ", Copyright (C) 2010-17 Digital Devices GmbH\n"); - if (ddb_class_create() < 0) - return -1; - ddb_wq = create_workqueue("ddbridge"); - if (!ddb_wq) - goto exit1; + stat = ddb_init_ddbridge(); + if (stat < 0) + return stat; stat = pci_register_driver(&ddb_pci_driver); if (stat < 0) - goto exit2; - return stat; -exit2: - destroy_workqueue(ddb_wq); -exit1: - ddb_class_destroy(); + ddb_exit_ddbridge(0, stat); + return stat; } static __exit void module_exit_ddbridge(void) { pci_unregister_driver(&ddb_pci_driver); - destroy_workqueue(ddb_wq); - ddb_class_destroy(); + ddb_exit_ddbridge(0, 0); } module_init(module_init_ddbridge); diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index e22e67d7e0fe..dbd5f551ce76 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -368,9 +368,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len); /****************************************************************************/ -/* ddbridge-main.c (modparams) */ -extern struct workqueue_struct *ddb_wq; - /* ddbridge-core.c */ void ddb_ports_detach(struct ddb *dev); void ddb_ports_release(struct ddb *dev); @@ -383,9 +380,9 @@ void ddb_ports_init(struct ddb *dev); int ddb_buffers_alloc(struct ddb *dev); int ddb_ports_attach(struct ddb *dev); int ddb_device_create(struct ddb *dev); -int ddb_class_create(void); -void ddb_class_destroy(void); int ddb_init(struct ddb *dev); void ddb_unmap(struct ddb *dev); +int ddb_exit_ddbridge(int stage, int error); +int ddb_init_ddbridge(void); #endif /* DDBRIDGE_H */