Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp262587lqg; Thu, 11 Apr 2024 01:52:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUrLLNDKVmHBsJUzLJhfMJ9Wskfh/RwB6WYrxsexTI2BCvSW9wlJ0JWjF3WMFqzyO95bONI0ucK3Weh2ktCbzMmImNFBMM7Hp7ucYCQAw== X-Google-Smtp-Source: AGHT+IGTHRZwF0+t0WFIfjY/2mpUUeX8KtnBP7+x8LAozGbNhMCszm8QxcXJ2hJqley1hinrOaG7 X-Received: by 2002:a05:6a20:2d06:b0:1a7:1b6e:4c8 with SMTP id g6-20020a056a202d0600b001a71b6e04c8mr7437366pzl.18.1712825562247; Thu, 11 Apr 2024 01:52:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712825562; cv=pass; d=google.com; s=arc-20160816; b=uOyknYnvKyH2ziNSgBv+aW5Z3fFjB7PHJavzZNMG1WZj8htT518q0oHUzheZRFos/f J9d/NGqT95aJe4Ez3TS1MPIgCUPhOkU3xy04XrNHREr3zMhBrHmO+2bqqmxg2guHsfvg cgw5E8QcgnnlfTwpXahArJ6wRR3oUgGoGrtDQbaL4eTEc4ZpJMHtFu985OGkooMYp6dh b/Am3x9YYtCxp4mCOLeXOc132POOreyw7QvGLqpvv4jmrPB71rvSGpWhUoMFr5WldgW8 ry4rnrta2pD9c6f4MqpLOgfRuV/P++rD8lXyo9YCPT5CszfyM5Sbpcho298znCAwUA8D z89g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=wta2gWX4u9ZF8unGpNXdwZG7Lw5apk67azN69PwVgMg=; fh=3GUgNX5Y4IZGBhdL6Wgk67bVgDENWiYgvZ13WZtAURA=; b=jSXCT2Jji7qzwpu3uUl2UVq1auHAld16I34pAAMaf4w42X4d83THYKUMQv5GiYqZok g3Irs1I9XYFjn0dPkZ0pKHqCQ2c++jUrYKgUxrdXZ3kUZEg/2tr/Myk/peQTF+LIVaNf CRBWSXgn2rLsmthAJz98Nk0P52N/B45O8/Z77h5AbkX71UADZ2arPAaaNZQ8xWnFSk27 tlhWQB6RNrdrAxVtx6Ie+v/yXLk/Ap7qbWk9L5OHJK3ZVnw6E/nxbP2mh3LojnCM82DW OE+lrm3sMJSxhZ956JJXBpJcYLylSphq8yY07VFe81ZmTk/Ow1FABn2k7C1X7Nhu5q9a AS5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VFzRimod; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-140120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j12-20020a170903028c00b001e5373b0e46si931408plr.66.2024.04.11.01.52.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 01:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VFzRimod; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-140120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0332E281DC0 for ; Thu, 11 Apr 2024 08:52:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D542F143C62; Thu, 11 Apr 2024 08:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VFzRimod" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62D671422CC; Thu, 11 Apr 2024 08:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712825535; cv=none; b=i5gzzWDOAqfTP5tbKFgs0lxVhZilvJyMdQPQU3t/Bz7qtaXNwoB0EUeHjgFUzXmgWjs7ZGCw1dg111yaOSYQ2qVRkm42jbL8iUvKE42X1lAm5EJxDQzA3GSrj007ikeWG1RubvAKvJRdVsSLXKyCtcCKyYTZ2qjeac6GkJr00yU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712825535; c=relaxed/simple; bh=Lmp+/nQbro7M10fnzbwdyIkY7l8hkTvrz2rPgWvaS2s=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=IlR/wPO00ecOX2QzTqcBrW+9AIIf5ZCdam3VPUE/8a66Z+vpUOayQ0oXtW/jwAhlHqjw/utyxN9inew2Z/n2OERkmzVACqFuhyFvMjs5366FmNqwnpIgMIpkc+Cfmd5ZT4NEYQHLyXtqPtxbH4KMMPjIynhy/NlXaC89uhGXiiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VFzRimod; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712825533; x=1744361533; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Lmp+/nQbro7M10fnzbwdyIkY7l8hkTvrz2rPgWvaS2s=; b=VFzRimod6BP9kudbAmlTzcNXYX1w/aYa4TcpMdpghPlBASurbrLvWYqm 03F0fohRADpW5G9PLvQIta40VKsZMadlFRrqGBaErCM/KREQXMLzDvvcL 9pIqdSCC6SUmpa6SMwINF9A2geDg8LS5S4HFdJyrVsyF7bgsNrJxBaZ4w 0E2PF0cxJnw88GyELC2W/8q61RpxZmASeo3H0kZo9u02mOJG2SYUCtDDO YTSWDKVkbxXBoOHD9waE4HKdtd9FTZ0QVh5OtB0EPArNWfSiwgviV2SIW zjveo6mLqkRR2XF4ijufYV/COB9vTZUL2I1IYaLOxlPyYH7iUAXB8Knf7 A==; X-CSE-ConnectionGUID: WYVkxo0MTJ6UZJZ3539stA== X-CSE-MsgGUID: uNFeFnuNQdesrUfD/ja1nA== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8386897" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="8386897" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 01:52:13 -0700 X-CSE-ConnectionGUID: 5is+jPGDQE2tVNTNpf8inQ== X-CSE-MsgGUID: gnVtjtZRQA60saBAH+BdEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="25318573" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.30]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 01:52:10 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Thu, 11 Apr 2024 11:52:06 +0300 (EEST) To: "David E. Box" cc: Hans de Goede , platform-driver-x86@vger.kernel.org, LKML , sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH V4 8/9] platform/x86/intel/sdsi: Simplify ascii printing In-Reply-To: <20240411025856.2782476-9-david.e.box@linux.intel.com> Message-ID: <77993eef-b896-7e75-93ba-a76f126b5fad@linux.intel.com> References: <20240411025856.2782476-1-david.e.box@linux.intel.com> <20240411025856.2782476-9-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-1072423584-1712825526=:1017" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1072423584-1712825526=:1017 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 10 Apr 2024, David E. Box wrote: > Add #define for feature length and move NUL assignment from callers to > get_feature(). >=20 > Signed-off-by: David E. Box > Reviewed-by: Kuppuswamy Sathyanarayanan > --- > V4 - Move NUL assignment to get_feature() and increment FEAT_LEN. >=20 > V3 - Add FEAT_LEN #def >=20 > V2 - Split of V1 patch 7 >=20 > tools/arch/x86/intel_sdsi/intel_sdsi.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) >=20 > diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/inte= l_sdsi/intel_sdsi.c > index ba2a6b6645ae..301213370740 100644 > --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c > +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c > @@ -43,6 +43,7 @@ > #define METER_CERT_MAX_SIZE=094096 > #define STATE_MAX_NUM_LICENSES=0916 > #define STATE_MAX_NUM_IN_BUNDLE=09(uint32_t)8 > +#define FEAT_LEN=09=095=09/* 4 plus NUL terminator */ > =20 > #define __round_mask(x, y) ((__typeof__(x))((y) - 1)) > #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) > @@ -321,10 +322,11 @@ static char *content_type(uint32_t type) > =09} > } > =20 > -static void get_feature(uint32_t encoding, char *feature) > +static void get_feature(uint32_t encoding, char feature[5]) > { > =09char *name =3D (char *)&encoding; > =20 > +=09feature[4] =3D '\0'; > =09feature[3] =3D name[0]; > =09feature[2] =3D name[1]; > =09feature[1] =3D name[2]; Works, assuming none of the name bytes are 0. Reviewed-by: Ilpo J=E4rvinen --=20 i. > @@ -339,7 +341,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) > =09uint32_t count =3D 0; > =09FILE *cert_ptr; > =09int ret, size; > -=09char name[4]; > +=09char name[FEAT_LEN]; > =20 > =09ret =3D sdsi_update_registers(s); > =09if (ret) > @@ -383,7 +385,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) > =09printf("\n"); > =20 > =09get_feature(mc->signature, name); > -=09printf("Signature: %.4s\n", name); > +=09printf("Signature: %s\n", name); > =20 > =09printf("Version: %d\n", mc->version); > =09printf("Count Unit: %dms\n", mc->counter_unit); > @@ -391,7 +393,7 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) > =09printf("Feature Bundle Length: %d\n", mc->bundle_length); > =20 > =09get_feature(mc->mmrc_encoding, name); > -=09printf("MMRC encoding: %.4s\n", name); > +=09printf("MMRC encoding: %s\n", name); > =20 > =09printf("MMRC counter: %d\n", mc->mmrc_counter); > =09if (mc->bundle_length % METER_BUNDLE_SIZE) { > @@ -409,9 +411,8 @@ static int sdsi_meter_cert_show(struct sdsi_dev *s) > =20 > =09printf("Number of Feature Counters: %ld\n", BUNDLE_COUNT(mc->bundle= _length)); > =09while (count < BUNDLE_COUNT(mc->bundle_length)) { > -=09=09char feature[5]; > +=09=09char feature[FEAT_LEN]; > =20 > -=09=09feature[4] =3D '\0'; > =09=09get_feature(bec[count].encoding, feature); > =09=09printf(" %s: %d\n", feature, bec[count].counter); > =09=09++count; > @@ -494,7 +495,7 @@ static int sdsi_state_cert_show(struct sdsi_dev *s) > =09=09=09sizeof(*lki) +=09=09=09// size of the license key info > =09=09=09offset;=09=09=09=09// offset to this blob content > =09=09struct bundle_encoding *bundle =3D (void *)(lbc) + sizeof(*lbc); > -=09=09char feature[5]; > +=09=09char feature[FEAT_LEN]; > =09=09uint32_t i; > =20 > =09=09printf(" Blob %d:\n", count - 1); > @@ -507,8 +508,6 @@ static int sdsi_state_cert_show(struct sdsi_dev *s) > =09=09printf(" Blob revision ID: %u\n", lbc->rev_id); > =09=09printf(" Number of Features: %u\n", lbc->num_bundle= s); > =20 > -=09=09feature[4] =3D '\0'; > - > =09=09for (i =3D 0; i < min(lbc->num_bundles, STATE_MAX_NUM_IN_BUNDLE); = i++) { > =09=09=09get_feature(bundle[i].encoding, feature); > =09=09=09printf(" Feature %d: %s\n", i, feature)= ; --8323328-1072423584-1712825526=:1017--