From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750814AbdEARLh (ORCPT ); Mon, 1 May 2017 13:11:37 -0400 Received: from smtprelay0006.hostedemail.com ([216.40.44.6]:47136 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750736AbdEARLe (ORCPT ); Mon, 1 May 2017 13:11:34 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1042:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1963:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3872:3873:4321:5007:6119:6691:7576:7903:8603:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12048:12114:12294:12296:12438:12740:12895:13069:13161:13229:13311:13357:13439:13894:14659:14721:21080:21433:21451:30012:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: chain74_6428e972e2b5a X-Filterd-Recvd-Size: 2755 Message-ID: <1493658687.6621.3.camel@perches.com> Subject: Re: [PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology() From: Joe Perches To: SF Markus Elfring , dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Jani Nikula , Sean Paul Cc: LKML , kernel-janitors@vger.kernel.org Date: Mon, 01 May 2017 10:11:27 -0700 In-Reply-To: References: <1949e36b-5039-a7b6-5774-6ada7eb05ea6@users.sourceforge.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-05-01 at 18:46 +0200, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 1 May 2017 17:08:56 +0200 > > A few single characters (line breaks) should be put into a sequence. > Thus use the corresponding function "seq_putc". > > This issue was detected by using the Coccinelle software. [] > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c [] > @@ -2840,17 +2840,17 @@ void drm_dp_mst_dump_topology(struct seq_file *m, > seq_printf(m, "dpcd: "); > for (i = 0; i < DP_RECEIVER_CAP_SIZE; i++) > seq_printf(m, "%02x ", buf[i]); > - seq_printf(m, "\n"); > + seq_putc(m, '\n'); > ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2); > seq_printf(m, "faux/mst: "); > for (i = 0; i < 2; i++) > seq_printf(m, "%02x ", buf[i]); > - seq_printf(m, "\n"); > + seq_putc(m, '\n'); > ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1); > seq_printf(m, "mst ctrl: "); > for (i = 0; i < 1; i++) > seq_printf(m, "%02x ", buf[i]); > - seq_printf(m, "\n"); > + seq_putc(m, '\n'); Please don't be _just_ mechanical. Stop and read the code the tools you use using suggest modifying and see how you can improve it for a human reader. If you're really trying to improve these to make them more readable or smaller object code size, you should use the vsprintf extensions like: seq_printf(m, "dpcd: %*ph\n", DP_RECEIVER_CAP_SIZE, buf); And if these are supposed to be correct, then the return value from drm_dp_dpcd_read should be tested too. Likely these repeated code blocks could be put into a helper function.