Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5701892ybp; Tue, 8 Oct 2019 07:07:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsKJ8bR88Yr+G7zPJDB/j9DveOYlKJI8S2+HQeW2fnBxo1cO3LpfE/Q+lfmkXuIh37X2EU X-Received: by 2002:a17:906:7d8:: with SMTP id m24mr29506498ejc.196.1570543633414; Tue, 08 Oct 2019 07:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570543633; cv=none; d=google.com; s=arc-20160816; b=RU1GLPhtYBTzlagOq9DrLzqYM2/xNA0xS0WjJfDXEqa2WamA7hQfwrluNev0zQjIUD AFO/q7ArGSqKhQVFkhz/H1Dyc3KYvRok/wq7Q+Ko0FbgqB/6+rQXo9Ec2jQeaxcOx13o nzYBuCkowCNjQ0IJYGoB2unSFlJjP5KqbAYUCmIYB+VtCv5MJ8DWbGB5Mt3UatjvCzRp ECV+QUxuCBBR49eAy31m7N1ZIhau7VCOIua9cWatAuNc0DWEgVaOv3DnUr3naW5xfZMy w9m4Y6+8OIQuXEQvuBGA5xFRYUdJDOFMOZql/FRu7Pj1Ga7W4sqYuLeN9AcpCoKDuZ0l o2Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fX8YVLu/3OL9nyJUEwgfbsywgxmLeSvs7m7Mxgq1tfI=; b=qk0dIwaiO6JPJM4xzwXKm+dSCp0t2VV6zvZb23UMfShuGdt/dwNZZQGxtYeQjeLx3I cylOj7fOaExSjtyXUq+bk7nZirVVATDzPQx/Hj7tgwv7s4FHVuZVtkvo9+4zRjbc17YJ HDwdGbUTu1hFqC6slAJvx4PC+/NOJjt2GrWKiiYwDo1PkmKW2E/JmcIQKVqhedn7F/7/ AkmVcCLxsUcdw2Npk/zIjwcz/eq1Hk+F3CTsn26VPWqs8QfI8t+oS5bwHayoucEtHzqH pBlx6ZQ9ymEuwDnyB4LH1tTlkqwdJfwrcv1aQtPwVpuCG1f4LAWqIGVTcVtV9xb2/B9V NSFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si10508957edj.0.2019.10.08.07.06.48; Tue, 08 Oct 2019 07:07:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726948AbfJHOGQ (ORCPT + 99 others); Tue, 8 Oct 2019 10:06:16 -0400 Received: from smtp2.goneo.de ([85.220.129.33]:38648 "EHLO smtp2.goneo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726656AbfJHOGN (ORCPT ); Tue, 8 Oct 2019 10:06:13 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp2.goneo.de (Postfix) with ESMTP id 6FB7823F5D5; Tue, 8 Oct 2019 16:06:11 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -3.093 X-Spam-Level: X-Spam-Status: No, score=-3.093 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.193, BAYES_00=-1.9] autolearn=ham Received: from smtp2.goneo.de ([127.0.0.1]) by localhost (smtp2.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Go2Nt7ldw4fB; Tue, 8 Oct 2019 16:06:10 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPA id 292E123F5D7; Tue, 8 Oct 2019 16:06:10 +0200 (CEST) From: Lars Poeschel To: Lars Poeschel , Jilayne Lovejoy , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Steve Winslow , Thomas Gleixner , Kate Stewart , Allison Randal , netdev@vger.kernel.org (open list:NFC SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Cc: Johan Hovold Subject: [PATCH v9 3/7] nfc: pn533: Add dev_up/dev_down hooks to phy_ops Date: Tue, 8 Oct 2019 16:05:40 +0200 Message-Id: <20191008140544.17112-4-poeschel@lemonage.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191008140544.17112-1-poeschel@lemonage.de> References: <20191008140544.17112-1-poeschel@lemonage.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds hooks for dev_up and dev_down to the phy_ops. They are optional. The idea is to inform the phy driver when the nfc chip is really going to be used. When it is not used, the phy driver can suspend it's interface to the nfc chip to save some power. The nfc chip is considered not in use before dev_up and after dev_down. Cc: Johan Hovold Signed-off-by: Lars Poeschel --- Changes in v9: - Rebased the patch series on v5.4-rc2 Changes in v6: - Rebased the patch series on v5.3-rc5 Changes in v5: - (dev->phy_ops->dev_up) instead (dev->phy_ops) Changes in v4: - This patch is new in v4 drivers/nfc/pn533/pn533.c | 12 +++++++++++- drivers/nfc/pn533/pn533.h | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c index a172a32aa9d9..64836c727aee 100644 --- a/drivers/nfc/pn533/pn533.c +++ b/drivers/nfc/pn533/pn533.c @@ -2458,6 +2458,9 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev) { struct pn533 *dev = nfc_get_drvdata(nfc_dev); + if (dev->phy_ops->dev_up) + dev->phy_ops->dev_up(dev); + if (dev->device_type == PN533_DEVICE_PN532) { int rc = pn532_sam_configuration(nfc_dev); @@ -2470,7 +2473,14 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev) static int pn533_dev_down(struct nfc_dev *nfc_dev) { - return pn533_rf_field(nfc_dev, 0); + struct pn533 *dev = nfc_get_drvdata(nfc_dev); + int ret; + + ret = pn533_rf_field(nfc_dev, 0); + if (dev->phy_ops->dev_down && !ret) + dev->phy_ops->dev_down(dev); + + return ret; } static struct nfc_ops pn533_nfc_ops = { diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h index 8bf9d6ece0f5..570ee0a3e832 100644 --- a/drivers/nfc/pn533/pn533.h +++ b/drivers/nfc/pn533/pn533.h @@ -207,6 +207,15 @@ struct pn533_phy_ops { struct sk_buff *out); int (*send_ack)(struct pn533 *dev, gfp_t flags); void (*abort_cmd)(struct pn533 *priv, gfp_t flags); + /* + * dev_up and dev_down are optional. + * They are used to inform the phy layer that the nfc chip + * is going to be really used very soon. The phy layer can then + * bring up it's interface to the chip and have it suspended for power + * saving reasons otherwise. + */ + void (*dev_up)(struct pn533 *priv); + void (*dev_down)(struct pn533 *priv); }; -- 2.23.0