* [PATCH 1/3] clocksource: Skip to check the override clocksource if override name is empty
@ 2018-01-17 6:01 Baolin Wang
2018-01-17 6:01 ` [PATCH 2/3] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes Baolin Wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Baolin Wang @ 2018-01-17 6:01 UTC (permalink / raw)
To: john.stultz, tglx, sboyd; +Cc: broonie, arnd, baolin.wang, linux-kernel
Some platforms will not set the override clocksource name to select, so we
can skip to check the override clocksource when selecting one clocksource.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
kernel/time/clocksource.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 65f9e3f..c5fdcb1 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -594,6 +594,9 @@ static void __clocksource_select(bool skipcur)
if (!best)
return;
+ if (!strlen(override_name))
+ goto found;
+
/* Check for the override clocksource. */
list_for_each_entry(cs, &clocksource_list, list) {
if (skipcur && cs == curr_clocksource)
@@ -625,6 +628,7 @@ static void __clocksource_select(bool skipcur)
break;
}
+found:
if (curr_clocksource != best && !timekeeping_notify(best)) {
pr_info("Switched to clocksource %s\n", best->name);
curr_clocksource = best;
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/3] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes 2018-01-17 6:01 [PATCH 1/3] clocksource: Skip to check the override clocksource if override name is empty Baolin Wang @ 2018-01-17 6:01 ` Baolin Wang 2018-02-28 13:10 ` [tip:timers/core] " tip-bot for Baolin Wang 2018-01-17 6:01 ` [PATCH 3/3] clocksource: Use ATTRIBUTE_GROUPS macro Baolin Wang 2018-02-28 13:09 ` [tip:timers/core] clocksource: Don't walk the clocksource list for empty override tip-bot for Baolin Wang 2 siblings, 1 reply; 6+ messages in thread From: Baolin Wang @ 2018-01-17 6:01 UTC (permalink / raw) To: john.stultz, tglx, sboyd; +Cc: broonie, arnd, baolin.wang, linux-kernel Convert DEVICE_ATTR to DEVICE_ATTR_RW/RO/WO to make attributes' definition more clear. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> --- kernel/time/clocksource.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index c5fdcb1..7ce5346 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -857,16 +857,16 @@ int clocksource_unregister(struct clocksource *cs) #ifdef CONFIG_SYSFS /** - * sysfs_show_current_clocksources - sysfs interface for current clocksource + * current_clocksource_show - sysfs interface for current clocksource * @dev: unused * @attr: unused * @buf: char buffer to be filled with clocksource list * * Provides sysfs interface for listing current clocksource. */ -static ssize_t -sysfs_show_current_clocksources(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t current_clocksource_show(struct device *dev, + struct device_attribute *attr, + char *buf) { ssize_t count = 0; @@ -895,7 +895,7 @@ ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt) } /** - * sysfs_override_clocksource - interface for manually overriding clocksource + * current_clocksource_store - interface for manually overriding clocksource * @dev: unused * @attr: unused * @buf: name of override clocksource @@ -904,9 +904,9 @@ ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt) * Takes input from sysfs interface for manually overriding the default * clocksource selection. */ -static ssize_t sysfs_override_clocksource(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t current_clocksource_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { ssize_t ret; @@ -920,9 +920,10 @@ static ssize_t sysfs_override_clocksource(struct device *dev, return ret; } +static DEVICE_ATTR_RW(current_clocksource); /** - * sysfs_unbind_current_clocksource - interface for manually unbinding clocksource + * unbind_clocksource_store - interface for manually unbinding clocksource * @dev: unused * @attr: unused * @buf: unused @@ -930,7 +931,7 @@ static ssize_t sysfs_override_clocksource(struct device *dev, * * Takes input from sysfs interface for manually unbinding a clocksource. */ -static ssize_t sysfs_unbind_clocksource(struct device *dev, +static ssize_t unbind_clocksource_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -954,19 +955,19 @@ static ssize_t sysfs_unbind_clocksource(struct device *dev, return ret ? ret : count; } +static DEVICE_ATTR_WO(unbind_clocksource); /** - * sysfs_show_available_clocksources - sysfs interface for listing clocksource + * available_clocksource_show - sysfs interface for listing clocksource * @dev: unused * @attr: unused * @buf: char buffer to be filled with clocksource list * * Provides sysfs interface for listing registered clocksources */ -static ssize_t -sysfs_show_available_clocksources(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t available_clocksource_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct clocksource *src; ssize_t count = 0; @@ -990,17 +991,7 @@ static ssize_t sysfs_unbind_clocksource(struct device *dev, return count; } - -/* - * Sysfs setup bits: - */ -static DEVICE_ATTR(current_clocksource, 0644, sysfs_show_current_clocksources, - sysfs_override_clocksource); - -static DEVICE_ATTR(unbind_clocksource, 0200, NULL, sysfs_unbind_clocksource); - -static DEVICE_ATTR(available_clocksource, 0444, - sysfs_show_available_clocksources, NULL); +static DEVICE_ATTR_RO(available_clocksource); static struct bus_type clocksource_subsys = { .name = "clocksource", -- 1.7.9.5 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:timers/core] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes 2018-01-17 6:01 ` [PATCH 2/3] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes Baolin Wang @ 2018-02-28 13:10 ` tip-bot for Baolin Wang 0 siblings, 0 replies; 6+ messages in thread From: tip-bot for Baolin Wang @ 2018-02-28 13:10 UTC (permalink / raw) To: linux-tip-commits; +Cc: baolin.wang, mingo, hpa, linux-kernel, tglx Commit-ID: e87821d18cf4db19d634a04061c0a1b7eb9c0e65 Gitweb: https://git.kernel.org/tip/e87821d18cf4db19d634a04061c0a1b7eb9c0e65 Author: Baolin Wang <baolin.wang@linaro.org> AuthorDate: Wed, 17 Jan 2018 14:01:29 +0800 Committer: Thomas Gleixner <tglx@linutronix.de> CommitDate: Wed, 28 Feb 2018 14:04:52 +0100 clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes Convert DEVICE_ATTR to DEVICE_ATTR_RW/RO/WO which is the preferred and simpler way of implementation. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: arnd@arndb.de Cc: sboyd@codeaurora.org Cc: broonie@kernel.org Cc: john.stultz@linaro.org Link: https://lkml.kernel.org/r/8f35c77e753e957b61187e8e7b2e4a3d61e4a72b.1516167691.git.baolin.wang@linaro.org --- kernel/time/clocksource.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index c5fdcb13200f..7ce53465782b 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -857,16 +857,16 @@ EXPORT_SYMBOL(clocksource_unregister); #ifdef CONFIG_SYSFS /** - * sysfs_show_current_clocksources - sysfs interface for current clocksource + * current_clocksource_show - sysfs interface for current clocksource * @dev: unused * @attr: unused * @buf: char buffer to be filled with clocksource list * * Provides sysfs interface for listing current clocksource. */ -static ssize_t -sysfs_show_current_clocksources(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t current_clocksource_show(struct device *dev, + struct device_attribute *attr, + char *buf) { ssize_t count = 0; @@ -895,7 +895,7 @@ ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt) } /** - * sysfs_override_clocksource - interface for manually overriding clocksource + * current_clocksource_store - interface for manually overriding clocksource * @dev: unused * @attr: unused * @buf: name of override clocksource @@ -904,9 +904,9 @@ ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt) * Takes input from sysfs interface for manually overriding the default * clocksource selection. */ -static ssize_t sysfs_override_clocksource(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t current_clocksource_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { ssize_t ret; @@ -920,9 +920,10 @@ static ssize_t sysfs_override_clocksource(struct device *dev, return ret; } +static DEVICE_ATTR_RW(current_clocksource); /** - * sysfs_unbind_current_clocksource - interface for manually unbinding clocksource + * unbind_clocksource_store - interface for manually unbinding clocksource * @dev: unused * @attr: unused * @buf: unused @@ -930,7 +931,7 @@ static ssize_t sysfs_override_clocksource(struct device *dev, * * Takes input from sysfs interface for manually unbinding a clocksource. */ -static ssize_t sysfs_unbind_clocksource(struct device *dev, +static ssize_t unbind_clocksource_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -954,19 +955,19 @@ static ssize_t sysfs_unbind_clocksource(struct device *dev, return ret ? ret : count; } +static DEVICE_ATTR_WO(unbind_clocksource); /** - * sysfs_show_available_clocksources - sysfs interface for listing clocksource + * available_clocksource_show - sysfs interface for listing clocksource * @dev: unused * @attr: unused * @buf: char buffer to be filled with clocksource list * * Provides sysfs interface for listing registered clocksources */ -static ssize_t -sysfs_show_available_clocksources(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t available_clocksource_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct clocksource *src; ssize_t count = 0; @@ -990,17 +991,7 @@ sysfs_show_available_clocksources(struct device *dev, return count; } - -/* - * Sysfs setup bits: - */ -static DEVICE_ATTR(current_clocksource, 0644, sysfs_show_current_clocksources, - sysfs_override_clocksource); - -static DEVICE_ATTR(unbind_clocksource, 0200, NULL, sysfs_unbind_clocksource); - -static DEVICE_ATTR(available_clocksource, 0444, - sysfs_show_available_clocksources, NULL); +static DEVICE_ATTR_RO(available_clocksource); static struct bus_type clocksource_subsys = { .name = "clocksource", ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] clocksource: Use ATTRIBUTE_GROUPS macro 2018-01-17 6:01 [PATCH 1/3] clocksource: Skip to check the override clocksource if override name is empty Baolin Wang 2018-01-17 6:01 ` [PATCH 2/3] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes Baolin Wang @ 2018-01-17 6:01 ` Baolin Wang 2018-02-28 13:10 ` [tip:timers/core] clocksource: Use ATTRIBUTE_GROUPS tip-bot for Baolin Wang 2018-02-28 13:09 ` [tip:timers/core] clocksource: Don't walk the clocksource list for empty override tip-bot for Baolin Wang 2 siblings, 1 reply; 6+ messages in thread From: Baolin Wang @ 2018-01-17 6:01 UTC (permalink / raw) To: john.stultz, tglx, sboyd; +Cc: broonie, arnd, baolin.wang, linux-kernel Convert to use ATTRIBUTE_GROUPS to define one attribute group pointed by 'groups' of the device, which can avoid issuing device_create_file() many times. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> --- kernel/time/clocksource.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 7ce5346..0e974cf 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -993,6 +993,14 @@ static ssize_t available_clocksource_show(struct device *dev, } static DEVICE_ATTR_RO(available_clocksource); +static struct attribute *clocksource_attrs[] = { + &dev_attr_current_clocksource.attr, + &dev_attr_unbind_clocksource.attr, + &dev_attr_available_clocksource.attr, + NULL +}; +ATTRIBUTE_GROUPS(clocksource); + static struct bus_type clocksource_subsys = { .name = "clocksource", .dev_name = "clocksource", @@ -1001,6 +1009,7 @@ static ssize_t available_clocksource_show(struct device *dev, static struct device device_clocksource = { .id = 0, .bus = &clocksource_subsys, + .groups = clocksource_groups, }; static int __init init_clocksource_sysfs(void) @@ -1009,17 +1018,7 @@ static int __init init_clocksource_sysfs(void) if (!error) error = device_register(&device_clocksource); - if (!error) - error = device_create_file( - &device_clocksource, - &dev_attr_current_clocksource); - if (!error) - error = device_create_file(&device_clocksource, - &dev_attr_unbind_clocksource); - if (!error) - error = device_create_file( - &device_clocksource, - &dev_attr_available_clocksource); + return error; } -- 1.7.9.5 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:timers/core] clocksource: Use ATTRIBUTE_GROUPS 2018-01-17 6:01 ` [PATCH 3/3] clocksource: Use ATTRIBUTE_GROUPS macro Baolin Wang @ 2018-02-28 13:10 ` tip-bot for Baolin Wang 0 siblings, 0 replies; 6+ messages in thread From: tip-bot for Baolin Wang @ 2018-02-28 13:10 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, baolin.wang, hpa, mingo, tglx Commit-ID: 27263e8dc0f6fe27540a843611ec14a000591c41 Gitweb: https://git.kernel.org/tip/27263e8dc0f6fe27540a843611ec14a000591c41 Author: Baolin Wang <baolin.wang@linaro.org> AuthorDate: Wed, 17 Jan 2018 14:01:30 +0800 Committer: Thomas Gleixner <tglx@linutronix.de> CommitDate: Wed, 28 Feb 2018 14:05:07 +0100 clocksource: Use ATTRIBUTE_GROUPS Use ATTRIBUTE_GROUPS instead of manually creating the individual device files. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: arnd@arndb.de Cc: sboyd@codeaurora.org Cc: broonie@kernel.org Cc: john.stultz@linaro.org Link: https://lkml.kernel.org/r/d80dccb981dc2461781ebb8d71a32ccdc1b0e6f9.1516167691.git.baolin.wang@linaro.org --- kernel/time/clocksource.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 7ce53465782b..0e974cface0b 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -993,6 +993,14 @@ static ssize_t available_clocksource_show(struct device *dev, } static DEVICE_ATTR_RO(available_clocksource); +static struct attribute *clocksource_attrs[] = { + &dev_attr_current_clocksource.attr, + &dev_attr_unbind_clocksource.attr, + &dev_attr_available_clocksource.attr, + NULL +}; +ATTRIBUTE_GROUPS(clocksource); + static struct bus_type clocksource_subsys = { .name = "clocksource", .dev_name = "clocksource", @@ -1001,6 +1009,7 @@ static struct bus_type clocksource_subsys = { static struct device device_clocksource = { .id = 0, .bus = &clocksource_subsys, + .groups = clocksource_groups, }; static int __init init_clocksource_sysfs(void) @@ -1009,17 +1018,7 @@ static int __init init_clocksource_sysfs(void) if (!error) error = device_register(&device_clocksource); - if (!error) - error = device_create_file( - &device_clocksource, - &dev_attr_current_clocksource); - if (!error) - error = device_create_file(&device_clocksource, - &dev_attr_unbind_clocksource); - if (!error) - error = device_create_file( - &device_clocksource, - &dev_attr_available_clocksource); + return error; } ^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:timers/core] clocksource: Don't walk the clocksource list for empty override 2018-01-17 6:01 [PATCH 1/3] clocksource: Skip to check the override clocksource if override name is empty Baolin Wang 2018-01-17 6:01 ` [PATCH 2/3] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes Baolin Wang 2018-01-17 6:01 ` [PATCH 3/3] clocksource: Use ATTRIBUTE_GROUPS macro Baolin Wang @ 2018-02-28 13:09 ` tip-bot for Baolin Wang 2 siblings, 0 replies; 6+ messages in thread From: tip-bot for Baolin Wang @ 2018-02-28 13:09 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, mingo, hpa, tglx, baolin.wang Commit-ID: 7f852afe448c95691ead6b57bae5f37562d060b5 Gitweb: https://git.kernel.org/tip/7f852afe448c95691ead6b57bae5f37562d060b5 Author: Baolin Wang <baolin.wang@linaro.org> AuthorDate: Wed, 17 Jan 2018 14:01:28 +0800 Committer: Thomas Gleixner <tglx@linutronix.de> CommitDate: Wed, 28 Feb 2018 14:04:52 +0100 clocksource: Don't walk the clocksource list for empty override If the override clocksource name is empty there is no point in walking the clocksource list for a match. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: arnd@arndb.de Cc: sboyd@codeaurora.org Cc: broonie@kernel.org Cc: john.stultz@linaro.org Link: https://lkml.kernel.org/r/069ce2a605546bcad6552968cff755f0a03f9f10.1516167691.git.baolin.wang@linaro.org --- kernel/time/clocksource.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 65f9e3f24dde..c5fdcb13200f 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -594,6 +594,9 @@ static void __clocksource_select(bool skipcur) if (!best) return; + if (!strlen(override_name)) + goto found; + /* Check for the override clocksource. */ list_for_each_entry(cs, &clocksource_list, list) { if (skipcur && cs == curr_clocksource) @@ -625,6 +628,7 @@ static void __clocksource_select(bool skipcur) break; } +found: if (curr_clocksource != best && !timekeeping_notify(best)) { pr_info("Switched to clocksource %s\n", best->name); curr_clocksource = best; ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-28 13:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-01-17 6:01 [PATCH 1/3] clocksource: Skip to check the override clocksource if override name is empty Baolin Wang 2018-01-17 6:01 ` [PATCH 2/3] clocksource: Use DEVICE_ATTR_RW/RO/WO to define device attributes Baolin Wang 2018-02-28 13:10 ` [tip:timers/core] " tip-bot for Baolin Wang 2018-01-17 6:01 ` [PATCH 3/3] clocksource: Use ATTRIBUTE_GROUPS macro Baolin Wang 2018-02-28 13:10 ` [tip:timers/core] clocksource: Use ATTRIBUTE_GROUPS tip-bot for Baolin Wang 2018-02-28 13:09 ` [tip:timers/core] clocksource: Don't walk the clocksource list for empty override tip-bot for Baolin Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®