From patchwork Wed Aug 20 09:42:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 4748451 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D3D44C033A for ; Wed, 20 Aug 2014 09:46:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A40920108 for ; Wed, 20 Aug 2014 09:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20EC1201BC for ; Wed, 20 Aug 2014 09:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752400AbaHTJop (ORCPT ); Wed, 20 Aug 2014 05:44:45 -0400 Received: from mga09.intel.com ([134.134.136.24]:53692 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751923AbaHTJm7 (ORCPT ); Wed, 20 Aug 2014 05:42:59 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 20 Aug 2014 02:37:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,901,1400050800"; d="scan'208";a="561005142" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.77]) by orsmga001.jf.intel.com with ESMTP; 20 Aug 2014 02:42:54 -0700 Received: from andy by smile with local (Exim 4.84) (envelope-from ) id 1XK2Pt-00076d-0U; Wed, 20 Aug 2014 12:42:53 +0300 From: Andy Shevchenko To: "John W . Linville" , Johannes Berg , devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton , Joe Perches Cc: Andy Shevchenko Subject: [PATCH v3 09/11] staging: wlan-ng: use %*pEhp to print SN Date: Wed, 20 Aug 2014 12:42:50 +0300 Message-Id: <1408527772-27224-10-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1408527772-27224-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1408527772-27224-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.6 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 This is a generic specifier to print an escaped buffer by given criteria. Let's use it instead of custom approach. Signed-off-by: Andy Shevchenko --- drivers/staging/wlan-ng/prism2sta.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index 799ce8a..df577df 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include @@ -81,27 +80,6 @@ #include "hfa384x.h" #include "prism2mgmt.h" -/* Create a string of printable chars from something that might not be */ -/* It's recommended that the str be 4*len + 1 bytes long */ -#define wlan_mkprintstr(buf, buflen, str, strlen) \ -{ \ - int i = 0; \ - int j = 0; \ - memset(str, 0, (strlen)); \ - for (i = 0; i < (buflen); i++) { \ - if (isprint((buf)[i])) { \ - (str)[j] = (buf)[i]; \ - j++; \ - } else { \ - (str)[j] = '\\'; \ - (str)[j+1] = 'x'; \ - (str)[j+2] = hex_asc_hi((buf)[i]); \ - (str)[j+3] = hex_asc_lo((buf)[i]); \ - j += 4; \ - } \ - } \ -} - static char *dev_info = "prism2_usb"; static wlandevice_t *create_wlan(void); @@ -607,7 +585,6 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hfa384x_t *hw = (hfa384x_t *) wlandev->priv; u16 temp; u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN]; - char pstr[(HFA384x_RID_NICSERIALNUMBER_LEN * 4) + 1]; /* Collect version and compatibility info */ /* Some are critical, some are not */ @@ -862,9 +839,8 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER, snum, HFA384x_RID_NICSERIALNUMBER_LEN); if (!result) { - wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN, - pstr, sizeof(pstr)); - netdev_info(wlandev->netdev, "Prism2 card SN: %s\n", pstr); + netdev_info(wlandev->netdev, "Prism2 card SN: %*pEhp\n", + HFA384x_RID_NICSERIALNUMBER_LEN, snum); } else { netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n"); goto failed;