Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp349339pxf; Wed, 24 Mar 2021 06:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNR93bRdmRo9mMXyCX4gKVdtNnsS3UlX0j8cDFMzs8qg+keeiOrMJqKvliQQ/5luug/W7n X-Received: by 2002:a17:907:628a:: with SMTP id nd10mr3784342ejc.326.1616593220079; Wed, 24 Mar 2021 06:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616593220; cv=none; d=google.com; s=arc-20160816; b=wjt8FdiWu9435dcLKJJHc0kUOCoYjXc2JuwzQxubauy/HAmqUaTBElhSKL4qKeswr6 mdpwmDeO+iKMs2YGFfPK1keVjVDfg0lkKq56TWRpW8o8fjoMprnrJSE8U+1YkscfIvst q/RsN+yuEnMqTektKOJwpDVoGTseCkbcCGDZY5uqE/M8jgFTbBBRGzhjfD+QSI19+A8Y /iHJ6tBGBt71LRG1JUAdv6WpBko6ECZJFj7KO0a10tEDBsmwSRtYnV8Gh0J3HNfYUcaX lYsEMazlMShoI1kdii1sq7i8Aa23D0rbHwAJzVXRHQyoQ0EA+0iIBekU+YhONEs8vTGS ALBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mKyEJvRJM15uG+l9UbSSV3p2kXaYK0tOLuKoSvLXMuE=; b=luCgBQthXQlK7WJTQ6wGmrlfaoqnP1t/WsaSrSz3FRfwjrUtoHYrh+qdxNUxgdd/O2 dX5UwmAFrTU7R3r3Mr53EyqUbl/9ll7hHP6TJLlFGuxs20EuXinbfvJBk7zFAroPL2ct uNM8NAiqigC8h5n+oy/RoRA75usGzIciGYheJjAdF1DOrIrCi+IMurbCjau1zh2gfNB/ gKyRFmWkeqSSaZNipNOqk25emnC3g2NTAXxV9qFl2znDF/I0VYcj6f3+PbWNhidvzhGe a5CWHlZVMGoqYeb7TxrBPdj8i5w/JZXeGkdmPOPlhqP84Bfd1bxL7k/Go6b7+5kiZGZZ Serw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YjucVhlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ze11si1814533ejb.434.2021.03.24.06.39.55; Wed, 24 Mar 2021 06:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YjucVhlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235306AbhCXNhd (ORCPT + 99 others); Wed, 24 Mar 2021 09:37:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:48050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235284AbhCXNhJ (ORCPT ); Wed, 24 Mar 2021 09:37:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C94061A01; Wed, 24 Mar 2021 13:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616593029; bh=PslWGV1zAHiCp3MqLppdgDKQmZVZu+7LJijobMo672I=; h=From:To:Cc:Subject:Date:From; b=YjucVhlv4T4O6vQl3V2slzxT7hy6Co+DyTCphMDBxW5NMFNt8DjqAQgZqd9UF9b5W OXFRcGTiWArcvxPvg83co4bR3fHa8DEiq2E6H4xez//ePlhqww/9AU2sauVUBOCA00 d1F+oi/qwjxBdhkZVtGnU85ewEhX2a4xjJQxSPmTW5bVGsFUTHvrouVIun8RwEPjIg VO5dYbrHGWt+O6cE+C+pb9DS0BLkko1UT62XusklGh7hoQzCGFEY4xlEeuzIyWWb9d yuJxJbeGWlTdtWreyotXLRL3rkNZpIvarkU8u0JD5emchlX8KUC1mllSw9jdz4I1wV eOarLf2DivS1g== From: Arnd Bergmann To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Daniel Vetter Cc: Arnd Bergmann , Rasmus Villemoes , Jinzhou Su , Huang Rui , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] amdgpu: securedisplay: simplify i2c hexdump output Date: Wed, 24 Mar 2021 14:36:52 +0100 Message-Id: <20210324133705.2664873-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann A previous fix I did left a rather complicated loop in amdgpu_securedisplay_debugfs_write() for what could be expressed in a simple sprintf, as Rasmus pointed out. This drops the leading 0x for each byte, but is otherwise much nicer. Suggested-by: Rasmus Villemoes Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c index 69d7f6bff5d4..fc3ddd7aa6f0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c @@ -92,9 +92,7 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u struct drm_device *dev = adev_to_drm(adev); uint32_t phy_id; uint32_t op; - int i; char str[64]; - char i2c_output[256]; int ret; if (*pos || size > sizeof(str) - 1) @@ -136,12 +134,9 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u ret = psp_securedisplay_invoke(psp, TA_SECUREDISPLAY_COMMAND__SEND_ROI_CRC); if (!ret) { if (securedisplay_cmd->status == TA_SECUREDISPLAY_STATUS__SUCCESS) { - int pos = 0; - memset(i2c_output, 0, sizeof(i2c_output)); - for (i = 0; i < TA_SECUREDISPLAY_I2C_BUFFER_SIZE; i++) - pos += sprintf(i2c_output + pos, " 0x%X", - securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf[i]); - dev_info(adev->dev, "SECUREDISPLAY: I2C buffer out put is :%s\n", i2c_output); + dev_info(adev->dev, "SECUREDISPLAY: I2C buffer out put is: %*ph\n", + TA_SECUREDISPLAY_I2C_BUFFER_SIZE, + securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf); } else { psp_securedisplay_parse_resp_status(psp, securedisplay_cmd->status); } -- 2.29.2