Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp46512pxf; Tue, 6 Apr 2021 14:35:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLASdDHp9VQDNZCt1difmPzHR+L46/U2ef4hd88tSDPMA3pA6PPV6J0E8zsR+8BmxRORYF X-Received: by 2002:a05:6402:c1:: with SMTP id i1mr410242edu.315.1617744910622; Tue, 06 Apr 2021 14:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617744910; cv=none; d=google.com; s=arc-20160816; b=RboFy95jp7Cu/W3gH77ACjMtfw5zKpkpF2yWHUOo2TXv5Vih4mpPKZI67oI6H4CVpV wwXcGWYnzOo3GCOE/+4rzq0p44kfisqnxmqqBuWc3gBXQzq3GPw5nfgw87fNAmY9J2KX 31xYkd13QBJxmmMK8IyqFtywZGfzkAXIqHmk8tDTjV8iaN1VuMO2CapuuunbhQUZgLUM jsQRnU1UYvO58oCvFB6+2PDohvOK8t9f93noJ+CREkivpz+5OynR8zS0wpH9wt6NmBf0 y/bKL0FbTC28BpDMjIE6qlKEuUb12gtHWASfFtEmyDuR8LVc4HXZwK5j85pZxBq2jU7O qymA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=0PXrLzH+jQelOeixsXKlq8n/1TSzMSwjEX3Y1MHIdfo=; b=XqHxok4QC/az537fJgrujsi2aUyqMER8qXUQVg8ka7/aWcKB6YgdN3N6NtHi993TrP VoowWmof1bkWB7Su7+PKNYXUeJz6rZPogPETO4mtkvq+fWma17BTtZhRfoTMAUnbO3kg wF0OBLsttB2RCihcma+UEcqdq38gLUFzqpvRWER/eASSWhVYN6xt1tRAh4QmY3swxp8V YTQzR6dFgbmINiPJC5MyYAucScJjWK1RNHERP4SbWuqk/H0wlLmuqc7NIp1aVDsJqvIN 84FcPc6Pf8rDa96Mdo49Z5XXmhav2aZJ16MoEB7EkpSNZq2Gs7E/ODrqHLpndJVdrKyN gHNw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si6802037eje.57.2021.04.06.14.33.37; Tue, 06 Apr 2021 14:35:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241966AbhDFM0k (ORCPT + 99 others); Tue, 6 Apr 2021 08:26:40 -0400 Received: from mga12.intel.com ([192.55.52.136]:6874 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239328AbhDFM0g (ORCPT ); Tue, 6 Apr 2021 08:26:36 -0400 IronPort-SDR: DUhyKIkQAoFbXiRq/mhAjaxSh5pAqH0vN6YWWayzCHc49BKUb6KPdfIqMt3yQ5KoefTaN9vCvG HKJobspnk3BA== X-IronPort-AV: E=McAfee;i="6000,8403,9946"; a="172527356" X-IronPort-AV: E=Sophos;i="5.81,309,1610438400"; d="scan'208";a="172527356" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2021 05:26:27 -0700 IronPort-SDR: 8lKa5n8Ae2HzZHCFbou4Yvgz+CvYTNxLDETcl6LhmceLHj4saiIoum14LlgTHgQtWfX7shLQj2 wyS9WyPwUmoA== X-IronPort-AV: E=Sophos;i="5.81,309,1610438400"; d="scan'208";a="421195694" Received: from oowomilo-mobl2.ger.corp.intel.com (HELO localhost) ([10.249.33.55]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2021 05:26:23 -0700 From: Jani Nikula To: Carlis , joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Xuezhi Zhang Subject: Re: [PATCH] drm/i915/sysfs: convert snprintf to sysfs_emit In-Reply-To: <20210404084103.528211-1-llyz108@163.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20210404084103.528211-1-llyz108@163.com> Date: Tue, 06 Apr 2021 15:26:20 +0300 Message-ID: <87k0pflhub.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 04 Apr 2021, Carlis wrote: > From: Xuezhi Zhang > > Fix the following coccicheck warning: > drivers/gpu/drm/i915//i915_sysfs.c:266:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:285:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:276:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:335:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:390:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:465:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:107:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:75:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:83:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:91:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:99:8-16: > WARNING: use scnprintf or sprintf > drivers/gpu/drm/i915//i915_sysfs.c:326:8-16: > WARNING: use scnprintf or sprintf > > Signed-off-by: Xuezhi Zhang Thanks for the patch, pushed to drm-intel-next. BR, Jani. > --- > drivers/gpu/drm/i915/i915_sysfs.c | 30 ++++++++++++------------------ > 1 file changed, 12 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c > index 45d32ef42787..4c6b5d52b5ca 100644 > --- a/drivers/gpu/drm/i915/i915_sysfs.c > +++ b/drivers/gpu/drm/i915/i915_sysfs.c > @@ -72,7 +72,7 @@ show_rc6_mask(struct device *kdev, struct device_attribute *attr, char *buf) > if (HAS_RC6pp(dev_priv)) > mask |= BIT(2); > > - return snprintf(buf, PAGE_SIZE, "%x\n", mask); > + return sysfs_emit(buf, "%x\n", mask); > } > > static ssize_t > @@ -80,7 +80,7 @@ show_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) > { > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > u32 rc6_residency = calc_residency(dev_priv, GEN6_GT_GFX_RC6); > - return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); > + return sysfs_emit(buf, "%u\n", rc6_residency); > } > > static ssize_t > @@ -88,7 +88,7 @@ show_rc6p_ms(struct device *kdev, struct device_attribute *attr, char *buf) > { > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > u32 rc6p_residency = calc_residency(dev_priv, GEN6_GT_GFX_RC6p); > - return snprintf(buf, PAGE_SIZE, "%u\n", rc6p_residency); > + return sysfs_emit(buf, "%u\n", rc6p_residency); > } > > static ssize_t > @@ -96,7 +96,7 @@ show_rc6pp_ms(struct device *kdev, struct device_attribute *attr, char *buf) > { > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > u32 rc6pp_residency = calc_residency(dev_priv, GEN6_GT_GFX_RC6pp); > - return snprintf(buf, PAGE_SIZE, "%u\n", rc6pp_residency); > + return sysfs_emit(buf, "%u\n", rc6pp_residency); > } > > static ssize_t > @@ -104,7 +104,7 @@ show_media_rc6_ms(struct device *kdev, struct device_attribute *attr, char *buf) > { > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > u32 rc6_residency = calc_residency(dev_priv, VLV_GT_MEDIA_RC6); > - return snprintf(buf, PAGE_SIZE, "%u\n", rc6_residency); > + return sysfs_emit(buf, "%u\n", rc6_residency); > } > > static DEVICE_ATTR(rc6_enable, S_IRUGO, show_rc6_mask, NULL); > @@ -263,8 +263,7 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev, > struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); > struct intel_rps *rps = &i915->gt.rps; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - intel_rps_read_actual_frequency(rps)); > + return sysfs_emit(buf, "%d\n", intel_rps_read_actual_frequency(rps)); > } > > static ssize_t gt_cur_freq_mhz_show(struct device *kdev, > @@ -273,8 +272,7 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev, > struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); > struct intel_rps *rps = &i915->gt.rps; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - intel_gpu_freq(rps, rps->cur_freq)); > + return sysfs_emit(buf, "%d\n", intel_gpu_freq(rps, rps->cur_freq)); > } > > static ssize_t gt_boost_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) > @@ -282,8 +280,7 @@ static ssize_t gt_boost_freq_mhz_show(struct device *kdev, struct device_attribu > struct drm_i915_private *i915 = kdev_minor_to_i915(kdev); > struct intel_rps *rps = &i915->gt.rps; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - intel_gpu_freq(rps, rps->boost_freq)); > + return sysfs_emit(buf, "%d\n", intel_gpu_freq(rps, rps->boost_freq)); > } > > static ssize_t gt_boost_freq_mhz_store(struct device *kdev, > @@ -323,8 +320,7 @@ static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > struct intel_rps *rps = &dev_priv->gt.rps; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - intel_gpu_freq(rps, rps->efficient_freq)); > + return sysfs_emit(buf, "%d\n", intel_gpu_freq(rps, rps->efficient_freq)); > } > > static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) > @@ -332,8 +328,7 @@ static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > struct intel_rps *rps = &dev_priv->gt.rps; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - intel_gpu_freq(rps, rps->max_freq_softlimit)); > + return sysfs_emit(buf, "%d\n", intel_gpu_freq(rps, rps->max_freq_softlimit)); > } > > static ssize_t gt_max_freq_mhz_store(struct device *kdev, > @@ -387,8 +382,7 @@ static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute > struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); > struct intel_rps *rps = &dev_priv->gt.rps; > > - return snprintf(buf, PAGE_SIZE, "%d\n", > - intel_gpu_freq(rps, rps->min_freq_softlimit)); > + return sysfs_emit(buf, "%d\n", intel_gpu_freq(rps, rps->min_freq_softlimit)); > } > > static ssize_t gt_min_freq_mhz_store(struct device *kdev, > @@ -462,7 +456,7 @@ static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr > else > BUG(); > > - return snprintf(buf, PAGE_SIZE, "%d\n", val); > + return sysfs_emit(buf, "%d\n", val); > } > > static const struct attribute * const gen6_attrs[] = { -- Jani Nikula, Intel Open Source Graphics Center