From patchwork Wed Jun 15 18:32:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Palatin X-Patchwork-Id: 636009 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rVFWH4d3Dz9t1Z for ; Thu, 16 Jun 2016 04:32:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=bFR793Xo; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932327AbcFOScy (ORCPT ); Wed, 15 Jun 2016 14:32:54 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:32968 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753728AbcFOScs (ORCPT ); Wed, 15 Jun 2016 14:32:48 -0400 Received: by mail-pf0-f172.google.com with SMTP id i123so7471502pfg.0 for ; Wed, 15 Jun 2016 11:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=4uTHpsFqEVP/kd2Hq+EfIxubAIOsO6bsaFiB4/39Uas=; b=bFR793XoyZ2eEb8q8ktKvgOLUkWFMGq0u7QMC9WfILxlw+GkJet+AMNV3Rfjhfw5yz 9ND0pnZndmEKNt2nn0B7jCNZik9EjPrGjnM5dZ+KyhuiZGp4WF1CR23bGTxKARXFzY5U OTmSRypVCBl7QowKzptoqOpM2OLhU5c7EnRk9YsJlcUUoFDIrqRRLsizS23YT/P9PML/ T+vSSNGKh99lMm2TeDZIqZT982oumY7lVVzl5DpMwNuNa2CosX8srRGLY9S6LywDK2iP TpU6+qRA9JriRnSv0v9exImoFtfezn/ZymvDUcn4B+E67BJcMd43Nqp2CqseaP6zZQ7j n/GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=4uTHpsFqEVP/kd2Hq+EfIxubAIOsO6bsaFiB4/39Uas=; b=IBSwgfvthQs/OU4p7LnGbeVQ1AAzkcErQRIVPg4HA3LYXOfoCpJdpswGAc4Mkbxf4K gzW0neiYg0nmJJ/V4PsJfIVjOXHcGM/tM2wdeK3nqaICcFzUIr+5UIvxf82eHIbkCQvZ echFvGAdbsSRjcWrLzoGLULm/c3dKN7fNbSNn5+UbjeJGd3MUA8VIUJlQNsgcPoIKYGj 5IxDNOIlonEXktxKL53J9Z6Rf7FkZIzWOi7UiPtbhi6lp2RjqmZQE714rrPQCGb2ngGy p78bYETqjZuIePgLx1MbFaM+Kt+gpCKc34tR9iaKqaQn1o2RUQKM4VGC85GaTrWDiQZJ 6mcQ== X-Gm-Message-State: ALyK8tL4CBrcKS88Xme1mM49b9BC5vtDjhE92J2tdqG+WaWSTUc4kTd+VIVgQReHOx/zmaxq X-Received: by 10.98.89.85 with SMTP id n82mr137907pfb.23.1466015567619; Wed, 15 Jun 2016 11:32:47 -0700 (PDT) Received: from vp2.mtv.corp.google.com ([172.22.67.225]) by smtp.gmail.com with ESMTPSA id i68sm932815pfe.64.2016.06.15.11.32.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Jun 2016 11:32:46 -0700 (PDT) From: Vincent Palatin To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andrew Lunn , Douglas Anderson , Giuseppe Cavallaro , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Shunqian Zheng , Vincent Palatin Subject: [PATCH v2 1/3] net: stmmac: allow to split suspend/resume from init/exit callbacks Date: Wed, 15 Jun 2016 11:32:21 -0700 Message-Id: X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Let the stmmac platform drivers provide dedicated suspend and resume callbacks rather than always re-using the init and exits callbacks. If the driver does not provide the suspend or resume callback, we fall back to the old behavior trying to use exit or init. This allows a specific platform to perform only a partial power-down on suspend if Wake-on-Lan is enabled but always perform the full shutdown sequence if the module is unloaded. Signed-off-by: Vincent Palatin --- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 ++++++-- include/linux/stmmac.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 409db91..a96714d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -411,7 +411,9 @@ static int stmmac_pltfr_suspend(struct device *dev) struct platform_device *pdev = to_platform_device(dev); ret = stmmac_suspend(dev); - if (priv->plat->exit) + if (priv->plat->suspend) + priv->plat->suspend(pdev, priv->plat->bsp_priv); + else if (priv->plat->exit) priv->plat->exit(pdev, priv->plat->bsp_priv); return ret; @@ -430,7 +432,9 @@ static int stmmac_pltfr_resume(struct device *dev) struct stmmac_priv *priv = netdev_priv(ndev); struct platform_device *pdev = to_platform_device(dev); - if (priv->plat->init) + if (priv->plat->resume) + priv->plat->resume(pdev, priv->plat->bsp_priv); + else if (priv->plat->init) priv->plat->init(pdev, priv->plat->bsp_priv); return stmmac_resume(dev); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index ffdaca9..0507dbf 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -135,6 +135,8 @@ struct plat_stmmacenet_data { void (*bus_setup)(void __iomem *ioaddr); int (*init)(struct platform_device *pdev, void *priv); void (*exit)(struct platform_device *pdev, void *priv); + void (*suspend)(struct platform_device *pdev, void *priv); + void (*resume)(struct platform_device *pdev, void *priv); void *bsp_priv; struct stmmac_axi *axi; int has_gmac4;