Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7659303imu; Tue, 22 Jan 2019 09:24:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN5LJaWkVqm8pXCchzkfYdg/q7qcmgdmeZoOXOLjdQvSoxh5Ykh7vPX4HMgI3BxGZoS4VS5o X-Received: by 2002:a17:902:24e7:: with SMTP id l36mr35210008plg.61.1548177895263; Tue, 22 Jan 2019 09:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548177895; cv=none; d=google.com; s=arc-20160816; b=thL3Njz8zx2NUlP31tWsBvGlulczcYYtADj4Og78eTN+QdIfHQPOZGJX3jOcXjPMvz w1PnR+rFVRFGtbNXP+4NMBz4KwSGGetMUb8gDIhpU6+IJBrKDXJPHGVWPwjC6pa/tMdG 8MymPsvZVC6z+2sPuKvegjyOIzA77eMT6Qe9j/Qk178fmlIf7485iiGy0B3dHtk/A8nf D9tS9HhcY1bQ0nmRKbDvIPRGuEbdz56Pn7yhsK8Hj38PhZDWBrsVCi8uQvHAgmh2kDfU 5YW74AVwG8K6uvHsDQY4YHS5C6uSZnkGc3L+qGgHeqtJfWoAO3nvAdKbyX1laSI3yrDv W+UQ== 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=rl2KJL7uDBCdwW+hXir8OykyApAvp/osF5eC6yaBp90=; b=Kin9vAwWww32gtgGCIEwLV6EtL/+ouYNq6HX6RX9Y74Nyt4dVkuRM8zAjOCgRir076 CITCCWiwmFlsewp7i2CmYIZKPOhp1aIkC1zDPcsgypackES2rwo/pYjXPR++rq5+mp81 ukvrEOlng8ANCULgQV+0WsR20aY7aoQ2z4C9ywK61DNtxOfXXkdYfvVb+mJXQDMkSMCL wyd40liWy8KbCxLfO669NGYkTKQCnBTG5vtLAs56Fgzz8nKY6qB7pOgN/OoCSsT0diwK pkVPEMSRtmtXS6ss2Q05/Usyj9EuoiwBoLy0Q5+V29lJS0t2PhOB0EKq+zy6GCvqdRwS YntA== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si16216841pfd.86.2019.01.22.09.24.39; Tue, 22 Jan 2019 09:24:55 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729651AbfAVRX1 (ORCPT + 99 others); Tue, 22 Jan 2019 12:23:27 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38666 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729336AbfAVRXW (ORCPT ); Tue, 22 Jan 2019 12:23:22 -0500 Received: by mail-lj1-f193.google.com with SMTP id c19-v6so21349779lja.5 for ; Tue, 22 Jan 2019 09:23:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rl2KJL7uDBCdwW+hXir8OykyApAvp/osF5eC6yaBp90=; b=bjjx2s79itSflK6PXZmT8RmmcEx/e6vS48Z+yiWeZHw3BJfYmwhmkeuajtK8ze4Q4t v/hl3ESsEvCLI/N1EBiBZ5cjWdB/xodFdU3pPkpZh4TG5KuzMYVvmFtTrd7+hX5t9L+L 3oKfuEq9J5h7/ZgG8yVL07E3qTws+ttG+Ya0vj5TkyWaXdTGYCLB34SnJmR1e3hqPVz0 56WeginGX2jJlw9QWNELAI8c7/I9JIOphW+goteBwL+Sgfgp8AIX1ZtO9XV/uWciAfXS C3oK65ur6AhvZCgeQeqtWfZcMoS9R4b6ot5c6MLuBMbazCaF/qSsn+xTd7K721jkJOqe UHRQ== X-Gm-Message-State: AJcUukeXD3ki1VnuG7uwmjSjpW5DWPCBMa8qeT50qVARDlklYaDX3UuP 7BEPZ1e8NqcwtbNxWoY7VX+WyAdU X-Received: by 2002:a2e:9e16:: with SMTP id e22-v6mr21033977ljk.4.1548177799686; Tue, 22 Jan 2019 09:23:19 -0800 (PST) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id z6sm93863lfd.50.2019.01.22.09.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 09:23:18 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1glzla-0004gI-UU; Tue, 22 Jan 2019 18:23:14 +0100 From: Johan Hovold To: linux-kernel@vger.kernel.org Cc: Andreas Kemnade , Johan Hovold Subject: [PATCH 2/3] gnss: sirf: force hibernate mode on probe Date: Tue, 22 Jan 2019 18:22:54 +0100 Message-Id: <20190122172255.17944-3-johan@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190122172255.17944-1-johan@kernel.org> References: <20190122172255.17944-1-johan@kernel.org> 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 Make sure to put the receiver in hibernate mode in case it is already active during probe in order to avoid wasting power until first open or suspend. This can happen, for example, after a reset or non-clean shutdown, and possibly also due to glitches during power-on. Reported-by: Andreas Kemnade Signed-off-by: Johan Hovold --- drivers/gnss/sirf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c index 8e3f6a776e02..f9a9d00dec98 100644 --- a/drivers/gnss/sirf.c +++ b/drivers/gnss/sirf.c @@ -320,6 +320,11 @@ static int sirf_probe(struct serdev_device *serdev) } if (data->wakeup) { + ret = gpiod_get_value_cansleep(data->wakeup); + if (ret < 0) + goto err_disable_vcc; + data->active = ret; + ret = gpiod_to_irq(data->wakeup); if (ret < 0) goto err_disable_vcc; @@ -332,6 +337,18 @@ static int sirf_probe(struct serdev_device *serdev) goto err_disable_vcc; } + if (data->on_off) { + /* Force hibernate mode if already active. */ + if (data->active) { + ret = sirf_set_active(data, false); + if (ret) { + dev_err(dev, "failed to set hibernate mode: %d\n", + ret); + goto err_free_irq; + } + } + } + if (IS_ENABLED(CONFIG_PM)) { pm_runtime_set_suspended(dev); /* clear runtime_error flag */ pm_runtime_enable(dev); -- 2.20.1