introduce assign_if() macros in attempt to reduce ifdeffery
Subsystems (4)
cover introduce assign_if() macros in attempt to reduce ifdeffery
Based on the observation that given the following:
static void my_callback(void)
{
}
void (*callback)(void) = 0 ? my_callback : NULL;GCC will,
1.) Not emit 'defined but unused' warnings for 'my_callback' 2.) Typecheck my_callback against typeof(*callback)
3.) Eliminate my_callback as dead code (assuming it's unused elsewhere)
this patchset explores where/how this might be used to reduce the amount of ifdeffed code in device drivers.
Patch 1 in this series introduces two friendly-named helper macros:
assign_if(const_expr, fn): A friendlier form of (const_expr ? fn : NULL)
assign_if_enabled(conf, fn): Composition of assign_if() and IS_ENABLED().
In order to show a good target usecase for these macros, patch 2 introduces a new set of PM-related macros, similar to SET_*_PM_OPS, using assign_if_enabled() under the hood.
In particular, this is aimed at reducing code like the following:
#ifdef CONFIG_PM_SLEEP
static int foo_suspend(struct device *dev)
{
/* ... */
}
#else
#define foo_suspend NULL
#endif
static const struct dev_pm_ops foo_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(foo_suspend, NULL)
};With the ifdefless:
static int foo_suspend(struct device *dev)
{
/* ... */
}
static const struct dev_pm_ops foo_pm_ops = {
ASSIGN_SYSTEM_SLEEP_PM_OPS(foo_suspend, NULL),
};For patch 3, an existing consumer of SET_*_PM_OPS(), the MSM USB phy driver[1] is modified to use the newly introduced ASSIGN_*_PM_OPS() macros to show in a real case what simplifications could be gained.
For testing that GCC is actually eliminating the PM-related callbacks when it can, the MSM USB phy driver was built before and after patch 3, in 4 different configurations, and object sizes compared[2]:
text data bss dec hex filename
11008 488 20 11516 2cfc phy_objects_before/phy-msm-usb.nopm.o 11008 488 20 11516 2cfc phy_objects_after/phy-msm-usb.nopm.o
13528 584 20 14132 3734 phy_objects_before/phy-msm-usb.runtime.o 13528 584 20 14132 3734 phy_objects_after/phy-msm-usb.runtime.o
13828 632 20 14480 3890 phy_objects_before/phy-msm-usb.runtime+sleep.o 13828 632 20 14480 3890 phy_objects_after/phy-msm-usb.runtime+sleep.o
13072 560 20 13652 3554 phy_objects_before/phy-msm-usb.sleep.o 13072 560 20 13652 3554 phy_objects_after/phy-msm-usb.sleep.o
[1]: Chosen because it has recently broken randconfig builds due to improper
#ifdeffery using CONFIG_PM* defines
[2]:
$ ${CROSS_COMPILE}gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.8-2013.07-1 - Linaro GCC 2013.07) 4.8.2 20130624 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.Josh Cartwright (3):
typecheck: introduce assign_if() and assign_if_enabled()
PM: define new ASSIGN_*_PM_OPS macros based on assign_if
usb: phy: msm: use ASSIGN_*_PM_OPS variants
drivers/usb/phy/phy-msm-usb.c | 13 +++---------- include/linux/pm.h | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/typecheck.h | 18 ++++++++++++++++++ 3 files changed, 60 insertions(+), 10 deletions(-)
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 1/3 typecheck: introduce assign_if() and assign_if_enabled()
The assign_if() and assign_if_enable() macros are intended to be used in static initializers for function pointers, where the pointer is expected to be NULL when a compile-time condition does not hold.
These macros allow for implementing this behavior, without requiring the functions be wrapped in #ifdef conditionals, and while providing typesafety regardless of the value of the conditional.
For example, the following pattern is common:
#ifdef CONFIG_FOO
static void foo_callback(void)
{
}
#else
#define foo_callback NULL
#endif
static struct foo_object foo_obj = {
.callback = foo_callback,
};Usage of assign_if_enabled() allows for achieving the same effect without the preprocessor conditional, and in addition, allowing the compiler to typecheck the function regardless of CONFIG_FOO.
static void foo_callback(void)
{
}
static struct foo_object foo_obj = {
.callback = assign_if_enabled(CONFIG_FOO, foo_callback),
};--- include/linux/typecheck.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/linux/typecheck.h +18 -0
@@ -21,4 +21,22 @@ (void )__tmp; \ }) +/* +* Intended for use in static object initializers, +* assign_if(const_expr, function) evaluates to 'function' if 'const_expr', +* otherwise NULL. +* +* The type of the assign_if() expression is typeof(function), and therefore +* can provide typechecking regardless of 'const_expr'. +* +* gcc considers 'function' to be used and will not generate a 'defined but not +* used' warning when not 'const_expr', however, gcc is smart enough to +* eliminate 'function' if assign_if() is the only reference. +*/ +#define assign_if (const_expr,function) \ + ((const_expr) ? function : NULL) + +#define assign_if_enabled (option,function) \ + assign_if(IS_ENABLED(option), function) +#endif /* TYPECHECK_H_INCLUDED */
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Greg Kroah-Hartman
maintainerRe: [PATCH 1/3] typecheck: introduce assign_if() and assign_if_enabled()
Quoted 50 lines · Josh Cartwright
The
assign_if()andassign_if_enable()macros are intended to be used in static initializers for function pointers, where the pointer is expected to be NULL when a compile-time condition does not hold.These macros allow for implementing this behavior, without requiring the functions be wrapped in #ifdef conditionals, and while providing typesafety regardless of the value of the conditional.
For example, the following pattern is common:
#ifdef CONFIG_FOO static void foo_callback(void) { } #else #define foo_callback NULL #endif static struct foo_object foo_obj = { .callback = foo_callback, };Usage of
assign_if_enabled()allows for achieving the same effect without the preprocessor conditional, and in addition, allowing the compiler to typecheck the function regardless ofCONFIG_FOO.static void foo_callback(void) { } static struct foo_object foo_obj = { .callback = assign_if_enabled(CONFIG_FOO, foo_callback), };Cc Andrew Morton <[email protected]>Signed-off-by Josh Cartwright <[email protected]>--- include/linux/typecheck.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)include/linux/typecheck.h +2
-0@@ -21,4 +21,22 @@ (void )__tmp; \ }) +/* +* Intended for use in static object initializers,
include/linux/typecheck.h line 35
Quoted 10 lines
include/linux/typecheck.h +10
-0+* assign_if(const_expr, function) evaluates to 'function' if 'const_expr', +* otherwise NULL. +* +* The type of the assign_if() expression is typeof(function), and therefore +* can provide typechecking regardless of 'const_expr'. +* +* gcc considers 'function' to be used and will not generate a 'defined but not +* used' warning when not 'const_expr', however, gcc is smart enough to +* eliminate 'function' if assign_if() is the only reference. +*/
What version of gcc started doing this? Does llvm also do this?
thanks,
greg k-h
Re: [PATCH 1/3] typecheck: introduce assign_if() and assign_if_enabled()
Quoted 14 lines · Greg Kroah-Hartman
Quoted 4 lines · Josh Cartwright
+/*
+ * Intended for use in static object initializers,
+ *assign_if(const_expr, function)evaluates to 'function' if 'const_expr',
+ * otherwise NULL.Quoted 8 lines
+ *
+ * The type of theassign_if()expression is typeof(function), and therefore
+ * can provide typechecking regardless of 'const_expr'.
+ *
+ * gcc considers 'function' to be used and will not generate a 'defined but not
+ * used' warning when not 'const_expr', however, gcc is smart enough to
+ * eliminate 'function' ifassign_if()is the only reference.
+ */
Quoted 1 line
What version of gcc started doing this? Does llvm also do this?
I'll need to dig up some old gcc's to give this a more thorough testing; testing with clang 3.4, and it appears to have the same behavior, at least when I throw a trivial usecase at it.
$ clang --version clang version 3.4 (tags/RELEASE_34/final) Target: x86_64-unknown-linux-gnu Thread model: posix
$ cat test.c
static void foo(void)
{
extern void BROKEN(void);
BROKEN();
}
void (*callback)(void) = 0 ? foo : 0;$ clang -Wall -Werror -c test.c
$ size test.o text data bss dec hex filename 0 0 8 8 8 /tmp/test.o
$ nm test.o 0000000000000000 B callback
Although, given the feedback on the other patches, assign_if() may become just be a solution in search of a problem :).
Thanks,
Josh
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 2/3 PM: define new ASSIGN_*_PM_OPS macros based on assign_if
In reply to Josh CartwrightSimilar to the SET_*_PM_OPS(), these functions are to be used in initializers of struct dev_pm_ops, for example:
static const struct dev_pm_ops foo_pm_ops = {
ASSIGN_RUNTIME_PM_OPS(foo_rpm_suspend, foo_rpm_resume, NULL)
ASSIGN_SYSTEM_SLEEP_PM_OPS(foo_suspend, foo_resume)
};Unlike their SET_*_PM_OPS() counter parts, it is unnecessary to wrap the function callbacks in #ifdeffery in order to prevent 'defined but not used' warnings when the corresponding CONFIG_PM* options are unset.
--- include/linux/pm.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
include/linux/pm.h +39 -0
@@ -299,6 +299,15 @@ struct dev_pm_ops {int (*runtime_idle)(struct device *dev); }; +#define assign_if_pm_sleep (fn) \ + assign_if_enabled(CONFIG_PM_SLEEP, fn) + +#define assign_if_pm_runtime (fn) \ + assign_if_enabled(CONFIG_PM_RUNTIME, fn) + +#define assign_if_pm (fn) \ + assign_if_enabled(CONFIG_PM, fn) +#ifdef CONFIG_PM_SLEEP #define SET_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ .suspend = suspend_fn, \
@@ -342,6 +351,36 @@ struct dev_pm_ops {#endif /* +* The ASSIGN_* variations of the above make wrapping the associated callback +* functions in preprocessor defines unnecessary. +*/ +#define ASSIGN_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend = assign_if_pm_sleep(suspend_fn), \ + .resume = assign_if_pm_sleep(resume_fn), \ + .freeze = assign_if_pm_sleep(suspend_fn), \ + .thaw = assign_if_pm_sleep(resume_fn), \ + .poweroff = assign_if_pm_sleep(suspend_fn), \ + .restore = assign_if_pm_sleep(resume_fn), + +#define ASSIGN_LATE_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend_late = assign_if_pm_sleep(suspend_fn), \ + .resume_early = assign_if_pm_sleep(resume_fn), \ + .freeze_late = assign_if_pm_sleep(suspend_fn), \ + .thaw_early = assign_if_pm_sleep(resume_fn), \ + .poweroff_late = assign_if_pm_sleep(suspend_fn), \ + .restore_early = assign_if_pm_sleep(resume_fn), + +#define ASSIGN_RUNTIME_PM_OPS (suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = assign_if_pm_runtime(suspend_fn), \ + .runtime_resume = assign_if_pm_runtime(resume_fn), \ + .runtime_idle = assign_if_pm_runtime(idle_fn), + +#define ASSIGN_PM_RUNTIME_PM_OPS (suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = assign_if_pm(suspend_fn), \ + .runtime_resume = assign_if_pm(resume_fn), \ + .runtime_idle = assign_if_pm(idle_fn), + +/* * Use this if you want to use the same suspend and resume callbacks for suspend * to RAM and hibernation. */
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Greg Kroah-Hartman
maintainerRe: [PATCH 2/3] PM: define new ASSIGN_*_PM_OPS macros based on assign_if
Quoted 59 lines · Josh Cartwright
Similar to the SET_*_PM_OPS(), these functions are to be used in initializers of struct
dev_pm_ops, for example:static const struct dev_pm_ops foo_pm_ops = { ASSIGN_RUNTIME_PM_OPS(foo_rpm_suspend, foo_rpm_resume, NULL) ASSIGN_SYSTEM_SLEEP_PM_OPS(foo_suspend, foo_resume) };Unlike their SET_*_PM_OPS() counter parts, it is unnecessary to wrap the function callbacks in #ifdeffery in order to prevent 'defined but not used' warnings when the corresponding CONFIG_PM* options are unset.
Signed-off-by Josh Cartwright <[email protected]>--- include/linux/pm.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)include/linux/pm.h +27
-0@@ -299,6 +299,15 @@ struct dev_pm_ops {int (*runtime_idle)(struct device *dev); }; +#define assign_if_pm_sleep (fn) \ + assign_if_enabled(CONFIG_PM_SLEEP, fn) + +#define assign_if_pm_runtime (fn) \ + assign_if_enabled(CONFIG_PM_RUNTIME, fn) + +#define assign_if_pm (fn) \ + assign_if_enabled(CONFIG_PM, fn) +#ifdef CONFIG_PM_SLEEP #define SET_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ .suspend = suspend_fn, \@@ -342,6 +351,36 @@ struct dev_pm_ops {#endif /* +* The ASSIGN_* variations of the above make wrapping the associated callback +* functions in preprocessor defines unnecessary. +*/ +#define ASSIGN_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend = assign_if_pm_sleep(suspend_fn), \ + .resume = assign_if_pm_sleep(resume_fn), \ + .freeze = assign_if_pm_sleep(suspend_fn), \ + .thaw = assign_if_pm_sleep(resume_fn), \ + .poweroff = assign_if_pm_sleep(suspend_fn), \ + .restore = assign_if_pm_sleep(resume_fn), + +#define ASSIGN_LATE_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend_late = assign_if_pm_sleep(suspend_fn), \ + .resume_early = assign_if_pm_sleep(resume_fn), \ + .freeze_late = assign_if_pm_sleep(suspend_fn), \ + .thaw_early = assign_if_pm_sleep(resume_fn), \ + .poweroff_late = assign_if_pm_sleep(suspend_fn), \ + .restore_early = assign_if_pm_sleep(resume_fn),
include/linux/pm.h struct dev_pm_ops { · line 381
Quoted 10 lines
include/linux/pm.h +10
-0+ +#define ASSIGN_RUNTIME_PM_OPS (suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = assign_if_pm_runtime(suspend_fn), \ + .runtime_resume = assign_if_pm_runtime(resume_fn), \ + .runtime_idle = assign_if_pm_runtime(idle_fn), + +#define ASSIGN_PM_RUNTIME_PM_OPS (suspend_fn, resume_fn, idle_fn) \ + .runtime_suspend = assign_if_pm(suspend_fn), \ + .runtime_resume = assign_if_pm(resume_fn), \ + .runtime_idle = assign_if_pm(idle_fn),
Ugh, what a mess, really? Is it that hard to get the #ifdef right in the code? Why not just always define the functions and then also always have them in the structures, and if the feature isn't enabled, just don't call/use them?
Yes, it would cause a _very_ tiny increase in code size if the option is disabled, but really, does anyone ever disable those options becides on the dreaded 'make randconfig' checkers?
It seems that would solve the problem much easier than this macro hell.
ick.
greg k-h
Re: [PATCH 2/3] PM: define new ASSIGN_*_PM_OPS macros based on assign_if
Hi!
Quoted 4 lines
Quoted 4 lines
include/linux/pm.h +4
-0+#define ASSIGN_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend = assign_if_pm_sleep(suspend_fn), \ + .resume = assign_if_pm_sleep(resume_fn), \ + .freeze = assign_if_pm_sleep(suspend_fn), \
Quoted 8 lines
include/linux/pm.h struct dev_pm_ops { · line 363
Quoted 3 lines
include/linux/pm.h +3
-0+ .thaw = assign_if_pm_sleep(resume_fn), \ + .poweroff = assign_if_pm_sleep(suspend_fn), \ + .restore = assign_if_pm_sleep(resume_fn),Ugh, what a mess, really? Is it that hard to get the #ifdef right in the code? Why not just always define the functions and then also always have them in the structures, and if the feature isn't enabled, just don't call/use them?
The functions may not compile with CONFIG_PM disabled. (And #ifdefs in the code are considered ugly).
Quoted 3 lines
Yes, it would cause a _very_ tiny increase in code size if the option is disabled, but really, does anyone ever disable those options becides on the dreaded 'make randconfig' checkers?
We don't want CONFIG_PM complexity on some embedded systems... and it is useful tostart with simple (!PM) system when introducing new board.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Greg Kroah-Hartman
maintainerRe: [PATCH 2/3] PM: define new ASSIGN_*_PM_OPS macros based on assign_if
Quoted 15 lines · Pavel Machek
Hi!
Quoted 4 lines
Quoted 4 lines
include/linux/pm.h +4
-0+#define ASSIGN_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend = assign_if_pm_sleep(suspend_fn), \ + .resume = assign_if_pm_sleep(resume_fn), \ + .freeze = assign_if_pm_sleep(suspend_fn), \Quoted 8 lines
include/linux/pm.h struct dev_pm_ops { · line 363
Quoted 3 lines
include/linux/pm.h +3
-0+ .thaw = assign_if_pm_sleep(resume_fn), \ + .poweroff = assign_if_pm_sleep(suspend_fn), \ + .restore = assign_if_pm_sleep(resume_fn),Ugh, what a mess, really? Is it that hard to get the #ifdef right in the code? Why not just always define the functions and then also always have them in the structures, and if the feature isn't enabled, just don't call/use them?
Quoted 8 lines
The functions may not compile with
CONFIG_PMdisabled. (And #ifdefs in the code are considered ugly).Quoted 3 lines
Yes, it would cause a _very_ tiny increase in code size if the option is disabled, but really, does anyone ever disable those options becides on the dreaded 'make randconfig' checkers?
We don't want
CONFIG_PMcomplexity on some embedded systems...
Really, what embedded systems do not want this?
Quoted 2 lines
and it is useful tostart with simple (!PM) system when introducing new board.
I'm not saying to disable the option, I'm saying to stop worrying about saving a few hundred bytes in individual drivers with this crazy #ifdef and macro mess that no one understands and always gets wrong.
greg k-h
Re: [PATCH 2/3] PM: define new ASSIGN_*_PM_OPS macros based on assign_if
Hi!
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
include/linux/pm.h +4
-0+#define ASSIGN_SYSTEM_SLEEP_PM_OPS (suspend_fn, resume_fn) \ + .suspend = assign_if_pm_sleep(suspend_fn), \ + .resume = assign_if_pm_sleep(resume_fn), \ + .freeze = assign_if_pm_sleep(suspend_fn), \Quoted 8 lines
include/linux/pm.h struct dev_pm_ops { · line 363
Quoted 3 lines
include/linux/pm.h +3
-0+ .thaw = assign_if_pm_sleep(resume_fn), \ + .poweroff = assign_if_pm_sleep(suspend_fn), \ + .restore = assign_if_pm_sleep(resume_fn),Ugh, what a mess, really? Is it that hard to get the #ifdef right in the code? Why not just always define the functions and then also always have them in the structures, and if the feature isn't enabled, just don't call/use them?
The functions may not compile with
CONFIG_PMdisabled. (And #ifdefs in the code are considered ugly).
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Yes, it would cause a _very_ tiny increase in code size if the option is disabled, but really, does anyone ever disable those options becides on the dreaded 'make randconfig' checkers?
We don't want
CONFIG_PMcomplexity on some embedded systems...Really, what embedded systems do not want this?
Most of them? :-) In last four years, I cooperated on 4 of those, and device power management was not requirement on any of those. Just one was operated on battery that was "small".
Quoted 6 lines
Quoted 2 lines
and it is useful tostart with simple (!PM) system when introducing new board.
I'm not saying to disable the option, I'm saying to stop worrying about saving a few hundred bytes in individual drivers with this crazy #ifdef and macro mess that no one understands and always gets wrong.
Quoted 2 lines · I wrote:
Quoted 2 lines
The functions may not compile with
CONFIG_PMdisabled. (And #ifdefs in the code are considered ugly).
To reiterate: suspend_fn (etc) is likely to use stuff not avialable in !PM case, so it will break your compilation if you don't add some #ifdefs.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 3/3 usb: phy: msm: use ASSIGN_*_PM_OPS variants
In reply to Josh CartwrightUse ASSIGN_SYSTEM_SLEEP_PM_OPS and ASSIGN_RUNTIME_PM_OPS in the initializer for msm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.
--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/usb/phy/phy-msm-usb.c +3 -10
@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {
@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {
@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);
@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);
@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle) };static struct platform_driver msm_otg_driver = {
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Hi,
Quoted 51 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-6@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ;
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c +3
-4} -#endif static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)
if the patch introducing assign_if() gets accepted, I'm ok with this patch.
Signature · 1 line
balbi
Greg Kroah-Hartman
maintainerRe: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif
Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.
I can't take that patch at this point in time, it's just too ugly...
As are those crazy SET_SYSTEM_SLEEP_PM_OPS() macros, ick, who made those things?
What language are we trying to program in here people?
greg k-h
Re: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Quoted 69 lines · Greg Kroah-Hartman
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.
Quoted 6 lines
I can't take that patch at this point in time, it's just too ugly...
As are those crazy
SET_SYSTEM_SLEEP_PM_OPS()macros, ick, who made those things?What language are we trying to program in here people?
Since we're discussing this topic here, I'd like point my RFC which gets rid of same ifdeffery in a different way:
http://lkml.org/lkml/2013/12/13/4
Comments are welcome.
Br, David
Quoted 6 lines
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg Kroah-Hartman
maintainerRe: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Quoted 72 lines · David Cohen
Quoted 71 lines · Greg Kroah-Hartman
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.I can't take that patch at this point in time, it's just too ugly...
Quoted 8 lines
Quoted 4 lines
As are those crazy
SET_SYSTEM_SLEEP_PM_OPS()macros, ick, who made those things?What language are we trying to program in here people?
Since we're discussing this topic here, I'd like point my RFC which gets rid of same ifdeffery in a different way:
http://lkml.org/lkml/2013/12/13/4
Again, why can't we just always define these fields in the structure, then we don't need any crazy, complicated mess for assigning the function pointers?
Again, the odds that this config option is ever disabled in "real" systems is so low these days, I have half a mind just to rip it out entirely as the amount of work spent on compiler warnings and the like in this area has proably offset any power savings the code was supposed to save on systems :(
ick.
greg k-h
Re: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Quoted 86 lines · Greg Kroah-Hartman
Quoted 72 lines · David Cohen
Quoted 71 lines · Greg Kroah-Hartman
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.I can't take that patch at this point in time, it's just too ugly...
Quoted 8 lines
Quoted 4 lines
As are those crazy
SET_SYSTEM_SLEEP_PM_OPS()macros, ick, who made those things?What language are we trying to program in here people?
Since we're discussing this topic here, I'd like point my RFC which gets rid of same ifdeffery in a different way:
http://lkml.org/lkml/2013/12/13/4Again, why can't we just always define these fields in the structure, then we don't need any crazy, complicated mess for assigning the function pointers?
Quoted 5 lines
Again, the odds that this config option is ever disabled in "real" systems is so low these days, I have half a mind just to rip it out entirely as the amount of work spent on compiler warnings and the like in this area has proably offset any power savings the code was supposed to save on systems :(
That makes sense :)
Thanks for your feedback.
BR, David
Quoted 8 lines
ick.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
In reply to Greg Kroah-HartmanQuoted 86 lines · Greg Kroah-Hartman
Quoted 72 lines · David Cohen
Quoted 71 lines · Greg Kroah-Hartman
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.I can't take that patch at this point in time, it's just too ugly...
Quoted 8 lines
Quoted 4 lines
As are those crazy
SET_SYSTEM_SLEEP_PM_OPS()macros, ick, who made those things?What language are we trying to program in here people?
Since we're discussing this topic here, I'd like point my RFC which gets rid of same ifdeffery in a different way:
http://lkml.org/lkml/2013/12/13/4Again, why can't we just always define these fields in the structure, then we don't need any crazy, complicated mess for assigning the function pointers?
Quoted 5 lines
Again, the odds that this config option is ever disabled in "real" systems is so low these days, I have half a mind just to rip it out entirely as the amount of work spent on compiler warnings and the like in this area has proably offset any power savings the code was supposed to save on systems :(
Your point is certainly valid. I suppose the footprint of the kernel is nothing we should bother about? We have other solutions for that, right?
Kind regards
Ulf Hansson
Quoted 9 lines
ick.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Greg Kroah-Hartman
maintainerRe: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Quoted 94 lines · Ulf Hansson
Quoted 86 lines · Greg Kroah-Hartman
Quoted 72 lines · David Cohen
Quoted 71 lines · Greg Kroah-Hartman
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.I can't take that patch at this point in time, it's just too ugly...
Quoted 8 lines
Quoted 4 lines
As are those crazy
SET_SYSTEM_SLEEP_PM_OPS()macros, ick, who made those things?What language are we trying to program in here people?
Since we're discussing this topic here, I'd like point my RFC which gets rid of same ifdeffery in a different way:
http://lkml.org/lkml/2013/12/13/4Again, why can't we just always define these fields in the structure, then we don't need any crazy, complicated mess for assigning the function pointers?
Quoted 5 lines
Again, the odds that this config option is ever disabled in "real" systems is so low these days, I have half a mind just to rip it out entirely as the amount of work spent on compiler warnings and the like in this area has proably offset any power savings the code was supposed to save on systems :(
Quoted 3 lines
Your point is certainly valid. I suppose the footprint of the kernel is nothing we should bother about? We have other solutions for that, right?
What does the "footprint of the kernel" have to do with an option that everyone enables as they want/need the functionality? You are only talking about saving size for systems that do not exist. Do you know of any commen system that cares about size and yet not power that would be affected by this change?
And exactly how much "size" are we talking about here? Did the available memory size for new chips just increase more in me writing this email than the size that this proposed patch would have offset?
greg k-h
Re: [PATCH 3/3] usb: phy: msm: use ASSIGN_*_PM_OPS variants
Quoted 99 lines · Greg Kroah-Hartman
Quoted 94 lines · Ulf Hansson
Quoted 86 lines · Greg Kroah-Hartman
Quoted 72 lines · David Cohen
Quoted 71 lines · Greg Kroah-Hartman
Quoted 57 lines · Felipe Balbi
Hi,
Quoted 54 lines · Josh Cartwright
Use
ASSIGN_SYSTEM_SLEEP_PM_OPSandASSIGN_RUNTIME_PM_OPSin the initializer formsm_otg_dev_pm_ops. Doing so allows us to eliminate preprocessor conditionals around the specified callbacks.Signed-off-by Josh Cartwright <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-7@@ -414,8 +414,6 @@ static int msm_otg_reset(struct usb_phy *phy)#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) -#ifdef CONFIG_PM -#define USB_PHY_SUSP_DIG_VOL 500000static int msm_hsusb_config_vddcx (int high) {@@ -609,7 +607,6 @@ skip_phy_resume:return 0 ; } -#endif static void msm_otg_notify_charger (struct msm_otg *motg,unsigned mA) {@@ -1664,7 +1661,6 @@ static int msm_otg_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_RUNTIME static int msm_otg_runtime_idle (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1699,9 +1695,7 @@ static int msm_otg_runtime_resume(struct device *dev)dev_dbg (dev,"OTG runtime resume\n" );return msm_otg_resume (motg); } -#endif -#ifdef CONFIG_PM_SLEEP static int msm_otg_pm_suspend (struct device *dev) {struct msm_otg *motg =dev_get_drvdata (dev);@@ -1731,12 +1725,11 @@ static int msm_otg_pm_resume(struct device *dev)return 0 ; } -#endif Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_pm_resume(struct device *dev) · line 1732
Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +3
-3static const struct dev_pm_ops msm_otg_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) -SET_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, - msm_otg_runtime_idle) + ASSIGN_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) +ASSIGN_RUNTIME_PM_OPS (msm_otg_runtime_suspend, msm_otg_runtime_resume, + msm_otg_runtime_idle)if the patch introducing
assign_if()gets accepted, I'm ok with this patch.I can't take that patch at this point in time, it's just too ugly...
Quoted 8 lines
Quoted 4 lines
As are those crazy
SET_SYSTEM_SLEEP_PM_OPS()macros, ick, who made those things?What language are we trying to program in here people?
Since we're discussing this topic here, I'd like point my RFC which gets rid of same ifdeffery in a different way:
http://lkml.org/lkml/2013/12/13/4Again, why can't we just always define these fields in the structure, then we don't need any crazy, complicated mess for assigning the function pointers?
Quoted 5 lines
Again, the odds that this config option is ever disabled in "real" systems is so low these days, I have half a mind just to rip it out entirely as the amount of work spent on compiler warnings and the like in this area has proably offset any power savings the code was supposed to save on systems :(
Quoted 3 lines
Your point is certainly valid. I suppose the footprint of the kernel is nothing we should bother about? We have other solutions for that, right?
Quoted 5 lines
What does the "footprint of the kernel" have to do with an option that everyone enables as they want/need the functionality? You are only talking about saving size for systems that do not exist. Do you know of any commen system that cares about size and yet not power that would be affected by this change?
It was more a hypothetical thought. I can't give you any examples of products and I certainly think your suggestion makes sense.
What I had in mind were my experience from flashloaders and productiontools. Those often requires a fast boot which don't cares about PM. One of many things that helps here, is a "small" footprint of the kernel. But I guess this becomes quite hypothetical and I guess we shouldn't consider this as a valid argument!?
Quoted 4 lines
And exactly how much "size" are we talking about here? Did the available memory size for new chips just increase more in me writing this email than the size that this proposed patch would have offset?
I only had the fast boot in mind... :-)
Kind regards
Ulf Hansson
Quoted 2 lines
greg k-h