Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp568158ybg; Tue, 28 Jul 2020 13:02:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaOLHfb0iKuT2q0NLq9GmXlMxgZbJh3qIKOQY4A09rQzLnZLcqC/75iQnAYXhEW08oObFq X-Received: by 2002:a17:906:c40d:: with SMTP id u13mr26442907ejz.519.1595966542910; Tue, 28 Jul 2020 13:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595966542; cv=none; d=google.com; s=arc-20160816; b=FFucCNHikRpkIcCo5lPKIC4gWkwrC5wMFnjRK/wKFvCMur2EzK6GS7Vmuws8SeD1Zd M4cFQ2ZT1be+5TQyBAdfReW4y0juGlHThBomGmbWaHj7gD6eRSzcTaVO2Kg5PYQVW7lX rwilFZb3JTlKjqc79SAcNjymEcf2zEqGeRzNCZg21J3cfAjY3TFvfoidAhD2VyQIXA/N Tv+4h8H5OqNkvyNcCIDvbe91pZGz5r92/8JTk/C2ziySrkKX9M+9rpn3vrgidhh9Z0qu AQt5Ae7ghc2Ycm6L/Q3ac5aXRJq+X5Zy2g0HcQA/5BzJNdDNexKDsl0nDefRTy8fpRBn iNjg== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=JBvAL50P9oYBy/Q6szVKDrhAqwRoUFlITph9Snmtpfc=; b=ksSxqbLuWfMkx4uwk0WbvYdTIHD6TUw4S8WhKlZ+/sZLABy+US7vayRXrLgr576Xmr 9qwFnsoDJjpgOdG/Wd+UvtVq/zJ/CPFZzrktbFq3QjB4ObiNKJskXgyPB820kDlcybpc fAI5lDKhanWS06YxEbQPWuq5CsXin64QkygsfjxScJBLTY7W7ApTSVlrtfhVLGr1ci52 Qr/IMzCOIePixXagvutTSb/Qr5YfjDHPnCWgl5rrXWyfsLG693Hj3vak0DPyQNQRy6ub 4naVUjrXOD3tAr3Ed/KyRTCZW2RcVINP2OGOHy4TXCSg5c9v3+Xs86o3d2BgvZGTxZZq uyew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si7297515edq.178.2020.07.28.13.01.58; Tue, 28 Jul 2020 13:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732238AbgG1SKx (ORCPT + 99 others); Tue, 28 Jul 2020 14:10:53 -0400 Received: from mga07.intel.com ([134.134.136.100]:19385 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728834AbgG1SKx (ORCPT ); Tue, 28 Jul 2020 14:10:53 -0400 IronPort-SDR: WmWiqBpKZ97LzAmNOCWdSkirne2J1FrSpqZTUfK/UITGqhUt9qjI9ZhL6d188/JIfCL2lepYgP 0smzNtvjHG0w== X-IronPort-AV: E=McAfee;i="6000,8403,9696"; a="215796103" X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="215796103" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2020 11:10:52 -0700 IronPort-SDR: A6qK79H71M9Uxr+9EIltU83hE1/D66iPcYDMVG2RCIe0ZZBh2586bD4zeWucOOzVEevKqoabhf aOfFMTaLTVaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="364586885" Received: from rmangham-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.254.114.251]) by orsmga001.jf.intel.com with ESMTP; 28 Jul 2020 11:10:52 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Fix calculation of model publication period Date: Tue, 28 Jul 2020 11:10:51 -0700 Message-Id: <20200728181051.22075-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This fixes the extraction of bit fields from model publication period octet received as part of Congif Publication Set message. The step resolution field is extracted as upper 2 bits (shift by 6) and the number of steps field is extracted by masking lower 6 bits. --- mesh/model.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 31197b363..ef7668147 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -170,20 +170,21 @@ static struct mesh_model *get_model(struct mesh_node *node, uint8_t ele_idx, static uint32_t pub_period_to_ms(uint8_t pub_period) { - int n; + int step_res, num_steps; - n = pub_period >> 2; + step_res = pub_period >> 6; + num_steps = pub_period & 0x3f; - switch (pub_period & 0x3) { + switch (step_res) { default: - return n * 100; + return num_steps * 100; case 2: - n *= 10; + num_steps *= 10; /* Fall Through */ case 1: - return n * 1000; + return num_steps * 1000; case 3: - return n * 10 * 60 * 1000; + return num_steps * 10 * 60 * 1000; } } -- 2.26.2