From patchwork Sat Mar 7 17:56:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: adrianremonda@gmail.com X-Patchwork-Id: 5959941 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 0D785BF440 for ; Sat, 7 Mar 2015 17:57:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F2A7200C6 for ; Sat, 7 Mar 2015 17:57:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5392A20035 for ; Sat, 7 Mar 2015 17:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751617AbbCGR5M (ORCPT ); Sat, 7 Mar 2015 12:57:12 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:37294 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbbCGR5K (ORCPT ); Sat, 7 Mar 2015 12:57:10 -0500 Received: by wesx3 with SMTP id x3so19049410wes.4; Sat, 07 Mar 2015 09:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sYvVQ74e8VeAmyPSGikLK+zXu6Vfd9n9kdKPNG49/So=; b=gIu6b0Z3/fxc/DkySyUstfQ4f+W+Iwiw/RtoH2AdKqZC8j43KC2rleFiBkF9ZD7tRb dhaxIhe1KSlUXXyz3bCHD4WA4K7AkmU06NQtkE6FJNfpJ8WIIUZ9zs1eRGUkhPAz+2QB oYWjHPSp2JYqAnPhFK3LnmCEmAKGc8B9bUR7m8Sv7zkeJ23evmpBorsStL6AapubNT2g 6GW2d5Kv4lUg7Z9mOr0ciwTnv6q0wruSHPzgwIXHORPL972JK4MhWZ+juG3YUsfUNaG7 Mf5WAHY9ioCYBfLstr6BR6uE30ylTprW+QkE0SyP3MH9681DDksFMb66ahL2lwHotWev OKHQ== X-Received: by 10.194.59.199 with SMTP id b7mr42070487wjr.26.1425751028877; Sat, 07 Mar 2015 09:57:08 -0800 (PST) Received: from debian.fh-joanneum.at (fh.fh-joanneum.at. [91.229.57.240]) by mx.google.com with ESMTPSA id lj13sm7559769wic.9.2015.03.07.09.57.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Mar 2015 09:57:08 -0800 (PST) From: Adrian Remonda Cc: adrianremonda@gmail.com, broonie@kernel.org, corbet@lwn.net, linux-spi@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] Cleaned hexadecimal dump Date: Sat, 7 Mar 2015 12:56:32 -0500 Message-Id: <1425750995-18176-2-git-send-email-adrianremonda@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1425750995-18176-1-git-send-email-adrianremonda@gmail.com> References: <1425750995-18176-1-git-send-email-adrianremonda@gmail.com> To: unlisted-recipients:; (no To-header on input) 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Signed-off-by: Adrian Remonda --- Documentation/spi/spidev_test.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c index 3a2f9d59edab..533050ced9f1 100644 --- a/Documentation/spi/spidev_test.c +++ b/Documentation/spi/spidev_test.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,33 @@ static uint8_t bits = 8; static uint32_t speed = 500000; static uint16_t delay; +static void hexDump(const void *src, size_t length, size_t bLine, char *prefix) +{ + int i = 0; + char *address = (char *)src; + char *line = (char *)address; + unsigned char c; + + printf("%s | ", prefix); + while (length-- > 0) { + printf("%02X ", (unsigned char)*address++); + if (!(++i % bLine) || (length == 0 && i % bLine)) { + if (length == 0) { + while (i++ % bLine) + printf("__ "); + } + printf(" | "); /* right close */ + while (line < address) { + c = *line++; + printf("%c", (c < 33 || c == 255) ? 0x2E : c); + } + printf("\n"); + if (length > 0) + printf("%s | ", prefix); + } + } +} + static void transfer(int fd) { int ret; @@ -76,12 +104,7 @@ static void transfer(int fd) if (ret < 1) pabort("can't send spi message"); - for (ret = 0; ret < ARRAY_SIZE(tx); ret++) { - if (!(ret % 6)) - puts(""); - printf("%.2X ", rx[ret]); - } - puts(""); + hexDump(rx, ARRAY_SIZE(tx), 32, "RX"); } static void print_usage(const char *prog)