From patchwork Fri Dec 18 12:44:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 7883281 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8DF53BEEE5 for ; Fri, 18 Dec 2015 12:44:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC5632017D for ; Fri, 18 Dec 2015 12:44:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6780202AE for ; Fri, 18 Dec 2015 12:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753494AbbLRMom (ORCPT ); Fri, 18 Dec 2015 07:44:42 -0500 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163]:39912 "EHLO cgate.sperl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753502AbbLRMol (ORCPT ); Fri, 18 Dec 2015 07:44:41 -0500 Received: from raspcm.intern.sperl.org (account martin@sperl.org [10.10.10.41] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6390191; Fri, 18 Dec 2015 12:44:34 +0000 From: kernel@martin.sperl.org To: Geert Uytterhoeven , Mark Brown , linux-spi@vger.kernel.org Cc: Martin Sperl Subject: [PATCH 3/4] spi: loopback-test: make dump_messages module parameter a bitmask Date: Fri, 18 Dec 2015 12:44:26 +0000 Message-Id: <1450442668-2391-4-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1450442668-2391-1-git-send-email-kernel@martin.sperl.org> References: <1450442668-2391-1-git-send-email-kernel@martin.sperl.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Sperl Make dump_messages module parameter a bitmask to allow for better granularity when dumping messages. Signed-off-by: Martin Sperl --- drivers/spi/spi-loopback-test.c | 40 ++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c index 8dac6a4..6e76c3e 100644 --- a/drivers/spi/spi-loopback-test.c +++ b/drivers/spi/spi-loopback-test.c @@ -36,11 +36,17 @@ MODULE_PARM_DESC(simulate_only, "if not 0 do not execute the spi message"); /* dump spi messages */ int dump_messages; +#define DUMP_MESSAGE_AFTER BIT(0) +#define DUMP_MESSAGE_BEFORE BIT(1) +#define DUMP_MESSAGE_DATA_AFTER BIT(2) +#define DUMP_MESSAGE_DATA_BEFORE BIT(3) module_param(dump_messages, int, 0); -MODULE_PARM_DESC(dump_message, - "=1 dump the basic spi_message_structure, " \ - "=2 dump the spi_message_structure including data, " \ - "=3 dump the spi_message structure before and after execution"); +MODULE_PARM_DESC(dump_messages, + "BIT(0) - dump the basic spi_message_structure after processing, " + "BIT(1) - dump the basic spi_message_structure before processing, " + "BIT(2) - also dump the spi_message data after processing, " + "BIT(3) - also dump the spi_message data before processing"); + /* the device is jumpered for loopback - enabling some rx_buf tests */ int loopback; module_param(loopback, int, 0); @@ -749,9 +755,15 @@ int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test, /* only if we do not simulate */ if (!simulate_only) { - /* dump the complete message before and after the transfer */ - if (dump_messages == 3) - spi_message_dump_data(spi, msg, 1024); + /* dump the complete message before the transfer */ + if (dump_messages & DUMP_MESSAGE_BEFORE) { + /* calc bytes to dump */ + if (dump_messages & DUMP_MESSAGE_DATA_BEFORE) + i = 1024; + else + i = 0; + spi_message_dump_data(spi, msg, i); + } /* run spi message */ ret = spi_sync(spi, msg); @@ -786,10 +798,16 @@ int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test, /* if requested or on error dump message (including data) */ exit: - if (dump_messages || ret) - spi_message_dump_data(spi, msg, - ((dump_messages >= 2) || (ret)) ? - 1024 : 0); + if ((dump_messages & DUMP_MESSAGE_AFTER) || ret) { + /* calc bytes to dump */ + i = 0; + if (dump_messages & DUMP_MESSAGE_DATA_AFTER) + i = 1024; + if (ret) + i = 1024; + /* dump the message */ + spi_message_dump_data(spi, msg, i); + } return ret; }