Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp214379imb; Thu, 28 Feb 2019 21:40:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwFZcYN3nEv5MN3WeR5DMl0lvZyB3IiR8FMsjVB58k2wqi5xAIQMigHuy1MxU41TS5ZBUld X-Received: by 2002:a63:b14d:: with SMTP id g13mr3210307pgp.270.1551418815682; Thu, 28 Feb 2019 21:40:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551418815; cv=none; d=google.com; s=arc-20160816; b=V3IoV+0NicPHLV3I2VdA6p+vYVAaDJqHeELeaG4gyeR6//L/6TVayJC4zu85iPr0lM kU23fyo0OHBzNwiuhD52lwrNXTaW5siSVEbV3ea0UYHjufgJYXHHHKRa1ZCvM+uhf80f C/ZuMm5NsCFH1m/FHvrYeZAsz/72JPYF/6Q6AMOrXPES0GA06ix1GDXixiS63tSJ+/aS n4bMIuS3Lv//e6si5i1kxKzJbOpNRX8Y5zqqLbhx/tbhynr5PFf+txHdRbFgqFNm10ge NBtK9rGrHCmq30TTpySj3d6/zoHax5tn3pu9C/KIGfSxFr2250YELuCYQfFxjy+8AyFK WoYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=V81X25Uyj+wTVDQmVe+I4rUToeKc5NriyOA4+PdwIf0=; b=0c1X/GieQ6+1CzWmBgqtxrq1Q8077TyYkQLT4GC/zvC+EW8UFLliHGjZNQ0soOw72e IPUpgHT66qjaFOu0kZUbB4MkcxHSAP0s3DAvKy2LCK5Z8iLokyHXsMYNmD6TMc+xZBUs zAIN9Jf7wTlI6Y1C/d2sINmu5AbaD16lc6iV1TsQ6Z8Gz0gzouX7lHA0nwYpMDCDlqTJ +BSOanuFfLpOILaBPcrcfi/72fn2VbWkOwT/H/CVC9MLaI2BeQ3ptR7GBg54568j6pID kFEMuYGPUeYsXylGEYePU8eoVqw3QbFaqLxcschX59fwgpZallEPb4J0wco5LV7a0qdd 8saw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p91si19944734plb.69.2019.02.28.21.40.00; Thu, 28 Feb 2019 21:40:15 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbfCAFiL (ORCPT + 99 others); Fri, 1 Mar 2019 00:38:11 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:42688 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728007AbfCAFiJ (ORCPT ); Fri, 1 Mar 2019 00:38:09 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from parav@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Mar 2019 07:38:04 +0200 Received: from sw-mtx-036.mtx.labs.mlnx (sw-mtx-036.mtx.labs.mlnx [10.12.150.149]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x215brYX016903; Fri, 1 Mar 2019 07:38:01 +0200 From: Parav Pandit To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, michal.lkml@markovi.net, davem@davemloft.net, gregkh@linuxfoundation.org, jiri@mellanox.com Cc: parav@mellanox.com Subject: [RFC net-next 2/8] subdev: Introduce pm callbacks Date: Thu, 28 Feb 2019 23:37:46 -0600 Message-Id: <1551418672-12822-3-git-send-email-parav@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551418672-12822-1-git-send-email-parav@mellanox.com> References: <1551418672-12822-1-git-send-email-parav@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Keep power management callbacks in place to optionally notify drivers who register them. Signed-off-by: Parav Pandit --- drivers/subdev/subdev_main.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/subdev/subdev_main.c b/drivers/subdev/subdev_main.c index 4aabcaa..e213331 100644 --- a/drivers/subdev/subdev_main.c +++ b/drivers/subdev/subdev_main.c @@ -23,10 +23,69 @@ static int subdev_bus_match(struct device *dev, struct device_driver *drv) return 0; } +static int subdev_pm_prepare(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->prepare) + return dev->driver->pm->prepare(dev); + return 0; +} + +static void subdev_pm_complete(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->complete) + dev->driver->pm->complete(dev); +} + +static int subdev_pm_suspend(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->suspend) + return dev->driver->pm->suspend(dev); + return 0; +} + +static int subdev_pm_suspend_late(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->suspend_late) + return dev->driver->pm->suspend_late(dev); + return 0; +} + +static int subdev_pm_resume(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->resume) + return dev->driver->pm->resume(dev); + return 0; +} + +static int subdev_pm_freeze(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->freeze) + return dev->driver->pm->freeze(dev); + return 0; +} + +static int subdev_pm_freeze_late(struct device *dev) +{ + if (dev->driver->pm && dev->driver->pm->freeze_late) + return dev->driver->pm->freeze_late(dev); + return 0; +} + +static const struct dev_pm_ops subdev_dev_pm_ops = { + .prepare = subdev_pm_prepare, + .complete = subdev_pm_complete, + .suspend = subdev_pm_suspend, + .suspend_late = subdev_pm_suspend_late, + .resume = subdev_pm_resume, + .freeze = subdev_pm_freeze, + .freeze_late = subdev_pm_freeze_late, +}; + static struct bus_type subdev_bus_type = { .dev_name = "subdev", .name = "subdev", .match = subdev_bus_match, + .pm = &subdev_dev_pm_ops, }; int __subdev_register_driver(struct subdev_driver *drv, struct module *owner, -- 1.8.3.1