Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7702431imu; Tue, 22 Jan 2019 10:07:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN7zHydOCXZcv09oWQ+YqLwNpA67D5D+lVAO2OxXIWXw7b5+DZxS7RHSzrhoT5tQxpRggQL6 X-Received: by 2002:a63:e445:: with SMTP id i5mr32880091pgk.307.1548180468724; Tue, 22 Jan 2019 10:07:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180468; cv=none; d=google.com; s=arc-20160816; b=CFw0R1JvMTlHCytaGJ5BlloMUaXy3uPQU4P+q4Bh0VzWDq11Ft/v+eWma2PeMLcjR/ UjuzG0LjqEnGgIKrm/csW2DAoai+7eVx1GNgVmzwCzh0Bxgwtsm5+Nb8IX98qfioJxWc UthzK7fwfDrXVQ1YpEXYM/LbMgfTs+C01iKeSbrh/9mZzQxl78Gb7KK7IBziRF7yLZ18 oAmWRExN/Hf/gLxdjPI17SWwLP0ogxC00qcPsgvglq2NVhJm7rGXQa0Xv83ltsZFA7PW wmjmtqVyPQxhjYUdpwD5yz7qP2vLFXp2U8Ftl+btvtN2d3ugfXxNQY+/ZMS032teliIf sqZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=E3FFYJpxjt1KqLVB3Vwz0+MbFkyksMYoRu2AMp2Ajwg=; b=UV34Sfwg5CVyHHEIUgnLC9QX0cfL15BXXOZ7St/VfgUUwZHncLlHV+Iu2vtFN6axiE xIIlor1gc0LeBtCpGmpsfAkSC8+8ps4NyWLx4ExQO6CyOb/B1wRXZz1TPLdYY3r+fdWq X7Edks60PMFfHZF7emd8n1NH9hS9QNvyiepyLSyxmWOAjhrHhEtVJXQZnjCDD9Mm2qEi UCBkB/60+v5etNyvHcn7v+oX9le+hEanUIW0U2TCl6KSNPt6aLbRfre04G791t8+2XiK CH777/+s0/JOcCDQsqkKo+0qB4Ekj/GkGlikwjtSFHkSGWtj3bDfGxZn7TEqWtDZqwl3 EW+g== 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 u11si17386236plm.8.2019.01.22.10.07.29; Tue, 22 Jan 2019 10:07:48 -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 S1726702AbfAVSD2 (ORCPT + 99 others); Tue, 22 Jan 2019 13:03:28 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45430 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbfAVSD1 (ORCPT ); Tue, 22 Jan 2019 13:03:27 -0500 Received: by mail-lj1-f196.google.com with SMTP id s5-v6so21416425ljd.12; Tue, 22 Jan 2019 10:03:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=E3FFYJpxjt1KqLVB3Vwz0+MbFkyksMYoRu2AMp2Ajwg=; b=GUUAXHtz3bP4CsM5cDe7B/MzwVQIgls4GEiiX9uniVvoIUZx6UycNk/cWh3dbuD6E7 54XTm2cHe7uU46AFvRv8aLGGmVjOxR1P3WZmaiqFJKidy9Fqt2vOKWIWHfdxswXcLC9X YiGIVoH/wIJI9Q8hslQ71jv6VC7zLP0Cy4/5K/egMzN4Cdm7KDS34S+jFfuoukhwfL28 8AirxWdV2TWYiW4OEs/YdIkIdzepUwI2iBw4EAACG0VcbavI4MehWVhxynnZeX/ycb09 m0XkGaiXzHGMS7FzMFvk/oS8bxK4YgA8W4VG3VCWdZvAnLBU/pteH3Ox6aJAY3CltacB +o6g== X-Gm-Message-State: AJcUukeoA163BOsVKjs4FZbdSLVvMlUEkRsIC7a4g3U6H6m40w/oFVpW 3gGXMXh001PmWWekuJlANZjzb7HK X-Received: by 2002:a2e:9603:: with SMTP id v3-v6mr18590396ljh.15.1548180205032; Tue, 22 Jan 2019 10:03:25 -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 x29-v6sm105718ljb.97.2019.01.22.10.03.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:03:24 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1gm0OP-0004ta-4o; Tue, 22 Jan 2019 19:03:21 +0100 Date: Tue, 22 Jan 2019 19:03:21 +0100 From: Johan Hovold To: Andreas Kemnade Cc: letux-kernel@openphoenux.org, johan@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 5/6] gnss: sirf: add a separate supply for a lna Message-ID: <20190122180321.GS3691@localhost> References: <20190116211812.6337-1-andreas@kemnade.info> <20190116211812.6337-6-andreas@kemnade.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190116211812.6337-6-andreas@kemnade.info> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 16, 2019 at 10:18:11PM +0100, Andreas Kemnade wrote: > Devices might have a separate lna between antenna input of the gps > chip and the antenna which might have a separate supply. > > Signed-off-by: Andreas Kemnade > --- > Changes in v3: > - improved error checking > - style cleanup > > Changes in v2: > - handle lna also if there is no on-off gpio > - rebase on changed 2/5 > > drivers/gnss/sirf.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 44 insertions(+), 6 deletions(-) > > diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c > index 943a2ec9b708..7de98edf198a 100644 > --- a/drivers/gnss/sirf.c > +++ b/drivers/gnss/sirf.c > @@ -41,6 +41,7 @@ struct sirf_data { > struct serdev_device *serdev; > speed_t speed; > struct regulator *vcc; > + struct regulator *lna; > struct gpio_desc *on_off; > struct gpio_desc *wakeup; > int irq; > @@ -293,21 +294,52 @@ static int sirf_set_active(struct sirf_data *data, bool active) > static int sirf_runtime_suspend(struct device *dev) > { > struct sirf_data *data = dev_get_drvdata(dev); > + int ret; > > - if (!data->on_off) > - return regulator_disable(data->vcc); > + if (data->on_off) > + ret = sirf_set_active(data, false); > + else > + ret = regulator_disable(data->vcc); > + > + if (ret) > + return ret; > > - return sirf_set_active(data, false); > + ret = regulator_disable(data->lna); > + if (ret) { Use an error label for this to avoid the indentation. > + int reenable_ret; Rename ret2 and move to start of function. > + > + if (data->on_off) > + reenable_ret = sirf_set_active(data, true); > + else > + reenable_ret = regulator_enable(data->vcc); > + > + if (reenable_ret) > + dev_err(dev, > + "failed to reenable power on failed suspend: %d\n", > + reenable_ret); > + } > + > + return ret; > } > > static int sirf_runtime_resume(struct device *dev) > { > struct sirf_data *data = dev_get_drvdata(dev); > + int ret; > + > + ret = regulator_enable(data->lna); > + if (ret) > + return ret; > > - if (!data->on_off) > - return regulator_enable(data->vcc); > + if (data->on_off) > + ret = sirf_set_active(data, true); > + else > + ret = regulator_enable(data->vcc); > > - return sirf_set_active(data, true); > + if (ret) Use an error label here too for consistency (and if if ever add further resources to be manipulated here). > + regulator_disable(data->lna); > + > + return ret; > } > > static int __maybe_unused sirf_suspend(struct device *dev) > @@ -395,6 +427,12 @@ static int sirf_probe(struct serdev_device *serdev) > goto err_put_device; > } > > + data->lna = devm_regulator_get(dev, "lna"); > + if (IS_ERR(data->lna)) { > + ret = PTR_ERR(data->lna); > + goto err_put_device; > + } > + > data->on_off = devm_gpiod_get_optional(dev, "sirf,onoff", > GPIOD_OUT_LOW); > if (IS_ERR(data->on_off)) Johan