Skip to content

Commit 0bf2840

Browse files
poescheldavem330
authored andcommitted
nfc: pn533: Add dev_up/dev_down hooks to phy_ops
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 <[email protected]> Signed-off-by: Lars Poeschel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3c57b39 commit 0bf2840

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

drivers/nfc/pn533/pn533.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,9 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev)
24582458
{
24592459
struct pn533 *dev = nfc_get_drvdata(nfc_dev);
24602460

2461+
if (dev->phy_ops->dev_up)
2462+
dev->phy_ops->dev_up(dev);
2463+
24612464
if (dev->device_type == PN533_DEVICE_PN532) {
24622465
int rc = pn532_sam_configuration(nfc_dev);
24632466

@@ -2470,7 +2473,14 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev)
24702473

24712474
static int pn533_dev_down(struct nfc_dev *nfc_dev)
24722475
{
2473-
return pn533_rf_field(nfc_dev, 0);
2476+
struct pn533 *dev = nfc_get_drvdata(nfc_dev);
2477+
int ret;
2478+
2479+
ret = pn533_rf_field(nfc_dev, 0);
2480+
if (dev->phy_ops->dev_down && !ret)
2481+
dev->phy_ops->dev_down(dev);
2482+
2483+
return ret;
24742484
}
24752485

24762486
static struct nfc_ops pn533_nfc_ops = {

drivers/nfc/pn533/pn533.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ struct pn533_phy_ops {
207207
struct sk_buff *out);
208208
int (*send_ack)(struct pn533 *dev, gfp_t flags);
209209
void (*abort_cmd)(struct pn533 *priv, gfp_t flags);
210+
/*
211+
* dev_up and dev_down are optional.
212+
* They are used to inform the phy layer that the nfc chip
213+
* is going to be really used very soon. The phy layer can then
214+
* bring up it's interface to the chip and have it suspended for power
215+
* saving reasons otherwise.
216+
*/
217+
void (*dev_up)(struct pn533 *priv);
218+
void (*dev_down)(struct pn533 *priv);
210219
};
211220

212221

0 commit comments

Comments
 (0)