Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3720267pxt; Tue, 10 Aug 2021 09:46:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGLCgjDqGGTH0Rco0J8TIZbo/hDARI14NTwC8xYCdT0Se/broW3Fp02gOYRazSV0uC398m X-Received: by 2002:a17:906:9515:: with SMTP id u21mr1028441ejx.120.1628613994523; Tue, 10 Aug 2021 09:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628613994; cv=none; d=google.com; s=arc-20160816; b=dsezUAEflHgWnpg8T9oYW5GvBk2IpgRPDpk41iEYhWkVGV7Pcgc+JiioPmCsxhpAiz 2GCPD7sHQYeDvAOwwdTg+wZ8FbNlNqs9UE0jF2zIsSaYwzz7RAByBfEHqisiZJRi6vRE Os3cunn7zzFXzDeI0+wA6Zs7crn7g8MF5PdattIaN0vcVNhXkM7OiJD1ZmIAXPY/JBTM Z270CjRjBygW2LTOCKVlfy8QF8sjpqHihGJy/9wWWuF6T/1FFv5U1EE7d+qr0hot1aw8 AqSCsM0GH3kbdYXHBQpewXv9L24EKV5e5esIRiCbCdFwCh2gWHKUAGG8K30hp2lY6RwD 3DWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=EfSkqEWB2iL7ol++AoUyQUkD1YwKKukEj+prXFTL7LU=; b=nXiWZcCeR33cKaEXKoV+u9tr920ahXmB4hN16EJ436taJam40xTkuLruKmIBOZfGNy /qo9zIbA6AU6EDsuod/N7t55xlM+NgvubNQSy0idz9AIig9+b0/GEx7wla+F+fDyTB9T INrOuKMk4+ngsJIey3liUNJYi/QaYw4mc7sZw0rb4c/KdwcH8ZCVJmRufSBYTGu0voZz 2zvHw3dbiekgc57jCG7NkwDDUOyfAaYOx6ct1tc6HFtlWE3lA3ll1Yk5o88onOScCAof 0WMi4YKoOG+O1XaBUw/gTJmmSumPwx0rw662FP7023zW+tGO8tZd663Mqf0qhNWq0VoL iB2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Epjrz5w; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si21496116edb.607.2021.08.10.09.46.07; Tue, 10 Aug 2021 09:46:34 -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=@linutronix.de header.s=2020 header.b=2Epjrz5w; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234155AbhHJQPN (ORCPT + 99 others); Tue, 10 Aug 2021 12:15:13 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:44526 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233697AbhHJQPD (ORCPT ); Tue, 10 Aug 2021 12:15:03 -0400 Date: Tue, 10 Aug 2021 16:14:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628612079; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EfSkqEWB2iL7ol++AoUyQUkD1YwKKukEj+prXFTL7LU=; b=2Epjrz5wqerpi1xBkIzxMvunjvCEmwYSrAHK93wk+gmwPL2xz3Ig+9RqCFczSpuaNU33El 8kurzUzdU+3G2uOn8rGkqyMngY3U+RxdlerSiUBV9lmyilvu0O6OZI5JwirvWhrMKJnIPP /BYRGy6xowLoYaB9XfLzqnQGk/Jy/5xQYiPkgqIZpwIbkzCLuwvPm/+PTg2UUS0gfXW64u 8hcKlV1n6xR0Z8Vl6KRkCJMkW839quMiI/TzoCwwyUBBKRtRh2ZDYGzcpwKxLrbTz4IWeU z9ZoK8c35Cep5B8ylV5MguCM2HbBfP07ykU0qJEeqt4jvgQO5T5M+RPFCr5UXA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628612079; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EfSkqEWB2iL7ol++AoUyQUkD1YwKKukEj+prXFTL7LU=; b=dx5Fx7mjKnRNtMO5yG4rIkcsKeqrq+m2yUATDGIOnObmWlXaq1DjqUGoVeUGqShudGBT2n TcVilGyz7463MGAA== From: "tip-bot2 for YueHaibing" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Use DEVICE_ATTR_*() macro Cc: YueHaibing , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210527141105.2312-1-yuehaibing@huawei.com> References: <20210527141105.2312-1-yuehaibing@huawei.com> MIME-Version: 1.0 Message-ID: <162861207895.395.8410422606147143430.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the smp/core branch of tip: Commit-ID: 1782dc87b2edcf3a6c350ead748a8941b5835975 Gitweb: https://git.kernel.org/tip/1782dc87b2edcf3a6c350ead748a8941b5835975 Author: YueHaibing AuthorDate: Thu, 27 May 2021 22:11:05 +08:00 Committer: Thomas Gleixner CommitterDate: Tue, 10 Aug 2021 18:11:12 +02:00 cpu/hotplug: Use DEVICE_ATTR_*() macro Use DEVICE_ATTR_*() helper instead of plain DEVICE_ATTR, which makes the code a bit shorter and easier to read. Signed-off-by: YueHaibing Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20210527141105.2312-1-yuehaibing@huawei.com --- kernel/cpu.c | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 62fb67e..7ef28e1 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2249,18 +2249,17 @@ int cpuhp_smt_enable(void) #endif #if defined(CONFIG_SYSFS) && defined(CONFIG_HOTPLUG_CPU) -static ssize_t show_cpuhp_state(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t state_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id); return sprintf(buf, "%d\n", st->state); } -static DEVICE_ATTR(state, 0444, show_cpuhp_state, NULL); +static DEVICE_ATTR_RO(state); -static ssize_t write_cpuhp_target(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t target_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id); struct cpuhp_step *sp; @@ -2298,19 +2297,17 @@ out: return ret ? ret : count; } -static ssize_t show_cpuhp_target(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t target_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id); return sprintf(buf, "%d\n", st->target); } -static DEVICE_ATTR(target, 0644, show_cpuhp_target, write_cpuhp_target); - +static DEVICE_ATTR_RW(target); -static ssize_t write_cpuhp_fail(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t fail_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id); struct cpuhp_step *sp; @@ -2359,15 +2356,15 @@ static ssize_t write_cpuhp_fail(struct device *dev, return count; } -static ssize_t show_cpuhp_fail(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t fail_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, dev->id); return sprintf(buf, "%d\n", st->fail); } -static DEVICE_ATTR(fail, 0644, show_cpuhp_fail, write_cpuhp_fail); +static DEVICE_ATTR_RW(fail); static struct attribute *cpuhp_cpu_attrs[] = { &dev_attr_state.attr, @@ -2382,7 +2379,7 @@ static const struct attribute_group cpuhp_cpu_attr_group = { NULL }; -static ssize_t show_cpuhp_states(struct device *dev, +static ssize_t states_show(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t cur, res = 0; @@ -2401,7 +2398,7 @@ static ssize_t show_cpuhp_states(struct device *dev, mutex_unlock(&cpuhp_state_mutex); return res; } -static DEVICE_ATTR(states, 0444, show_cpuhp_states, NULL); +static DEVICE_ATTR_RO(states); static struct attribute *cpuhp_cpu_root_attrs[] = { &dev_attr_states.attr, @@ -2474,28 +2471,27 @@ static const char *smt_states[] = { [CPU_SMT_NOT_IMPLEMENTED] = "notimplemented", }; -static ssize_t -show_smt_control(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t control_show(struct device *dev, + struct device_attribute *attr, char *buf) { const char *state = smt_states[cpu_smt_control]; return snprintf(buf, PAGE_SIZE - 2, "%s\n", state); } -static ssize_t -store_smt_control(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t control_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { return __store_smt_control(dev, attr, buf, count); } -static DEVICE_ATTR(control, 0644, show_smt_control, store_smt_control); +static DEVICE_ATTR_RW(control); -static ssize_t -show_smt_active(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t active_show(struct device *dev, + struct device_attribute *attr, char *buf) { return snprintf(buf, PAGE_SIZE - 2, "%d\n", sched_smt_active()); } -static DEVICE_ATTR(active, 0444, show_smt_active, NULL); +static DEVICE_ATTR_RO(active); static struct attribute *cpuhp_smt_attrs[] = { &dev_attr_control.attr,