From patchwork Wed Mar 16 14:50:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 8601371 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB7F9C0553 for ; Wed, 16 Mar 2016 14:49:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C25C202FE for ; Wed, 16 Mar 2016 14:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15A2320212 for ; Wed, 16 Mar 2016 14:49:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935092AbcCPOtn (ORCPT ); Wed, 16 Mar 2016 10:49:43 -0400 Received: from mailout1.hostsharing.net ([83.223.95.204]:59155 "EHLO mailout1.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935079AbcCPOtm (ORCPT ); Wed, 16 Mar 2016 10:49:42 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout1.hostsharing.net (Postfix) with ESMTPS id 79E0210138B01; Wed, 16 Mar 2016 15:49:40 +0100 (CET) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 354E9603E02F; Wed, 16 Mar 2016 15:49:38 +0100 (CET) X-Mailbox-Line: From d90c3d66a193e4c01b8b74532c2b98c5b5aec89a Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Lukas Wunner Date: Wed, 16 Mar 2016 15:50:35 +0100 Subject: [RFC 3/4] thunderbolt: Move pm code to separate file To: linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Andreas Noever , Matthew Garrett Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 No code changes. Cc: Andreas Noever Signed-off-by: Lukas Wunner --- drivers/thunderbolt/Makefile | 3 +-- drivers/thunderbolt/nhi.c | 33 +-------------------------------- drivers/thunderbolt/power.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/thunderbolt/power.h | 14 ++++++++++++++ 4 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 drivers/thunderbolt/power.c create mode 100644 drivers/thunderbolt/power.h diff --git a/drivers/thunderbolt/Makefile b/drivers/thunderbolt/Makefile index 5d1053c..03c7ba5 100644 --- a/drivers/thunderbolt/Makefile +++ b/drivers/thunderbolt/Makefile @@ -1,3 +1,2 @@ obj-${CONFIG_THUNDERBOLT} := thunderbolt.o -thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o - +thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o power.o diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 36be23b..fa89160 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -7,7 +7,6 @@ * Copyright (c) 2014 Andreas Noever */ -#include #include #include #include @@ -17,6 +16,7 @@ #include "nhi.h" #include "nhi_regs.h" +#include "power.h" #include "tb.h" #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring") @@ -493,22 +493,6 @@ static irqreturn_t nhi_msi(int irq, void *data) return IRQ_HANDLED; } -static int nhi_suspend_noirq(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - struct tb *tb = pci_get_drvdata(pdev); - thunderbolt_suspend(tb); - return 0; -} - -static int nhi_resume_noirq(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - struct tb *tb = pci_get_drvdata(pdev); - thunderbolt_resume(tb); - return 0; -} - static void nhi_shutdown(struct tb_nhi *nhi) { int i; @@ -615,21 +599,6 @@ static void nhi_remove(struct pci_dev *pdev) nhi_shutdown(nhi); } -/* - * The tunneled pci bridges are siblings of us. Use resume_noirq to reenable - * the tunnels asap. A corresponding pci quirk blocks the downstream bridges - * resume_noirq until we are done. - */ -static const struct dev_pm_ops nhi_pm_ops = { - .suspend_noirq = nhi_suspend_noirq, - .resume_noirq = nhi_resume_noirq, - .freeze_noirq = nhi_suspend_noirq, /* - * we just disable hotplug, the - * pci-tunnels stay alive. - */ - .restore_noirq = nhi_resume_noirq, -}; - static struct pci_device_id nhi_ids[] = { /* * We have to specify class, the TB bridges use the same device and diff --git a/drivers/thunderbolt/power.c b/drivers/thunderbolt/power.c new file mode 100644 index 0000000..1095ad0 --- /dev/null +++ b/drivers/thunderbolt/power.c @@ -0,0 +1,41 @@ +/* + * Thunderbolt Cactus Ridge driver - power management + * + * Copyright (c) 2014 Andreas Noever + */ + +#include +#include + +#include "tb.h" + +static int nhi_suspend_noirq(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct tb *tb = pci_get_drvdata(pdev); + thunderbolt_suspend(tb); + return 0; +} + +static int nhi_resume_noirq(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct tb *tb = pci_get_drvdata(pdev); + thunderbolt_resume(tb); + return 0; +} + +/* + * The tunneled pci bridges are siblings of us. Use resume_noirq to reenable + * the tunnels asap. A corresponding pci quirk blocks the downstream bridges + * resume_noirq until we are done. + */ +const struct dev_pm_ops nhi_pm_ops = { + .suspend_noirq = nhi_suspend_noirq, + .resume_noirq = nhi_resume_noirq, + .freeze_noirq = nhi_suspend_noirq, /* + * we just disable hotplug, the + * pci-tunnels stay alive. + */ + .restore_noirq = nhi_resume_noirq, +}; diff --git a/drivers/thunderbolt/power.h b/drivers/thunderbolt/power.h new file mode 100644 index 0000000..99cb900 --- /dev/null +++ b/drivers/thunderbolt/power.h @@ -0,0 +1,14 @@ +/* + * Thunderbolt Cactus Ridge driver - power management + * + * Copyright (c) 2014 Andreas Noever + */ + +#ifndef POWER_H +#define POWER_H + +#include + +extern const struct dev_pm_ops nhi_pm_ops; + +#endif