Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2022355imu; Sun, 18 Nov 2018 14:00:38 -0800 (PST) X-Google-Smtp-Source: AJdET5eUPaLyTjMD2e2v8wjoaXVZAZgGIJMFU6pJCim5bhiXVTxeR2QDSSpiepKjFtjxqoLeghIt X-Received: by 2002:a62:6fc7:: with SMTP id k190-v6mr20523709pfc.97.1542578438814; Sun, 18 Nov 2018 14:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542578438; cv=none; d=google.com; s=arc-20160816; b=j+NE38z+XXoCP56NhwYM5OWQprg8+taA6RrDssEsuWlN7FrwmQ6zfZscTYBQCf7HHH 7QotSQBu3HOjSXzp8KXNVwKeQA2nOLlsfnBOMNUjdEyBbj67XL1zzBL6QghhnZdKfqHG 1btCeLhx0nK2uGFCyH2WJO66nTTmIhAz3culI5SLkyWHjYI2wunqBspiOKxaErIHuO8B s/9lfM5u5nnZPEU5pqZ1c2MLXtPyBZEXEwLAYz8GG8q4rWfzMOGzGmOcjbCnfxjgtdBm E+hRwaApIWSiRBgj0R2EKmtnUSuv9o+85U3d2fssz75WMa1NFPExlSC2nAx3+XOeXjcp K80w== 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:dkim-signature; bh=mPX0rLvb/DOshuMsfaOMGkmitlEwJKs/scCkkhfcO5g=; b=Rj7s8GsEJXQmXlsPtJk94sV8FdCT0ZF4hia7eSgbOV9DN1a49DIGZhNze6ZP5oloPd 7uby8SfsFpi9n+PuRuRhHI94YzLrhYZTZ9IJbIl/0d57UPAcScJOPwSY+nili1lcQLre DrtWmclDFjE7RoDvpJ9tYXjb9ID22yW0ST/UejUjNhz0tWoGefSFXnFvVt4GvkZUbs+e 1X5cvCH8oX+dSgK7t73D9bMvmhMgkqJQ6IPiT5EI3trFHofMqP9L4lvfKaCu1OXjyQPf yl17o0VjcMcQrAnfKox/3jF/r9OIRzZusSFfLmkoINBdyCgjlHOxrMFV/9Gnjm96UfoN u7Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20180802 header.b="SoKym7/V"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si9490831pgo.9.2018.11.18.14.00.24; Sun, 18 Nov 2018 14:00:38 -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; dkim=fail header.i=@kemnade.info header.s=20180802 header.b="SoKym7/V"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbeKSITu (ORCPT + 99 others); Mon, 19 Nov 2018 03:19:50 -0500 Received: from mail.andi.de1.cc ([85.214.239.24]:52514 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbeKSITt (ORCPT ); Mon, 19 Nov 2018 03:19:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mPX0rLvb/DOshuMsfaOMGkmitlEwJKs/scCkkhfcO5g=; b=SoKym7/VE5PxI1/wCBiJbjY3O kor9ZNJfMAsuiNWbvfTCoOMIykKPRcJK0NW1jYdW3f5ARhPzNRohHm6GGIw7Bg8txTccYIMFSS+6K 5hukhNImG8MON+xALKh6MTOo6TDHc89Bjvd/DbclkpS/RWMDlHXm8A+APnyOnC5NWGYhg=; Received: from p200300ccfbe8ca001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbe8:ca00:1a3d:a2ff:febf:d33a] helo=aktux) by h2641619.stratoserver.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gOV55-00077o-Eh; Sun, 18 Nov 2018 22:58:15 +0100 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1gOV55-0003D8-3D; Sun, 18 Nov 2018 22:58:15 +0100 From: Andreas Kemnade To: johan@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Discussions about the Letux Kernel Cc: Andreas Kemnade Subject: [PATCH 1/5] gnss: sirf: write data to gnss only when the gnss device is open Date: Sun, 18 Nov 2018 22:57:57 +0100 Message-Id: <20181118215801.12280-2-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181118215801.12280-1-andreas@kemnade.info> References: <20181118215801.12280-1-andreas@kemnade.info> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The api forbids writing data there otherwise. Prepare for the serdev_open()/close() being a part of runtime pm. Signed-off-by: Andreas Kemnade --- drivers/gnss/sirf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c index 79cb98950013..b5efbb062316 100644 --- a/drivers/gnss/sirf.c +++ b/drivers/gnss/sirf.c @@ -34,6 +34,7 @@ struct sirf_data { struct gpio_desc *wakeup; int irq; bool active; + bool opened; wait_queue_head_t power_wait; }; @@ -43,6 +44,7 @@ static int sirf_open(struct gnss_device *gdev) struct serdev_device *serdev = data->serdev; int ret; + data->opened = true; ret = serdev_device_open(serdev); if (ret) return ret; @@ -54,6 +56,7 @@ static int sirf_open(struct gnss_device *gdev) if (ret < 0) { dev_err(&gdev->dev, "failed to runtime resume: %d\n", ret); pm_runtime_put_noidle(&serdev->dev); + data->opened = false; goto err_close; } @@ -73,6 +76,7 @@ static void sirf_close(struct gnss_device *gdev) serdev_device_close(serdev); pm_runtime_put(&serdev->dev); + data->opened = false; } static int sirf_write_raw(struct gnss_device *gdev, const unsigned char *buf, @@ -105,7 +109,17 @@ static int sirf_receive_buf(struct serdev_device *serdev, struct sirf_data *data = serdev_device_get_drvdata(serdev); struct gnss_device *gdev = data->gdev; - return gnss_insert_raw(gdev, buf, count); + /* + * we might come here everytime when runtime is resumed + * and data is received. Two cases are possible + * 1. device is opened during initialisation + * 2. kernel is compiled without runtime pm + * and device is opened all the time + */ + if (data->opened) + return gnss_insert_raw(gdev, buf, count); + + return 0; } static const struct serdev_device_ops sirf_serdev_ops = { -- 2.11.0