From patchwork Tue Mar 18 08:56:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 26466 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 58A51202FA for ; Tue, 18 Mar 2014 08:56:47 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wo20sf26241197obc.6 for ; Tue, 18 Mar 2014 01:56:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=YcqD0Nrnz0cm9PaEuhmNg36XmSK3A/F9kO8m/RMhR50=; b=UTGSG9vt1YN9I4fk6GazaqJDWRnnhyq5+4s0FhNbAf2zTKzxVCXRnKCUdll93sI2XU BihxvfsXGejWmQ7D7lbCtju/+MN7h1A938PQFJyMvHD6bHFSZJg5ZW40xN670M711nGY 9AwkTLQvDBxHSZKunKIUP8pYxyLlxP/S5cG+C2pPBD89JwMszEgPaW6zk24/2UZNEC7Y 8S4DFeqde+DmqAXr1IzJoboreB/Bh846q99/jzFOhHkVhmqROieQgZTqwecwhJtYLm0U ZC+wijMo5Mw9nW9tH9N6sG9kOxfExOgMI7DCuHtNIBd8UZQxnEHcNx2EnMghdKO8uOfs wyZA== X-Gm-Message-State: ALoCoQliFBydw/RB08Z6k8IUJA3N8Jpqc/KvhLvafOB4CEyiRrTiDRwpJSb443MtsCHfGZrJzna/ X-Received: by 10.43.75.198 with SMTP id zb6mr9683318icb.22.1395133006874; Tue, 18 Mar 2014 01:56:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.231 with SMTP id n94ls1929048qgd.24.gmail; Tue, 18 Mar 2014 01:56:46 -0700 (PDT) X-Received: by 10.58.146.5 with SMTP id sy5mr15701veb.43.1395133006734; Tue, 18 Mar 2014 01:56:46 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id sl9si3451017veb.75.2014.03.18.01.56.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 01:56:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so6782925vcb.2 for ; Tue, 18 Mar 2014 01:56:46 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr10553066vei.20.1395133006650; Tue, 18 Mar 2014 01:56:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.78.9 with SMTP id i9csp188529vck; Tue, 18 Mar 2014 01:56:45 -0700 (PDT) X-Received: by 10.66.137.109 with SMTP id qh13mr8512882pab.39.1395133005514; Tue, 18 Mar 2014 01:56:45 -0700 (PDT) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by mx.google.com with ESMTPS id j4si11963980pad.227.2014.03.18.01.56.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 01:56:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.180 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.192.180; Received: by mail-pd0-f180.google.com with SMTP id v10so6816028pde.11 for ; Tue, 18 Mar 2014 01:56:42 -0700 (PDT) X-Received: by 10.66.102.66 with SMTP id fm2mr31799889pab.51.1395133002666; Tue, 18 Mar 2014 01:56:42 -0700 (PDT) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id pp5sm50492235pbb.33.2014.03.18.01.56.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 01:56:41 -0700 (PDT) From: Sanjay Singh Rawat To: sanjay.rawat@linaro.org Subject: [RFC PATCH] driver wakeup: wakeup property in device tree Date: Tue, 18 Mar 2014 14:26:24 +0530 Message-Id: <1395132984-10860-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sanjay.rawat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , To configure the devices as wakeup sources, currently drivers make explicit calls to device wakeup functions. This patch tries to automate the wakeup configuration with the help of device tree. In this approach, we parse the device node and if the node is having the wakeup property, the driver will be configured as wakeup source. We don't have to make explicit call to wakeup functions in the drivers init part. Also using this, to set a device as wakeup source, we just need to rebuild the device tree with wakeup property set in the dt node. Signed-off-by: Sanjay Singh Rawat --- drivers/base/dd.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 0605176..ec72c73 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -262,6 +263,31 @@ EXPORT_SYMBOL_GPL(device_bind_driver); static atomic_t probe_count = ATOMIC_INIT(0); static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); +void driver_configure_wakeup(struct device *dev, bool set) +{ + if(dev->of_node) { + const int *can_wakeup; + u32 val; + + can_wakeup = of_get_property(dev->of_node, "wakeup", NULL); + if(!can_wakeup) + return; + + if(set) { + val = be32_to_cpu(*can_wakeup); + if(val == 1) { + val = device_init_wakeup(dev, true); + if(val) + printk(KERN_ERR "failed to configure + (%s) as wakeup source\n", dev_name(dev)); + dev_dbg(dev, "configured as wakeup source\n"); + } + } + else + device_init_wakeup(dev, false); + } +} + static int really_probe(struct device *dev, struct device_driver *drv) { int ret = 0; @@ -292,6 +318,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) ret = drv->probe(dev); if (ret) goto probe_failed; + driver_configure_wakeup(dev, true); } driver_bound(dev); @@ -503,8 +530,10 @@ static void __device_release_driver(struct device *dev) if (dev->bus && dev->bus->remove) dev->bus->remove(dev); - else if (drv->remove) + else if (drv->remove) { drv->remove(dev); + driver_configure_wakeup(dev, false); + } devres_release_all(dev); dev->driver = NULL; dev_set_drvdata(dev, NULL);