Skip to content

Commit 85750bc

Browse files
zhanglianjie-163rafaeljw
authored andcommitted
cpufreq: unify show() and store() naming and use __ATTR_XX
Usually, sysfs attributes have .show and .store and their naming convention is filename_show() and filename_store(). But in cpufreq the naming convention of these functions is show_filename() and store_filename() which prevents __ATTR_RW() and __ATTR_RO() from being used in there to simplify code. Accordingly, change the naming convention of the sysfs .show and .store methods in cpufreq to follow the one expected by __ATTR_RW() and __ATTR_RO() and use these macros in that code. Signed-off-by: Lianjie Zhang <zhanglianjie@uniontech.com> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 075c3c4 commit 85750bc

4 files changed

Lines changed: 18 additions & 20 deletions

File tree

drivers/cpufreq/cpufreq_conservative.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
146146

147147
/************************** sysfs interface ************************/
148148

149-
static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set,
149+
static ssize_t sampling_down_factor_store(struct gov_attr_set *attr_set,
150150
const char *buf, size_t count)
151151
{
152152
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,
161161
return count;
162162
}
163163

164-
static ssize_t store_up_threshold(struct gov_attr_set *attr_set,
164+
static ssize_t up_threshold_store(struct gov_attr_set *attr_set,
165165
const char *buf, size_t count)
166166
{
167167
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,
177177
return count;
178178
}
179179

180-
static ssize_t store_down_threshold(struct gov_attr_set *attr_set,
180+
static ssize_t down_threshold_store(struct gov_attr_set *attr_set,
181181
const char *buf, size_t count)
182182
{
183183
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,
195195
return count;
196196
}
197197

198-
static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set,
198+
static ssize_t ignore_nice_load_store(struct gov_attr_set *attr_set,
199199
const char *buf, size_t count)
200200
{
201201
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,
220220
return count;
221221
}
222222

223-
static ssize_t store_freq_step(struct gov_attr_set *attr_set, const char *buf,
223+
static ssize_t freq_step_store(struct gov_attr_set *attr_set, const char *buf,
224224
size_t count)
225225
{
226226
struct dbs_data *dbs_data = to_dbs_data(attr_set);

drivers/cpufreq/cpufreq_governor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static DEFINE_MUTEX(gov_dbs_data_mutex);
2727

2828
/* Common sysfs tunables */
2929
/*
30-
* store_sampling_rate - update sampling rate effective immediately if needed.
30+
* sampling_rate_store - update sampling rate effective immediately if needed.
3131
*
3232
* If new rate is smaller than the old, simply updating
3333
* dbs.sampling_rate might not be appropriate. For example, if the
@@ -41,7 +41,7 @@ static DEFINE_MUTEX(gov_dbs_data_mutex);
4141
* This must be called with dbs_data->mutex held, otherwise traversing
4242
* policy_dbs_list isn't safe.
4343
*/
44-
ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf,
44+
ssize_t sampling_rate_store(struct gov_attr_set *attr_set, const char *buf,
4545
size_t count)
4646
{
4747
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,
8080

8181
return count;
8282
}
83-
EXPORT_SYMBOL_GPL(store_sampling_rate);
83+
EXPORT_SYMBOL_GPL(sampling_rate_store);
8484

8585
/**
8686
* gov_update_cpu_data - Update CPU load data.

drivers/cpufreq/cpufreq_governor.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static inline struct dbs_data *to_dbs_data(struct gov_attr_set *attr_set)
5151
}
5252

5353
#define gov_show_one(_gov, file_name) \
54-
static ssize_t show_##file_name \
54+
static ssize_t file_name##_show \
5555
(struct gov_attr_set *attr_set, char *buf) \
5656
{ \
5757
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
@@ -60,20 +60,18 @@ static ssize_t show_##file_name \
6060
}
6161

6262
#define gov_show_one_common(file_name) \
63-
static ssize_t show_##file_name \
63+
static ssize_t file_name##_show \
6464
(struct gov_attr_set *attr_set, char *buf) \
6565
{ \
6666
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
6767
return sprintf(buf, "%u\n", dbs_data->file_name); \
6868
}
6969

7070
#define gov_attr_ro(_name) \
71-
static struct governor_attr _name = \
72-
__ATTR(_name, 0444, show_##_name, NULL)
71+
static struct governor_attr _name = __ATTR_RO(_name)
7372

7473
#define gov_attr_rw(_name) \
75-
static struct governor_attr _name = \
76-
__ATTR(_name, 0644, show_##_name, store_##_name)
74+
static struct governor_attr _name = __ATTR_RW(_name)
7775

7876
/* Common to all CPUs of a policy */
7977
struct policy_dbs_info {
@@ -176,7 +174,7 @@ void od_register_powersave_bias_handler(unsigned int (*f)
176174
(struct cpufreq_policy *, unsigned int, unsigned int),
177175
unsigned int powersave_bias);
178176
void od_unregister_powersave_bias_handler(void);
179-
ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf,
177+
ssize_t sampling_rate_store(struct gov_attr_set *attr_set, const char *buf,
180178
size_t count);
181179
void gov_update_cpu_data(struct dbs_data *dbs_data);
182180
#endif /* _CPUFREQ_GOVERNOR_H */

drivers/cpufreq/cpufreq_ondemand.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static unsigned int od_dbs_update(struct cpufreq_policy *policy)
202202
/************************** sysfs interface ************************/
203203
static struct dbs_governor od_dbs_gov;
204204

205-
static ssize_t store_io_is_busy(struct gov_attr_set *attr_set, const char *buf,
205+
static ssize_t io_is_busy_store(struct gov_attr_set *attr_set, const char *buf,
206206
size_t count)
207207
{
208208
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,
220220
return count;
221221
}
222222

223-
static ssize_t store_up_threshold(struct gov_attr_set *attr_set,
223+
static ssize_t up_threshold_store(struct gov_attr_set *attr_set,
224224
const char *buf, size_t count)
225225
{
226226
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,
237237
return count;
238238
}
239239

240-
static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set,
240+
static ssize_t sampling_down_factor_store(struct gov_attr_set *attr_set,
241241
const char *buf, size_t count)
242242
{
243243
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,
265265
return count;
266266
}
267267

268-
static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set,
268+
static ssize_t ignore_nice_load_store(struct gov_attr_set *attr_set,
269269
const char *buf, size_t count)
270270
{
271271
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,
290290
return count;
291291
}
292292

293-
static ssize_t store_powersave_bias(struct gov_attr_set *attr_set,
293+
static ssize_t powersave_bias_store(struct gov_attr_set *attr_set,
294294
const char *buf, size_t count)
295295
{
296296
struct dbs_data *dbs_data = to_dbs_data(attr_set);

0 commit comments

Comments
 (0)