From nobody Tue Jun 30 10:48:38 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 B7CECC433F5 for ; Tue, 18 Jan 2022 23:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350187AbiARXEY (ORCPT ); Tue, 18 Jan 2022 18:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350172AbiARXET (ORCPT ); Tue, 18 Jan 2022 18:04:19 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A238C06161C for ; Tue, 18 Jan 2022 15:04:19 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id f8so565089pgf.8 for ; Tue, 18 Jan 2022 15:04:19 -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=QfQD1u5VB3E351cX8YrjWGZk8vfWE2crrmBoY6ipDg4SX2/GS7Uck5C8/8Ixyl/ee6 5RwrN57TS0g+L9P/syCEvZqk3jluxNUUZuyAfiG3xxUYULGwOJOOuqCc82sm7+BwX3M8 uy83V4j/0LH7R2BhpkH71Jf/XHK5C5M7SnUlJFhokGszQ5UE6bb2OJLwiDN6rjwC7orl YvDv0rY6byus6J8y3Eyq5xO2hbztgN95nVDx57MDOsvjMyPjZGX2NeHSlxDCyrrP2gqR 0sEm+3hypvO86f1fGdg4wQJxJ/utQ8csuzhfsQrj3pgNEuPaiGB8UyU8fC3AiRsRZvtH 9Vvw== 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=nnDBug6r4MpLaIqTqifLQztLAa/YdojwV1MNFb9G2xShOhyIpgZgjEsjscntRS7EjU TtKPkFYkTvn1L/mMnaFMJyL1F8pHpKiDFhbFWE3BSkMCXVaWJ5+GgCPqlPw9O31KSGcK 8DbDqnHqm8221x8iWCIfWW/ILfuh0Rsq+irgoVJ9NnVr6Z+l/RUVgbYep87udtikJGjB xWyRTWn1gT+aPTVTu3K+VFJ1D0GL1f8pc2yrDFLUTWimrTS482e90gZ+mtHwq8YIIn0j 0nwMB5wrouRZnnR/pLRvR2IRDF/wF5MhidTbsYyzkO/q4CoV68cIe+gABKa4RSz4C3QL O6WQ== X-Gm-Message-State: AOAM531UnMGDDnvWVDPnH05JGE/bwSu7bb04e1hoQSkfss2bfOjKgst7 prjqa6WBd2ZrDEYxb5iIJd3Gr4nFoj7IVc2/pBw= X-Google-Smtp-Source: ABdhPJw+EJr9CIkmWZMT2kuFRRthOjv28RD0JsJY7pNppfXdsHHhYSV2ChZdm54sofXo+ulJRhvEMg== X-Received: by 2002:a62:1c12:0:b0:4bc:6d81:b402 with SMTP id c18-20020a621c12000000b004bc6d81b402mr27869091pfc.40.1642547058817; Tue, 18 Jan 2022 15:04:18 -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 x15sm20422153pfh.157.2022.01.18.15.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 15:04:18 -0800 (PST) Date: Wed, 19 Jan 2022 12:04:13 +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 v3 1/3] staging: pi433: fix validation for min bit rate supported by the device Message-ID: <20220118230413.GA4859@mail.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220118230312.GA4826@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 Acked-by: Dan Carpenter --- 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 10:48:38 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 55DFFC433F5 for ; Tue, 18 Jan 2022 23:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345283AbiARXFJ (ORCPT ); Tue, 18 Jan 2022 18:05:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiARXFI (ORCPT ); Tue, 18 Jan 2022 18:05:08 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98551C061574 for ; Tue, 18 Jan 2022 15:05:08 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id 59-20020a17090a09c100b001b34a13745eso4273002pjo.5 for ; Tue, 18 Jan 2022 15:05:08 -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=iZj1UrYomjsoNst1oHFF0dz6gUYl2R3R86cMGTV1/2YCsaWmkXfGqgZFOFtjr1YZk8 IzRDYzRzSVUkgOz7YAHzK57bJqsCP3rizbqzhXwBC5CJrQOJuPqMYGjjKGkJ3o4BYvIk 4oo+6gjjUfoVy1Ckai3kqWm4C2xZBOXdqMhW6lz4ehja9HT70/8fmZRBj89UsUOZEq12 +NXRBGHXQleJFh95XzcRYmw3jQicebSQH1LUzKvWx/GahWQsjyGHyoAAcKY6WEa1yw68 txyB6DhXh+N0rrtppw5HU+HnL5EwgTJayLY5YbHWF6JfI4xzl40f7Gmsce60kT/7EYoK QhtQ== 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=4vUcyqIv+WVodwCuIOAU4CoZwCvtuVKBD77a/nVfhcoS351zkUAQcjnzdYP6CAN9Ig swHhj8daX3sd7g5lckixO8UWjCDlGC/miEO0N1jy23FE7ZGIc6e2/a39X/zhKKVNOMOt N3TvmFLjLjgaX/7F1FdQSzACBRwxUp25Ho8YxSVZG0vEdVdw3SzIfIBRuIOUx7+5dGOS dcDOX82fijhwObd3ZKDuYeyR9bhqN2xf0pq6z8xK0Y5Gf5w60/2MQ6HV6e4PNUH1MIT1 or2vQ3pXyafYNjIERtFGfw9ZNwViSqXvIHYMuEzTMHNzZppfS0O5sgMgmSY4HyBEAE5g p/EQ== X-Gm-Message-State: AOAM530ied1elTl/N8Iq0a+Br5JecCzJyAyFYp/WiRfR3aF70Sk/H+Sf 40TOl+VE9nLxKnsQ1iQGCUA= X-Google-Smtp-Source: ABdhPJwBym8eeRcj0DVKaPItufN4k+RbokuV48j+BiichBZQGbGQaX0QAwwJXHJQ0uGtuJEszQPvlg== X-Received: by 2002:a17:903:1c4:b0:14a:555c:adc0 with SMTP id e4-20020a17090301c400b0014a555cadc0mr29501068plh.101.1642547108175; Tue, 18 Jan 2022 15:05:08 -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 on1sm3253534pjb.52.2022.01.18.15.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 15:05:07 -0800 (PST) Date: Wed, 19 Jan 2022 12:05:02 +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 v3 2/3] staging: pi433: change order in which driver config the rf69 chip Message-ID: <20220118230502.GA4897@mail.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220118230312.GA4826@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 Acked-by: Dan Carpenter --- 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 10:48:38 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 1EF09C433F5 for ; Tue, 18 Jan 2022 23:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350203AbiARXGE (ORCPT ); Tue, 18 Jan 2022 18:06:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350205AbiARXGB (ORCPT ); Tue, 18 Jan 2022 18:06:01 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0685FC06161C for ; Tue, 18 Jan 2022 15:06:01 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 133so632956pgb.0 for ; Tue, 18 Jan 2022 15:06:01 -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=Hmwr/NvAL+svS57T9uxuMiXf8YJx8mtgioZKYfbMWac=; b=BaFC4GCONEYspssy1GYPeTrMNDkEWVXKVAKOqw11b2bH5ij+Bh0ZcVZbIsqSHsX3Qr VrvkcDgelRGHD04GNSeQ0EawjnuSS9Sp6OTDcXsq37iiAC2I8naWSF1c+9wsh9n3YcWY 3UUa0zb2PG4/5oVgSbmFHG7VXw9wZJeB6DaGJZ8weyAX2Yc+1eyx2+cRLXOAg1q7/ZXD KL41pPLB6TArHpxRyXvcNKB9PRLiEm2cvYeQvn9tuNFja0Ns0l8vokrywxaaFURf9BFa zO996iFxIxH5Fi5k0TWEzkOL3CE9Pj1dwf1j4lCF/0pFPFt8ppVxSJOGfVXIu+R4ihfH F/1w== 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=Hmwr/NvAL+svS57T9uxuMiXf8YJx8mtgioZKYfbMWac=; b=AYvL24sjlFnmSAdeiUeTDHezU6Sf9RdiGIgS37ugGrpwfoT2cBQL27iIlng6jk/oSK FSNQYMOke+6NIl6Tn1ibB77L+nvY0B7F6VVEPnfh6XKWyIpoRPi4zWME8w+2+CmECAu1 LwGztpyzqJ5XPiFsiTpqtiztbI734hxzkQ8yGwGpr0cKCBDC2Qt4h6Aw7G2LzoZRYE8g E5MhpyM7aoJpO7iQ+NtUeP+NxHWidwvGTYNleVzPQPFtNgpxH892bbjPU8bHXpOlKsIq jJLNcbQ51gHfznpsPPGO1MPGQdG3E9MOyoHYilf09lPL3MNIBQGTDvPE/uVWwJwTH3Eq VgRw== X-Gm-Message-State: AOAM5304a6aSlquz21ZoyZoIBdHT6F/SzP4v8d+YrCX7Yo5UB8ozurHf mrMjMD5rCAhlbmu4ost2o7A= X-Google-Smtp-Source: ABdhPJw921ktYTKfD/b2cs4LS0dFFhpk51eulzdZ6obyPw2URyw/MnnVlyi5JrOouALyMeIx+POfCQ== X-Received: by 2002:a63:b10d:: with SMTP id r13mr25084906pgf.257.1642547160571; Tue, 18 Jan 2022 15:06:00 -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 t8sm15305456pga.15.2022.01.18.15.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 15:06:00 -0800 (PST) Date: Wed, 19 Jan 2022 12:05:55 +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 v3 3/3] staging: pi433: validate max bit_rate based on modulation used Message-ID: <20220118230555.GA4961@mail.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220118230312.GA4826@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 --- drivers/staging/pi433/TODO | 2 ++ drivers/staging/pi433/rf69.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO index 63a40bfcc67e..b9e6c01a02e0 100644 --- a/drivers/staging/pi433/TODO +++ b/drivers/staging/pi433/TODO @@ -3,3 +3,5 @@ * currently the code introduces new IOCTLs. I'm afraid this is a bad idea. -> Replace this with another interface, hints are welcome! * Some missing data (marked with ###) needs to be added in the documentati= on +* Change (struct pi433_tx_cfg)->bit_rate to be a u32 so that we can support + bit rates up to 300kbps per the spec. diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f4ac17adcd83..d60514a840c2 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -229,9 +229,17 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bit_= rate) 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 OOK && bit_rate > 32768)) { dev_dbg(&spi->dev, "setBitRate: illegal input param"); return -EINVAL; } --=20 2.25.4