Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1333250pxb; Tue, 8 Feb 2022 14:59:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN10zx4xScsOvY/8JSN82Sjr742RtgOS++Al6eOK5wH2WWsN47GgBqfAXx+3P+NsiXCHcL X-Received: by 2002:a05:6402:84a:: with SMTP id b10mr6810661edz.143.1644361172074; Tue, 08 Feb 2022 14:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644361172; cv=none; d=google.com; s=arc-20160816; b=TgLRKgCe7y+pXnZm/otz5dNExGbZekwwGB+cNnaNZ3YmF+B4GV8NKWz4fQjU4z/7cn Xkgstp22QfFk2e0JA0NFZSTz0Y9RgspgBp3FthzFptwqngF1393CUA1nEZkDanMYzmlm TqGld6mugFP57l6rGCCxRsu1AHe0OJ4sH2EFTmoCkqbJp98b/6r5b9qus7BaedAhXuzd v3yyFmGDO1iGJAf0Dc82eZZzLSqiyQyRX5c83yAb+2gFy0eUnY2fifJTZ4zGGwYUG7XA 316t+TXfNsXKYbRZJ/eTvNvLjzBPLrsvVGOmZdDyqRB87aTI59DbqtNounolojb+Pwbc mirQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=xm+csgTnUDpErNmAVkrgFErEXLw5b0TmRhIzFrD3fEI=; b=BGmRbDlwBdSqfSLLvxy4+dwfB03k8gZeC1f5djIRjkfW2IaMNqvzdf5AUAVvgQoUTJ Gzek374pEWBY8trRWUuL0il4uKpHljnIwFjMEhxiIT+Lm4EJ7qnvJxu0nFzWrb3wMhvN INwllIP/fd0y69KkcW/4+UQs1BkvOpH4A4kKo9nbwYHNHDn2TsOsR0zHfJuvsJPU0pF1 tEe/Od15DphcCt80njxy/E8KSJU8/8I2mEntC24/biUrvAaOroby4eGOKczHFFRZy0kI 354Aj3TH/9pX4+k2XHlCngYVsh6SfhI1OOiL5EepFL2bNeLayZus22UEHATdpDRRGJUf Rxjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZcLnfup6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji7si10580908ejc.39.2022.02.08.14.59.06; Tue, 08 Feb 2022 14:59:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZcLnfup6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbiBGFtU (ORCPT + 99 others); Mon, 7 Feb 2022 00:49:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240499AbiBGEpU (ORCPT ); Sun, 6 Feb 2022 23:45:20 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5878C043181 for ; Sun, 6 Feb 2022 20:45:19 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id n32so10918889pfv.11 for ; Sun, 06 Feb 2022 20:45: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; bh=xm+csgTnUDpErNmAVkrgFErEXLw5b0TmRhIzFrD3fEI=; b=ZcLnfup6DNDpRzMQqOuZ1AEsYS5RZiB2wSMVTgckVjNJgJhRK4jnkKi1QI3N3NQb6c CSBYImE44yFaJxI1jivJ0lUaXqp7X2aSvD3wHodKOss/dFNn7058OW33BFadFL+8mh7s Gz5Je7m/xJzA5hZvZPBd0hgCIqYuEO2yLuPskTfe8aIuc1AtNj930FMbrmXzf7xz2WJH raEXQiiIxSDZNwdw5ELaS8IVXRbpn3zH8ytBAdweX3in0ly7HU3mj9HP5NQcUHeQxCLd d0thewP68xUX9NyI33ll+lTZHlP9dFqG4MGbj76OKUXIbK/uQjNIGpB6jW80UAj7OTws W/ww== 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; bh=xm+csgTnUDpErNmAVkrgFErEXLw5b0TmRhIzFrD3fEI=; b=LnU1vI1w4s+A94aDGGpSo6QK+yUs7dC1sNHsHTPwAnF9HXnKUaNVw1sSyZnoftGZ90 bgtapTJJ6PzQ5r6ucmn8NUNLqdPt/n0mAII71lRnfubnc5F558rHGxsIUjQRlLKB4+f0 3rZJQuPWdkD42DjpeSt0gvfrEcanzjIWC1eTr6xoD/Y5Ei1yGJZ7o8lMJmDpmOLaZHsB zUbFpcwnAzPXAoqgnXhKg7xa40DcKdZ71COXzjEdItIiwde5FeKGqQIGMlajDIvKhr+2 wE2LgWDs3ePIA6FGKnkrE6ZxPsGjtzJKkNGsLHrHH5rkURPCDoVNLsMveRqEMhDO/BgF SMnw== X-Gm-Message-State: AOAM533XD4qdVhWSyjActjYcz5gPC9elw6SYrHXSIWlX8FeSRYXt8Dvb P2CqfLdWaouCTJsB96rfZDs= X-Received: by 2002:a05:6a00:1513:: with SMTP id q19mr14016623pfu.12.1644209119026; Sun, 06 Feb 2022 20:45:19 -0800 (PST) Received: from mail.google.com (219-89-118-172.adsl.xtra.co.nz. [219.89.118.172]) by smtp.gmail.com with ESMTPSA id ip4sm9145214pjb.8.2022.02.06.20.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 20:45:18 -0800 (PST) Date: Mon, 7 Feb 2022 17:45:12 +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] staging: pi433: remove need to recompile code to debug fifo content Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Debugging content present in the FIFO register is tricky as when we read the FIFO register that changes the content of fifo struct which reduces number of possible ways of debugging it. Rf69 uC has the possibility of triggering certain IRQs depending on how many items are in the FIFO queue, so being able to know what's in there is an important way to troubleshoot certain problems. This patch removes the requirement of having to compile pi433 driver with DEBUG_FIFO_ACCESS set and let that be driven by printk verbositity level and/or dynamic debug config instead. Signed-off-by: Paulo Miguel Almeida --- Meta-comments: #1 In my mind, I didn't like the idea of having to change the code and then echo "module pi433 +p" > /dynamic_debug/control to only then be able to read stuff being sent/retrieved from fifo. It felt somewhat redundant at a certain level. On the other hand, I understand that removing the conditional compilation will force a for-loop to iterate for no real reason most of the time (max 66 iterations)... so I made a trade-off and in case anyone disagrees with that, just let me know and I will be happy to change to a different approach. #2 In the past, it's been pointed out to me during code review that I tend to add code comments which could be omitted. In this case, the for-loop seemed a bit odd without explaining why it's in there. Let me know if you think I should keep/remove it. Patch dependency: This patch depends on the following patches being applied first: - https://lore.kernel.org/lkml/Yf9ivRB5qpmA5rY2@mail.google.com/ - https://lore.kernel.org/lkml/YgA4XHU4uf6YkOk5@mail.google.com/ --- drivers/staging/pi433/rf69.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index a8def70808d6..901f8db3e3ce 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -6,11 +6,6 @@ * Marcus Wolf */ -/* enable prosa debug info */ -#undef DEBUG -/* enable print of values on fifo access */ -#undef DEBUG_FIFO_ACCESS - #include #include @@ -829,9 +824,7 @@ int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) { -#ifdef DEBUG_FIFO_ACCESS int i; -#endif struct spi_transfer transfer; u8 local_buffer[FIFO_SIZE + 1]; int retval; @@ -851,10 +844,9 @@ int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) retval = spi_sync_transfer(spi, &transfer, 1); -#ifdef DEBUG_FIFO_ACCESS + /* print content read from fifo for debugging purposes */ for (i = 0; i < size; i++) dev_dbg(&spi->dev, "%d - 0x%x\n", i, local_buffer[i + 1]); -#endif memcpy(buffer, &local_buffer[1], size); @@ -863,9 +855,7 @@ int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) { -#ifdef DEBUG_FIFO_ACCESS int i; -#endif u8 local_buffer[FIFO_SIZE + 1]; if (size > FIFO_SIZE) { @@ -877,10 +867,9 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) local_buffer[0] = REG_FIFO | WRITE_BIT; memcpy(&local_buffer[1], buffer, size); -#ifdef DEBUG_FIFO_ACCESS + /* print content written from fifo for debugging purposes */ for (i = 0; i < size; i++) dev_dbg(&spi->dev, "0x%x\n", buffer[i]); -#endif return spi_write(spi, local_buffer, size + 1); } -- 2.34.1