From patchwork Thu Sep 4 13:04:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 4845521 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 583C19F390 for ; Thu, 4 Sep 2014 13:05:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA38520220 for ; Thu, 4 Sep 2014 13:05:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D10E201CD for ; Thu, 4 Sep 2014 13:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbaIDNFX (ORCPT ); Thu, 4 Sep 2014 09:05:23 -0400 Received: from mga01.intel.com ([192.55.52.88]:15807 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751063AbaIDNFW (ORCPT ); Thu, 4 Sep 2014 09:05:22 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 04 Sep 2014 06:04:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,465,1406617200"; d="scan'208";a="594514764" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.168]) by fmsmga002.fm.intel.com with ESMTP; 04 Sep 2014 06:04:39 -0700 Received: from andy by smile with local (Exim 4.84) (envelope-from ) id 1XPWiM-0003IC-AX; Thu, 04 Sep 2014 16:04:38 +0300 From: Andy Shevchenko To: Hans Verkuil , Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH] hdpvr: reduce memory footprint when debugging Date: Thu, 4 Sep 2014 16:04:38 +0300 Message-Id: <1409835878-12617-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 There is no need to use hex_dump_to_buffer() since we have a kernel helper to dump up to 64 bytes just via printk(). Signed-off-by: Andy Shevchenko --- drivers/media/usb/hdpvr/hdpvr-control.c | 21 ++++++--------------- drivers/media/usb/hdpvr/hdpvr-core.c | 27 ++++++--------------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-control.c b/drivers/media/usb/hdpvr/hdpvr-control.c index 6053661..6e86032 100644 --- a/drivers/media/usb/hdpvr/hdpvr-control.c +++ b/drivers/media/usb/hdpvr/hdpvr-control.c @@ -59,13 +59,10 @@ int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) 1000); #ifdef HDPVR_DEBUG - if (hdpvr_debug & MSG_INFO) { - char print_buf[15]; - hex_dump_to_buffer(dev->usbc_buf, 5, 16, 1, print_buf, - sizeof(print_buf), 0); + if (hdpvr_debug & MSG_INFO) v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, - "get video info returned: %d, %s\n", ret, print_buf); - } + "get video info returned: %d, %5ph\n", ret, + dev->usbc_buf); #endif mutex_unlock(&dev->usbc_mutex); @@ -82,9 +79,6 @@ int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) int get_input_lines_info(struct hdpvr_device *dev) { -#ifdef HDPVR_DEBUG - char print_buf[9]; -#endif int ret, lines; mutex_lock(&dev->usbc_mutex); @@ -96,13 +90,10 @@ int get_input_lines_info(struct hdpvr_device *dev) 1000); #ifdef HDPVR_DEBUG - if (hdpvr_debug & MSG_INFO) { - hex_dump_to_buffer(dev->usbc_buf, 3, 16, 1, print_buf, - sizeof(print_buf), 0); + if (hdpvr_debug & MSG_INFO) v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, - "get input lines info returned: %d, %s\n", ret, - print_buf); - } + "get input lines info returned: %d, %3ph\n", ret, + dev->usbc_buf); #else (void)ret; /* suppress compiler warning */ #endif diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c index c563896..42b4cdf 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -124,14 +124,6 @@ static int device_authorization(struct hdpvr_device *dev) int ret, retval = -ENOMEM; char request_type = 0x38, rcv_request = 0x81; char *response; -#ifdef HDPVR_DEBUG - size_t buf_size = 46; - char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL); - if (!print_buf) { - v4l2_err(&dev->v4l2_dev, "Out of memory\n"); - return retval; - } -#endif mutex_lock(&dev->usbc_mutex); ret = usb_control_msg(dev->udev, @@ -147,11 +139,9 @@ static int device_authorization(struct hdpvr_device *dev) } #ifdef HDPVR_DEBUG else { - hex_dump_to_buffer(dev->usbc_buf, 46, 16, 1, print_buf, - 5*buf_size+1, 0); v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, - "Status request returned, len %d: %s\n", - ret, print_buf); + "Status request returned, len %d: %46ph\n", + ret, dev->usbc_buf); } #endif @@ -189,15 +179,13 @@ static int device_authorization(struct hdpvr_device *dev) response = dev->usbc_buf+38; #ifdef HDPVR_DEBUG - hex_dump_to_buffer(response, 8, 16, 1, print_buf, 5*buf_size+1, 0); - v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, "challenge: %s\n", - print_buf); + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, "challenge: %8ph\n", + response); #endif challenge(response); #ifdef HDPVR_DEBUG - hex_dump_to_buffer(response, 8, 16, 1, print_buf, 5*buf_size+1, 0); - v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, " response: %s\n", - print_buf); + v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, " response: %8ph\n", + response); #endif msleep(100); @@ -213,9 +201,6 @@ static int device_authorization(struct hdpvr_device *dev) retval = ret != 8; unlock: mutex_unlock(&dev->usbc_mutex); -#ifdef HDPVR_DEBUG - kfree(print_buf); -#endif return retval; }