From patchwork Fri Dec 18 12:44:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 7883271 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B265D9F32E for ; Fri, 18 Dec 2015 12:44:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4CDE200D4 for ; Fri, 18 Dec 2015 12:44:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1D40201ED for ; Fri, 18 Dec 2015 12:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753536AbbLRMok (ORCPT ); Fri, 18 Dec 2015 07:44:40 -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 S1753494AbbLRMoj (ORCPT ); Fri, 18 Dec 2015 07:44:39 -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 6390194; 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 2/4] spi: loopback-test: move to use spi_message_dump_data Date: Fri, 18 Dec 2015 12:44:25 +0000 Message-Id: <1450442668-2391-3-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 Move loopback-test to use the core spi_message_dump_data method. Signed-off-by: Martin Sperl --- drivers/spi/spi-loopback-test.c | 75 +++------------------------------------ 1 file changed, 4 insertions(+), 71 deletions(-) diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c index 7f497ac..8dac6a4 100644 --- a/drivers/spi/spi-loopback-test.c +++ b/drivers/spi/spi-loopback-test.c @@ -331,74 +331,6 @@ MODULE_LICENSE("GPL"); /* we allocate one page more, to allow for offsets */ #define SPI_TEST_MAX_SIZE_PLUS (SPI_TEST_MAX_SIZE + PAGE_SIZE) -static void spi_test_print_hex_dump(char *pre, const void *ptr, size_t len) -{ - /* limit the hex_dump */ - if (len < 1024) { - print_hex_dump(KERN_INFO, pre, - DUMP_PREFIX_OFFSET, 16, 1, - ptr, len, 0); - return; - } - /* print head */ - print_hex_dump(KERN_INFO, pre, - DUMP_PREFIX_OFFSET, 16, 1, - ptr, 512, 0); - /* print tail */ - pr_info("%s truncated - continuing at offset %04zx\n", - pre, len - 512); - print_hex_dump(KERN_INFO, pre, - DUMP_PREFIX_OFFSET, 16, 1, - ptr + (len - 512), 512, 0); -} - -static void spi_test_dump_message(struct spi_device *spi, - struct spi_message *msg, - bool dump_data) -{ - struct spi_transfer *xfer; - int i; - u8 b; - - dev_info(&spi->dev, " spi_msg@%pK\n", msg); - if (msg->status) - dev_info(&spi->dev, " status: %i\n", - msg->status); - dev_info(&spi->dev, " frame_length: %i\n", - msg->frame_length); - dev_info(&spi->dev, " actual_length: %i\n", - msg->actual_length); - - list_for_each_entry(xfer, &msg->transfers, transfer_list) { - dev_info(&spi->dev, " spi_transfer@%pK\n", xfer); - dev_info(&spi->dev, " len: %i\n", xfer->len); - dev_info(&spi->dev, " tx_buf: %pK\n", xfer->tx_buf); - if (dump_data && xfer->tx_buf) - spi_test_print_hex_dump(" TX: ", - xfer->tx_buf, - xfer->len); - - dev_info(&spi->dev, " rx_buf: %pK\n", xfer->rx_buf); - if (dump_data && xfer->rx_buf) - spi_test_print_hex_dump(" RX: ", - xfer->rx_buf, - xfer->len); - /* check for unwritten test pattern on rx_buf */ - if (xfer->rx_buf) { - for (i = 0 ; i < xfer->len ; i++) { - b = ((u8 *)xfer->rx_buf)[xfer->len - 1 - i]; - if (b != SPI_TEST_PATTERN_UNWRITTEN) - break; - } - if (i) - dev_info(&spi->dev, - " rx_buf filled with %02x starts at offset: %i\n", - SPI_TEST_PATTERN_UNWRITTEN, - xfer->len - i); - } - } -} - struct rx_ranges { struct list_head list; u8 *start; @@ -819,7 +751,7 @@ int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test, if (!simulate_only) { /* dump the complete message before and after the transfer */ if (dump_messages == 3) - spi_test_dump_message(spi, msg, true); + spi_message_dump_data(spi, msg, 1024); /* run spi message */ ret = spi_sync(spi, msg); @@ -855,8 +787,9 @@ 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_test_dump_message(spi, msg, - (dump_messages >= 2) || (ret)); + spi_message_dump_data(spi, msg, + ((dump_messages >= 2) || (ret)) ? + 1024 : 0); return ret; }