From nobody Tue Jun 30 12:57:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D20E5C433F5 for ; Mon, 17 Jan 2022 06:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234530AbiAQGA6 (ORCPT ); Mon, 17 Jan 2022 01:00:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbiAQGA5 (ORCPT ); Mon, 17 Jan 2022 01:00:57 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27FF4C061574 for ; Sun, 16 Jan 2022 22:00:57 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id n8so7008476plc.3 for ; Sun, 16 Jan 2022 22:00:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :in-reply-to; bh=vmI5obZJChROSVQzReKLArfFA6O6EbFVOPbqT4ROOPo=; b=bzXRibkL6gMspoMTyv32gwea7E+SjcByYvMKrn+OpRMWQvPQHkqJLNUpxhFO/2dnd+ Bi8f+tQgp/VEMvIxH03Ak0osC+8Wh1dJ3RNLO4patFiYMQyJNP1jONINPUYJbcM7jHHp donOX/7l8Irwb84ORSQGk5bgUoZ4X26DmKTEWrqQO3jS96+FdHRoBuxkfVP03AVN6j4U eNJR8kpYQYoUmBcwo/1P31OsCWJO4ftIq1f2uSz3emLO7OqmlXZQQoTpaxr/Y+ZljwQO X/ojPgNbDbEqaRQYVrgCQwx479DFSs8Jzoxc/kRxnC0g/KwEA1RdlAxLuVWehRS6YR83 jo8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to; bh=vmI5obZJChROSVQzReKLArfFA6O6EbFVOPbqT4ROOPo=; b=YZfDam35gQOuZ2bm5pARxvohf0rngWOXdGjNbIfRcsK8g2trJ5EWXyfm8jHVryD9C+ LP0oWGNW2JNTveH6Kmf9CAn8W0jL6P0HIRPr8Shm28nTps7Ubt67CmJ46qizqO9J/P4o /z7xbYcV1IYvk8e4Kt5M3JlxnLJqaz8oJYEqTww8XgWSRpv/5dXAztlx9bMfC6uMoCtv f9y+eT1M7Aa81n4a6Ti64UwoLhMw602Lru0z8OYRnKOTb1Ls68RbkJSrCF1Qr+svxL09 h8X4P+26fnkW0WUcR/GvpovQpd0b4AM+HKXkHZID9l4np14/tYVuLOC8eJ6xq2Q8vyKy StTw== X-Gm-Message-State: AOAM532IBHYSfh4cb2H8CL/izzAdECnqqz8EjX2q7W5/QjMfQ2raWLOz ppCf+aQhIuwXrQ/ha5nIO6UxjX3DXG5kiWAUmLY= X-Google-Smtp-Source: ABdhPJy8a32ETgRL0olBS3qP/6S7LC7VlalHzWMXG4NzGgYhIGqvk2ybzhzIs+cvef4g3kQUc8IN/A== X-Received: by 2002:a17:90a:247:: with SMTP id t7mr32719997pje.198.1642399256665; Sun, 16 Jan 2022 22:00:56 -0800 (PST) Received: from mail.google.com (122-58-164-114-fibre.sparkbb.co.nz. [122.58.164.114]) by smtp.gmail.com with ESMTPSA id h7sm12858657pfk.173.2022.01.16.22.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jan 2022 22:00:56 -0800 (PST) Date: Mon, 17 Jan 2022 19:00:51 +1300 From: Paulo Miguel Almeida To: gregkh@linuxfoundation.org, paulo.miguel.almeida.rodenas@gmail.com, realwakka@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] staging: pi433: fix validation for min bit rate supported by the device Message-ID: <20220117060051.GA10941@mail.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220117055849.GA10644@mail.google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" rf69 datasheets establishes that the minimum supported bit rate is 1.2 kbps regardless of modulation. this patch replaces the errouneous validation with the correct value Signed-off-by: Paulo Miguel Almeida --- drivers/staging/pi433/rf69.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index ee8c81d164e1..f4ac17adcd83 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -226,14 +226,12 @@ int rf69_set_modulation_shaping(struct spi_device *sp= i, int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate) { int retval; - u32 bit_rate_min; u32 bit_rate_reg; u8 msb; u8 lsb; =20 // check input value - bit_rate_min =3D F_OSC / 8388608; // 8388608 =3D 2^23; - if (bit_rate < bit_rate_min) { + if (bit_rate < 1200) { dev_dbg(&spi->dev, "setBitRate: illegal input param"); return -EINVAL; } --=20 2.25.4 From nobody Tue Jun 30 12:57:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8D31C433F5 for ; Mon, 17 Jan 2022 06:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234542AbiAQGBq (ORCPT ); Mon, 17 Jan 2022 01:01:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbiAQGBo (ORCPT ); Mon, 17 Jan 2022 01:01:44 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0042CC061574 for ; Sun, 16 Jan 2022 22:01:43 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id 59-20020a17090a09c100b001b34a13745eso29155664pjo.5 for ; Sun, 16 Jan 2022 22:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :in-reply-to; bh=9nmGSMsNg7TpxFokhDu2M3YQG+slmr+fovI7GFM6KVY=; b=iRTT4mTT5f1JQ5w0wUvrSV16Y5UDiUO1mVCE5/mlInMIjd6sKt/7tNNHXKf0wRfmNm AKuj7JjnpYCNvEpTf9VfNr256jPLicl3NVOunXMiFXsI1GS41KKHTuZP2WmzALqFrmaV wK6KjsQHEFlmpgQ4oSVg1UAc93xi43Jm9o63AzxTjTg2jfNVHsTZ0+dX4vE5Au4HVXzk vL38KcJ2QXJGlMHbTHH+tiB+NL+IrQvrm02dTXLCPhH42FymHhH157n/Llf+Icx078ve HPmM16CDdTvqR5KNPILIUkesMlGNjAtvuq72Cptk0uvKBntxuw45D4AMCtrOmZqnIXxW RqhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to; bh=9nmGSMsNg7TpxFokhDu2M3YQG+slmr+fovI7GFM6KVY=; b=nUtc5TMDQmHGvAobXcEIvTKILFMD14Vyn/g4/PB6u6Ec6r1DaL3GNoillnCnrkVGem aXCy3GlHKiqF2pmyqlumxBqlpb69V0sbLRqChT9btX6+55gsKvOdLaiBwMIaiqfJ1lem F3NvUITHyHBuv6jZkslup/J42rESl1g6JiKb59jzcfqJSPaiOCxU2cmzpQn8JWhPlkRg BAS2xJ/04e/R0FZzpspoqnvTIEsVMnBdgkzDNU7MFUsdhCSXF0fL4oxLoyaULxhnzJZ3 a/L7IhjyVz98aT2IeLyYjVx3sB10FNRBCDyqT61DNSE1KdielExXUO/sAV+gaS/EJywW x3rw== X-Gm-Message-State: AOAM532jk1Q0pRdqTs67OtdXUuDx5hIujKEN0nCuPp/CSnif3eo10nLx +tQ0sshm1dSvexc4lEAl1I4= X-Google-Smtp-Source: ABdhPJxV8pjGiuIn2t9jdM5gDt/vpH51KFiyyYnlex25bCokaNm0pQ9bIpQrOjQP6abfjsc6T82l2A== X-Received: by 2002:a17:902:8b8b:b0:149:66d6:b034 with SMTP id ay11-20020a1709028b8b00b0014966d6b034mr20674789plb.129.1642399303478; Sun, 16 Jan 2022 22:01:43 -0800 (PST) Received: from mail.google.com (122-58-164-114-fibre.sparkbb.co.nz. [122.58.164.114]) by smtp.gmail.com with ESMTPSA id k8sm13464707pfc.177.2022.01.16.22.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jan 2022 22:01:43 -0800 (PST) Date: Mon, 17 Jan 2022 19:01:38 +1300 From: Paulo Miguel Almeida To: gregkh@linuxfoundation.org, paulo.miguel.almeida.rodenas@gmail.com, realwakka@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] staging: pi433: change order in which driver config the rf69 chip Message-ID: <20220117060138.GA11140@mail.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220117055849.GA10644@mail.google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is an explicit dependency between modulation and bit rate configurations. To ensure proper validation of input value for the set_bit_rate routine, we must ensure that modulation has been set before. This patch ensures that set_modulation is always called before set_bit_rate for both RX and TX routines Signed-off-by: Paulo Miguel Almeida --- drivers/staging/pi433/pi433_if.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index f9f86e2c44a9..17ff51f6a9da 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -167,10 +167,10 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi43= 3_rx_cfg *rx_cfg) ret =3D rf69_set_frequency(dev->spi, rx_cfg->frequency); if (ret < 0) return ret; - ret =3D rf69_set_bit_rate(dev->spi, rx_cfg->bit_rate); + ret =3D rf69_set_modulation(dev->spi, rx_cfg->modulation); if (ret < 0) return ret; - ret =3D rf69_set_modulation(dev->spi, rx_cfg->modulation); + ret =3D rf69_set_bit_rate(dev->spi, rx_cfg->bit_rate); if (ret < 0) return ret; ret =3D rf69_set_antenna_impedance(dev->spi, rx_cfg->antenna_impedance); @@ -290,10 +290,10 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi43= 3_tx_cfg *tx_cfg) ret =3D rf69_set_frequency(dev->spi, tx_cfg->frequency); if (ret < 0) return ret; - ret =3D rf69_set_bit_rate(dev->spi, tx_cfg->bit_rate); + ret =3D rf69_set_modulation(dev->spi, tx_cfg->modulation); if (ret < 0) return ret; - ret =3D rf69_set_modulation(dev->spi, tx_cfg->modulation); + ret =3D rf69_set_bit_rate(dev->spi, tx_cfg->bit_rate); if (ret < 0) return ret; ret =3D rf69_set_deviation(dev->spi, tx_cfg->dev_frequency); --=20 2.25.4 From nobody Tue Jun 30 12:57:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DE41C433EF for ; Mon, 17 Jan 2022 06:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234550AbiAQGC1 (ORCPT ); Mon, 17 Jan 2022 01:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbiAQGC0 (ORCPT ); Mon, 17 Jan 2022 01:02:26 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1152C061574 for ; Sun, 16 Jan 2022 22:02:26 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id l6-20020a17090a4d4600b001b44bb75a8bso8802067pjh.3 for ; Sun, 16 Jan 2022 22:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :in-reply-to; bh=oYNbsridkjdw0mrmNIJXC9tA1DTH89l9mm4V1SaB7II=; b=CVzimYdjMdj+rMkORT0DnpDSFjsK5qJ9o52H6ByQvWMdtgY+ULePg/qmE2tMabdHvk NCRg/UZOcQO/IIMlQifsXFc93W0kIs5iTbcG0wbmhPl10R9FasVW2zO9MBRItg7r0iLY ereHzUwWhCM7sKdSyoLFnHkamWmG+Y1cfI/5gEdNGYK0V984ceYzWM0oz+6Mwdr7oqxA DiAwEOqTD+tyOi69Mw5guzXwCToQglXG9oG72+KBH7ltncChrRuTWUP0wPYK/eYpeo8G s9amfzOhcAIqX1+QbUhVBUBfFgxmGGk7TRFMhncrCcd/E0PX0FPgMz6P7CKPzz60Xthi q6og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to; bh=oYNbsridkjdw0mrmNIJXC9tA1DTH89l9mm4V1SaB7II=; b=gWb+25HBZXtLA/iw99fqXGW+oImABbJ0ZjYe6wuPKoErJaf/5h+S4IadN1Qv1LQIis psDD5eQrbbYDIBsJjNonJhUUaI12xSdwNM7hse+sdMvsGQHpx3CazsZNqJyxK8xEgJhZ kPeLLsXfFfYjwj1vaBnap/7EpOKcJ26P6QHsaEvWMu4k/PFlDaP8diXoehnfEU4r+Ffb r16Jr+aRWHpjVBXCA3eCcrp1vtfCDjFlSfBJXZdqG6fIvZXKaiPw+hkC8JMkjIEYz6UX iLr88hp9jmNmiCV3YFtJKDpiv5nBk5hUPCE0tcyxNgXHdXTr6VP2jwuxyZhB7PsAK3Uu IxHA== X-Gm-Message-State: AOAM533YjkiumV2ZaqdK00SeOEIjOy+10azuIR/1FaxMWgphMHGzyakx Jo8V7kjC78AIhihQNjYRx/4= X-Google-Smtp-Source: ABdhPJw7wW+Ei3qEjCJEtInStJsZnCDLqtZoUPSL4PynvafDzn+vcdGgEDq8mOjw2RFVXlWs7U0Crw== X-Received: by 2002:a17:90b:2386:: with SMTP id mr6mr32773747pjb.24.1642399346264; Sun, 16 Jan 2022 22:02:26 -0800 (PST) Received: from mail.google.com (122-58-164-114-fibre.sparkbb.co.nz. [122.58.164.114]) by smtp.gmail.com with ESMTPSA id y3sm11160796pjp.55.2022.01.16.22.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jan 2022 22:02:25 -0800 (PST) Date: Mon, 17 Jan 2022 19:02:20 +1300 From: Paulo Miguel Almeida To: gregkh@linuxfoundation.org, paulo.miguel.almeida.rodenas@gmail.com, realwakka@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] staging: pi433: validate max bit_rate based on modulation used Message-ID: <20220117060220.GA11202@mail.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220117055849.GA10644@mail.google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Max bit rate is dependent on which modulation is used. Previous validation routine only took into consideration min bit rate which can lead a misconfiguration of the rf69 chip causing the packets not to be sent/read. This patch enhances that input check in set_bit_rate to account for modulation values and their respective max bit rate Signed-off-by: Paulo Miguel Almeida Acked-by: Dan Carpenter --- Meta-comments: In the patchset v1 I kept bit_rate argument's original type as I thought th= at changing it to accomodate values as high as 300kbps couldn't be part of this patchset and therefore it should be a separate patchset.=20 Given that kernel test bot compilation/test process 'complained' about the=20 argument's type, I decided to send the v2 patch that addresses the data type problem while I work on the patch that will change bit_rate type across tx_cfg and rx_cfg as this will require a bit more work. Please let me know if anyone dislikes the approach and wants me to deal wit= h it in a different way. --- drivers/staging/pi433/rf69.c | 14 ++++++++++++-- drivers/staging/pi433/rf69.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f4ac17adcd83..adba69b8365e 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -223,15 +223,25 @@ int rf69_set_modulation_shaping(struct spi_device *sp= i, } } =20 -int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate) +int rf69_set_bit_rate(struct spi_device *spi, u32 bit_rate) { int retval; u32 bit_rate_reg; u8 msb; u8 lsb; + enum modulation mod; + + // check if modulation is configured + mod =3D rf69_get_modulation(spi); + if (mod =3D=3D UNDEF) { + dev_dbg(&spi->dev, "setBitRate: modulation is undefined"); + return -EINVAL; + } =20 // check input value - if (bit_rate < 1200) { + if (bit_rate < 1200 || + (mod =3D=3D FSK && bit_rate > 300000) || + (mod =3D=3D OOK && bit_rate > 32768)) { dev_dbg(&spi->dev, "setBitRate: illegal input param"); return -EINVAL; } diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index c25942f142a6..3b8184155326 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -23,7 +23,7 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mo= de); int rf69_set_modulation(struct spi_device *spi, enum modulation modulation= ); int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping mod_shaping); -int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate); +int rf69_set_bit_rate(struct spi_device *spi, u32 bit_rate); int rf69_set_deviation(struct spi_device *spi, u32 deviation); int rf69_set_frequency(struct spi_device *spi, u32 frequency); int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask); --=20 2.25.4