From patchwork Mon Sep 18 17:49:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 9957237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EDF5D60385 for ; Mon, 18 Sep 2017 17:50:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE45A28D82 for ; Mon, 18 Sep 2017 17:50:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D28ED28D89; Mon, 18 Sep 2017 17:50:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37F2828D87 for ; Mon, 18 Sep 2017 17:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755458AbdIRRuB (ORCPT ); Mon, 18 Sep 2017 13:50:01 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33781 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755299AbdIRRuB (ORCPT ); Mon, 18 Sep 2017 13:50:01 -0400 Received: by mail-wm0-f68.google.com with SMTP id m127so1631779wmm.0 for ; Mon, 18 Sep 2017 10:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/7xsjwbfssv1LnLSMuR2oA9XwTBXXCNqvVNwquU9kvs=; b=Wh/VNq/zRgXYIFQclgIZHsp1ZvQMLGwBdNzwfJrNvIIhCrhbiuuDhPtS07yA6p1pMN oqzOjRhPewQye1CloDcoC45/u4ZAEJewFDd74MRUTREQ//6UQk0m+hOntDApnlj3Jpb7 +JpXMDJ/FsqnzmSXuPnf0wtw0dH+Sv9p40XmQaTNHXjCemYlWTUv9cNG99yUT09zAigS Bwf3jw8XhOMdZBSDYgopznowU1UVHru1N9YuaPAtIIi/F2zNrYmIJhYa9+hsCuwdR7E2 aIJSPf3gNG3OHhFIqpmS/Re3B8X3Ir3TU325WPCTsFwsPoBIrlhD86gHJZ9b91icTktR +FyQ== 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; bh=/7xsjwbfssv1LnLSMuR2oA9XwTBXXCNqvVNwquU9kvs=; b=OtcgDDrg9mEQG43X4FrQqvO7GpGn8x3yjmq8CpD8paToWKCOB42WsoyuVeyWh1YXkL DFKY6yXEAYHOlgfHUZz/LYOBsovv/j8UJJ9en8PiJ40igV2axAmGrbGFMot7x8OK45iN vHlhDSIhxOs5yemVJfYCJOr38i6wOfX5IMYWMoVKRlvfKwJti/mH/LYd+j8SffNX9z2u TyFLGiVnYNS9bUoDrnR0dyNA4aXr1x8c2mv73rhqWc+XTvSD76tHndMJzzGYKTWecvHK Z17M4rQ9o+bWR2GKurY/3wxvvkUYgeExnM/ANb9dkjpf/yWlkSg0J67bHj8g4yeWzjap abDQ== X-Gm-Message-State: AHPjjUjTzAYi3ngvsDDoFueydNYRGbdWR1hfxz6YiC7GGbyCg+sa6Xov C598zegaMGvMAg== X-Google-Smtp-Source: AOwi7QAwwHMS/N3Lg8irnswxptdqjIGw088yJrA3yhC3fLp6Inc4JiSTdZvFgk5qfeIcetdA4TY57g== X-Received: by 10.28.159.77 with SMTP id i74mr9190947wme.22.1505756999622; Mon, 18 Sep 2017 10:49:59 -0700 (PDT) Received: from localhost.localdomain ([151.66.56.134]) by smtp.gmail.com with ESMTPSA id k52sm9279701wrf.62.2017.09.18.10.49.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Sep 2017 10:49:58 -0700 (PDT) From: Lorenzo Bianconi X-Google-Original-From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, lorenzo.bianconi@st.com Subject: [PATCH] iio: imu: st_lsm6dsx: set sensor->odr value just in st_lsm6dsx_write_raw() Date: Mon, 18 Sep 2017 19:49:57 +0200 Message-Id: <20170918174957.12533-1-lorenzo.bianconi@st.com> X-Mailer: git-send-email 2.14.1 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update odr value in st_lsm6dsx_sensor data structure just in st_lsm6dsx_write_raw() in order to avoid to set the same value multiple times Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index d45d714acdd3..c68cc7c91928 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -322,7 +322,6 @@ static int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, return -EINVAL; *val = st_lsm6dsx_odr_table[sensor->id].odr_avl[i].val; - sensor->odr = odr; return 0; } @@ -449,6 +448,8 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev, u8 data; err = st_lsm6dsx_check_odr(sensor, val, &data); + if (!err) + sensor->odr = val; break; } default: