Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1956203pxp; Thu, 10 Mar 2022 16:01:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx06ryUZF+clyUbjqjbctzc5XvLtEn+yfPfoltkc01DoLZjIreMJzgvOSLpxxPNnHpMD+Pd X-Received: by 2002:a17:902:bf4a:b0:151:7d37:2943 with SMTP id u10-20020a170902bf4a00b001517d372943mr7472971pls.131.1646956899900; Thu, 10 Mar 2022 16:01:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646956899; cv=none; d=google.com; s=arc-20160816; b=EywOwFaeunq8k2auT86DG/GNdei4Msd7sXicTpo0RyJ1EEwMckvQGTRAd483ih798a iaa46RGP9Gse+StKrJYq/Xfe1NROYOI8xaHCgikTNXYu653hDKcoE1G+hXz701O0A6AC pIlYbXiJ7vxjE7QALFBpdByrjV6GICkUd4XxhYD0RGfeZq9GmncHKDZEYi+mfHu2yKaX zT4lqROP6OMk72Nnh3hyogJGbsd8KGM1Lsm+Xkj8PU8yDD+GZui7vXUY1eXA6Q8lx9Vl 1ajqNDDymCSHKg4hs1S4tzirG9gQmQ01vW4TTN+8Aqf9lhHrdAoljcRgwPORAWHlwyxn 3CJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=JbZwW4Q33oM0K6Ehmd6ut1YN/0anOjxbXg3ljY5Q01s=; b=qHQu1J1YlyKNxevFwX/W5KJbMNyeNGlqe2xn8sbtfT7b9oFfobZAPMiC6sCjKKGvWx dQVEZG9c86punO5DaLpxWqkM2Zm5XBQpnoJE6MapS3tHIG3MVjIOz7+WNmbGWXOHMZpc 9yy7iLbyC7wt9uV24ySbcpTJaNMfDGT/AmiB3XyGOu0HrO3sNes57hrbVxCYQYVB9+Ad VxkP0TR7lGuCfa6d3rUdZbgKK1MxUDQ6rgGWsIvzGywZp8VANvwWw5U0vnb/pq402kFE 8IVzrd715tGjT5jg0DNYvLG77t/r4aFBDSvtStY9X4P8GE/8OX2Zmk7/sZ3uU0qyxb6S Xqaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bi12-20020a170902bf0c00b0014fd360c0e8si5865516plb.372.2022.03.10.16.01.23; Thu, 10 Mar 2022 16:01:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S245686AbiCJS74 (ORCPT + 99 others); Thu, 10 Mar 2022 13:59:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234025AbiCJS7x (ORCPT ); Thu, 10 Mar 2022 13:59:53 -0500 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498873DA5F; Thu, 10 Mar 2022 10:58:49 -0800 (PST) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-2dc0364d2ceso69002217b3.7; Thu, 10 Mar 2022 10:58:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JbZwW4Q33oM0K6Ehmd6ut1YN/0anOjxbXg3ljY5Q01s=; b=fR/7p+0xwUdh9MqSD9Y5pKtzk7fpnyw2tEshfgrEB2Voo6PvuXYKb23VQrvXqIAPHK /MgsrCKSfDAkmCqh6t2R42+SSS5RLgfd+ToqOzRme2NWuevp9H5lZD4FZTntpcRh9ztC xou173jrFPDIwyW3/H8PZjV5CASlyj6XkEBWTLQpYwdYld0tnqpN/SXLs0uaeclxFKlB PO9md5A3xOHznkwGkdaT5lIOvFprz7V5webtYKSOWhnHZY54qg5V866TtOkYowdq6Af0 k5/IQtEWAmHky0fF53OaNHjwEe4uKvMvng0rqtRC8HwBFcr4tkz9T9+g5nWgCPdGSeGl SROA== X-Gm-Message-State: AOAM532GiLhKM2rXghuS5dWtso4NijZAGtgqtRHMkSxzZ67bHjIT2mup ZKgpXAiicaYybir5It0GkSfF/lNmry5SNNX2e7w= X-Received: by 2002:a81:f008:0:b0:2d0:cd72:74e5 with SMTP id p8-20020a81f008000000b002d0cd7274e5mr5331536ywm.301.1646938728285; Thu, 10 Mar 2022 10:58:48 -0800 (PST) MIME-Version: 1.0 References: <20220310143830.4677-1-zhanglianjie@uniontech.com> In-Reply-To: <20220310143830.4677-1-zhanglianjie@uniontech.com> From: "Rafael J. Wysocki" Date: Thu, 10 Mar 2022 19:58:37 +0100 Message-ID: Subject: Re: [PATCH v3] cpufreq: unify the show() and store() styles of attr and use __ATTR_XX macro To: Lianjie Zhang Cc: "Rafael J . Wysocki" , Viresh Kumar , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 10, 2022 at 3:38 PM Lianjie Zhang wrote: > > Usually /sys directory under the file, the corresponding Attribute > contains .show and .store, and their naming style is filename_show() and > filename_store(). But all naming style in 'cpufreq' is show_filename() > and store_filename(), resulting in __ATTR_RW() and __ATTR_RO() macros > cannot be used to simplify code, So need to change naming style. > Use helper macro __ATTR_XX to make code more clear. > > Signed-off-by: Lianjie Zhang > > diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c > index 08515f7e515f..b6bd0ff35323 100644 > --- a/drivers/cpufreq/cpufreq_conservative.c > +++ b/drivers/cpufreq/cpufreq_conservative.c > @@ -146,7 +146,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > > /************************** sysfs interface ************************/ > > -static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, > +static ssize_t sampling_down_factor_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -161,7 +161,7 @@ static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_up_threshold(struct gov_attr_set *attr_set, > +static ssize_t up_threshold_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -177,7 +177,7 @@ static ssize_t store_up_threshold(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_down_threshold(struct gov_attr_set *attr_set, > +static ssize_t down_threshold_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -195,7 +195,7 @@ static ssize_t store_down_threshold(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set, > +static ssize_t ignore_nice_load_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -220,7 +220,7 @@ static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_freq_step(struct gov_attr_set *attr_set, const char *buf, > +static ssize_t freq_step_store(struct gov_attr_set *attr_set, const char *buf, > size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c > index 63f7c219062b..0d42cf8b88d8 100644 > --- a/drivers/cpufreq/cpufreq_governor.c > +++ b/drivers/cpufreq/cpufreq_governor.c > @@ -27,7 +27,7 @@ static DEFINE_MUTEX(gov_dbs_data_mutex); > > /* Common sysfs tunables */ > /* > - * store_sampling_rate - update sampling rate effective immediately if needed. > + * sampling_rate_store - update sampling rate effective immediately if needed. > * > * If new rate is smaller than the old, simply updating > * dbs.sampling_rate might not be appropriate. For example, if the > @@ -41,7 +41,7 @@ static DEFINE_MUTEX(gov_dbs_data_mutex); > * This must be called with dbs_data->mutex held, otherwise traversing > * policy_dbs_list isn't safe. > */ > -ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf, > +ssize_t sampling_rate_store(struct gov_attr_set *attr_set, const char *buf, > size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -80,7 +80,7 @@ ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf, > > return count; > } > -EXPORT_SYMBOL_GPL(store_sampling_rate); > +EXPORT_SYMBOL_GPL(sampling_rate_store); > > /** > * gov_update_cpu_data - Update CPU load data. > diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h > index bab8e6140377..a5a0bc3cc23e 100644 > --- a/drivers/cpufreq/cpufreq_governor.h > +++ b/drivers/cpufreq/cpufreq_governor.h > @@ -51,7 +51,7 @@ static inline struct dbs_data *to_dbs_data(struct gov_attr_set *attr_set) > } > > #define gov_show_one(_gov, file_name) \ > -static ssize_t show_##file_name \ > +static ssize_t file_name##_show \ > (struct gov_attr_set *attr_set, char *buf) \ > { \ > struct dbs_data *dbs_data = to_dbs_data(attr_set); \ > @@ -60,7 +60,7 @@ static ssize_t show_##file_name \ > } > > #define gov_show_one_common(file_name) \ > -static ssize_t show_##file_name \ > +static ssize_t file_name##_show \ > (struct gov_attr_set *attr_set, char *buf) \ > { \ > struct dbs_data *dbs_data = to_dbs_data(attr_set); \ > @@ -68,12 +68,10 @@ static ssize_t show_##file_name \ > } > > #define gov_attr_ro(_name) \ > -static struct governor_attr _name = \ > -__ATTR(_name, 0444, show_##_name, NULL) > +static struct governor_attr _name = __ATTR_RO(_name) > > #define gov_attr_rw(_name) \ > -static struct governor_attr _name = \ > -__ATTR(_name, 0644, show_##_name, store_##_name) > +static struct governor_attr _name = __ATTR_RW(_name) > > /* Common to all CPUs of a policy */ > struct policy_dbs_info { > @@ -176,7 +174,7 @@ void od_register_powersave_bias_handler(unsigned int (*f) > (struct cpufreq_policy *, unsigned int, unsigned int), > unsigned int powersave_bias); > void od_unregister_powersave_bias_handler(void); > -ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf, > +ssize_t sampling_rate_store(struct gov_attr_set *attr_set, const char *buf, > size_t count); > void gov_update_cpu_data(struct dbs_data *dbs_data); > #endif /* _CPUFREQ_GOVERNOR_H */ > diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c > index 6a41ea4729b8..e8fbf970ff07 100644 > --- a/drivers/cpufreq/cpufreq_ondemand.c > +++ b/drivers/cpufreq/cpufreq_ondemand.c > @@ -202,7 +202,7 @@ static unsigned int od_dbs_update(struct cpufreq_policy *policy) > /************************** sysfs interface ************************/ > static struct dbs_governor od_dbs_gov; > > -static ssize_t store_io_is_busy(struct gov_attr_set *attr_set, const char *buf, > +static ssize_t io_is_busy_store(struct gov_attr_set *attr_set, const char *buf, > size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -220,7 +220,7 @@ static ssize_t store_io_is_busy(struct gov_attr_set *attr_set, const char *buf, > return count; > } > > -static ssize_t store_up_threshold(struct gov_attr_set *attr_set, > +static ssize_t up_threshold_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -237,7 +237,7 @@ static ssize_t store_up_threshold(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, > +static ssize_t sampling_down_factor_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -265,7 +265,7 @@ static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set, > +static ssize_t ignore_nice_load_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > @@ -290,7 +290,7 @@ static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set, > return count; > } > > -static ssize_t store_powersave_bias(struct gov_attr_set *attr_set, > +static ssize_t powersave_bias_store(struct gov_attr_set *attr_set, > const char *buf, size_t count) > { > struct dbs_data *dbs_data = to_dbs_data(attr_set); > -- Applied as 5.18 material with some edits in the subject and changelog. Thanks!