* [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-04 20:43 ` Sebastian Capella
0 siblings, 0 replies; 35+ messages in thread
From: Sebastian Capella @ 2014-02-04 20:43 UTC (permalink / raw)
To: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches
Cc: Sebastian Capella, Pavel Machek, Len Brown, Rafael J. Wysocki
Checkpatch reports several warnings in hibernate.c
printk use removed, long lines wrapped, whitespace cleanup,
extend short msleeps, while loops on two lines.
Signed-off-by: Sebastian Capella <sebastian.capella@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
---
kernel/power/hibernate.c | 62 ++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 0121dab..cd1e30c 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -94,7 +94,7 @@ EXPORT_SYMBOL(system_entering_hibernation);
#ifdef CONFIG_PM_DEBUG
static void hibernation_debug_sleep(void)
{
- printk(KERN_INFO "hibernation debug: Waiting for 5 seconds.\n");
+ pr_info("hibernation debug: Waiting for 5 seconds.\n");
mdelay(5000);
}
@@ -239,7 +239,7 @@ void swsusp_show_speed(struct timeval *start, struct timeval *stop,
centisecs = 1; /* avoid div-by-zero */
k = nr_pages * (PAGE_SIZE / 1024);
kps = (k * 100) / centisecs;
- printk(KERN_INFO "PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
+ pr_info("PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
msg, k,
centisecs / 100, centisecs % 100,
kps / 1000, (kps % 1000) / 10);
@@ -260,8 +260,7 @@ static int create_image(int platform_mode)
error = dpm_suspend_end(PMSG_FREEZE);
if (error) {
- printk(KERN_ERR "PM: Some devices failed to power down, "
- "aborting hibernation\n");
+ pr_err("PM: Some devices failed to power down, aborting hibernation\n");
return error;
}
@@ -277,8 +276,7 @@ static int create_image(int platform_mode)
error = syscore_suspend();
if (error) {
- printk(KERN_ERR "PM: Some system devices failed to power down, "
- "aborting hibernation\n");
+ pr_err("PM: Some system devices failed to power down, aborting hibernation\n");
goto Enable_irqs;
}
@@ -289,8 +287,7 @@ static int create_image(int platform_mode)
save_processor_state();
error = swsusp_arch_suspend();
if (error)
- printk(KERN_ERR "PM: Error %d creating hibernation image\n",
- error);
+ pr_err("PM: Error %d creating hibernation image\n", error);
/* Restore control flow magically appears here */
restore_processor_state();
if (!in_suspend) {
@@ -413,8 +410,7 @@ static int resume_target_kernel(bool platform_mode)
error = dpm_suspend_end(PMSG_QUIESCE);
if (error) {
- printk(KERN_ERR "PM: Some devices failed to power down, "
- "aborting resume\n");
+ pr_err("PM: Some devices failed to power down, aborting resume\n");
return error;
}
@@ -550,7 +546,8 @@ int hibernation_platform_enter(void)
hibernation_ops->enter();
/* We should never get here */
- while (1);
+ while (1)
+ ;
Power_up:
syscore_resume();
@@ -611,8 +608,7 @@ static void power_down(void)
*/
error = swsusp_unmark();
if (error)
- printk(KERN_ERR "PM: Swap will be unusable! "
- "Try swapon -a.\n");
+ pr_err("PM: Swap will be unusable! Try swapon -a.\n");
return;
#endif
}
@@ -621,8 +617,9 @@ static void power_down(void)
* Valid image is on the disk, if we continue we risk serious data
* corruption after resume.
*/
- printk(KERN_CRIT "PM: Please power down manually\n");
- while(1);
+ pr_crit("PM: Please power down manually\n");
+ while (1)
+ ;
}
/**
@@ -644,9 +641,9 @@ int hibernate(void)
if (error)
goto Exit;
- printk(KERN_INFO "PM: Syncing filesystems ... ");
+ pr_info("PM: Syncing filesystems ... ");
sys_sync();
- printk("done.\n");
+ pr_cont("done.\n");
error = freeze_processes();
if (error)
@@ -670,7 +667,7 @@ int hibernate(void)
if (nocompress)
flags |= SF_NOCOMPRESS_MODE;
else
- flags |= SF_CRC32_MODE;
+ flags |= SF_CRC32_MODE;
pr_debug("PM: writing image.\n");
error = swsusp_write(flags);
@@ -750,7 +747,7 @@ static int software_resume(void)
pr_debug("PM: Checking hibernation image partition %s\n", resume_file);
if (resume_delay) {
- printk(KERN_INFO "Waiting %dsec before reading resume device...\n",
+ pr_info("Waiting %dsec before reading resume device...\n",
resume_delay);
ssleep(resume_delay);
}
@@ -765,7 +762,7 @@ static int software_resume(void)
if (isdigit(resume_file[0]) && resume_wait) {
int partno;
while (!get_gendisk(swsusp_resume_device, &partno))
- msleep(10);
+ msleep(20);
}
if (!swsusp_resume_device) {
@@ -776,8 +773,9 @@ static int software_resume(void)
wait_for_device_probe();
if (resume_wait) {
- while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
- msleep(10);
+ while ((swsusp_resume_device =
+ name_to_dev_t(resume_file)) == 0)
+ msleep(20);
async_synchronize_full();
}
@@ -826,7 +824,7 @@ static int software_resume(void)
if (!error)
hibernation_restore(flags & SF_PLATFORM_MODE);
- printk(KERN_ERR "PM: Failed to load hibernation image, recovering.\n");
+ pr_err("PM: Failed to load hibernation image, recovering.\n");
swsusp_free();
free_basic_memory_bitmaps();
Thaw:
@@ -965,7 +963,7 @@ power_attr(disk);
static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
- return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
+ return sprintf(buf, "%d:%d\n", MAJOR(swsusp_resume_device),
MINOR(swsusp_resume_device));
}
@@ -986,7 +984,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
lock_system_sleep();
swsusp_resume_device = res;
unlock_system_sleep();
- printk(KERN_INFO "PM: Starting manual resume from disk\n");
+ pr_info("PM: Starting manual resume from disk\n");
noresume = 0;
software_resume();
ret = n;
@@ -996,13 +994,15 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
power_attr(resume);
-static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
+static ssize_t image_size_show(struct kobject *kobj,
+ struct kobj_attribute *attr,
char *buf)
{
return sprintf(buf, "%lu\n", image_size);
}
-static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
+static ssize_t image_size_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
const char *buf, size_t n)
{
unsigned long size;
@@ -1039,7 +1039,7 @@ static ssize_t reserved_size_store(struct kobject *kobj,
power_attr(reserved_size);
-static struct attribute * g[] = {
+static struct attribute *g[] = {
&disk_attr.attr,
&resume_attr.attr,
&image_size_attr.attr,
@@ -1066,7 +1066,7 @@ static int __init resume_setup(char *str)
if (noresume)
return 1;
- strncpy( resume_file, str, 255 );
+ strncpy(resume_file, str, 255);
return 1;
}
@@ -1106,7 +1106,9 @@ static int __init resumewait_setup(char *str)
static int __init resumedelay_setup(char *str)
{
- resume_delay = simple_strtoul(str, NULL, 0);
+ int ret = kstrtoint(str, 0, &resume_delay);
+ /* mask must_check warn; on failure, leaves resume_delay unchanged */
+ (void)ret;
return 1;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 20:43 ` Sebastian Capella
@ 2014-02-04 21:21 ` Joe Perches
-1 siblings, 0 replies; 35+ messages in thread
From: Joe Perches @ 2014-02-04 21:21 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown, Rafael J. Wysocki
On Tue, 2014-02-04 at 12:43 -0800, Sebastian Capella wrote:
> Checkpatch reports several warnings in hibernate.c
> printk use removed, long lines wrapped, whitespace cleanup,
> extend short msleeps, while loops on two lines.
[]
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
[]
> @@ -765,7 +762,7 @@ static int software_resume(void)
> if (isdigit(resume_file[0]) && resume_wait) {
> int partno;
> while (!get_gendisk(swsusp_resume_device, &partno))
> - msleep(10);
> + msleep(20);
What good is changing this from 10 to 20?
> @@ -776,8 +773,9 @@ static int software_resume(void)
> wait_for_device_probe();
>
> if (resume_wait) {
> - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> - msleep(10);
> + while ((swsusp_resume_device =
> + name_to_dev_t(resume_file)) == 0)
> + msleep(20);
here too.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-04 21:21 ` Joe Perches
0 siblings, 0 replies; 35+ messages in thread
From: Joe Perches @ 2014-02-04 21:21 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown, Rafael J. Wysocki
On Tue, 2014-02-04 at 12:43 -0800, Sebastian Capella wrote:
> Checkpatch reports several warnings in hibernate.c
> printk use removed, long lines wrapped, whitespace cleanup,
> extend short msleeps, while loops on two lines.
[]
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
[]
> @@ -765,7 +762,7 @@ static int software_resume(void)
> if (isdigit(resume_file[0]) && resume_wait) {
> int partno;
> while (!get_gendisk(swsusp_resume_device, &partno))
> - msleep(10);
> + msleep(20);
What good is changing this from 10 to 20?
> @@ -776,8 +773,9 @@ static int software_resume(void)
> wait_for_device_probe();
>
> if (resume_wait) {
> - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> - msleep(10);
> + while ((swsusp_resume_device =
> + name_to_dev_t(resume_file)) == 0)
> + msleep(20);
here too.
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 21:21 ` Joe Perches
(?)
@ 2014-02-04 22:05 ` Sebastian Capella
2014-02-04 23:45 ` Joe Perches
-1 siblings, 1 reply; 35+ messages in thread
From: Sebastian Capella @ 2014-02-04 22:05 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown, Rafael J. Wysocki
Quoting Joe Perches (2014-02-04 13:21:02)
> On Tue, 2014-02-04 at 12:43 -0800, Sebastian Capella wrote:
> > Checkpatch reports several warnings in hibernate.c
> > printk use removed, long lines wrapped, whitespace cleanup,
> > extend short msleeps, while loops on two lines.
> []
> > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> []
> > @@ -765,7 +762,7 @@ static int software_resume(void)
> > if (isdigit(resume_file[0]) && resume_wait) {
> > int partno;
> > while (!get_gendisk(swsusp_resume_device, &partno))
> > - msleep(10);
> > + msleep(20);
>
> What good is changing this from 10 to 20?
>
> > @@ -776,8 +773,9 @@ static int software_resume(void)
> > wait_for_device_probe();
> >
> > if (resume_wait) {
> > - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> > - msleep(10);
> > + while ((swsusp_resume_device =
> > + name_to_dev_t(resume_file)) == 0)
> > + msleep(20);
>
> here too.
Thanks Joe!
I'm happy to make whatever change is best. I just ran into one
checkpatch warning around a printk I indented and figured I'd try to get
them all if I could.
The delays in question didn't appear timing critical as both are looping
waiting for device discovery to complete. They're only enabled when using
the resumewait command line parameter.
Is this an incorrect checkpatch warning? The message from checkpatch
implies using msleep for smaller values can be misleading.
WARNING: msleep < 20ms can sleep for up to 20ms; see
Documentation/timers/timers-howto.txt
+ msleep(10);
From Documentation/timers/timers-howto.txt
SLEEPING FOR ~USECS OR SMALL MSECS ( 10us - 20ms):
* Use usleep_range
- Why not msleep for (1ms - 20ms)?
Explained originally here:
http://lkml.org/lkml/2007/8/3/250
msleep(1~20) may not do what the caller intends, and
will often sleep longer (~20 ms actual sleep for any
value given in the 1~20ms range). In many cases this
is not the desired behavior.
When I look at kernel/timers.c in my current kernel, I see msleep is
using msecs_to_jiffies + 1, and on my current platform this appears to
be ~20msec as the jiffies are 10ms.
Thanks,
Sebastian
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 22:05 ` Sebastian Capella
@ 2014-02-04 23:45 ` Joe Perches
0 siblings, 0 replies; 35+ messages in thread
From: Joe Perches @ 2014-02-04 23:45 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown, Rafael J. Wysocki
On Tue, 2014-02-04 at 14:05 -0800, Sebastian Capella wrote:
> Quoting Joe Perches (2014-02-04 13:21:02)
> > On Tue, 2014-02-04 at 12:43 -0800, Sebastian Capella wrote:
> > > Checkpatch reports several warnings in hibernate.c
> > > printk use removed, long lines wrapped, whitespace cleanup,
> > > extend short msleeps, while loops on two lines.
> > []
> > > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> > []
> > > @@ -765,7 +762,7 @@ static int software_resume(void)
> > > if (isdigit(resume_file[0]) && resume_wait) {
> > > int partno;
> > > while (!get_gendisk(swsusp_resume_device, &partno))
> > > - msleep(10);
> > > + msleep(20);
> >
> > What good is changing this from 10 to 20?
> >
> > > @@ -776,8 +773,9 @@ static int software_resume(void)
> > > wait_for_device_probe();
> > >
> > > if (resume_wait) {
> > > - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> > > - msleep(10);
> > > + while ((swsusp_resume_device =
> > > + name_to_dev_t(resume_file)) == 0)
> > > + msleep(20);
> >
> > here too.
>
> Thanks Joe!
>
> I'm happy to make whatever change is best. I just ran into one
> checkpatch warning around a printk I indented and figured I'd try to get
> them all if I could.
Shutting up checkpatch for the sake of shutting of
checkpatch is sometimes not the right thing to do.
> The delays in question didn't appear timing critical as both are looping
> waiting for device discovery to complete. They're only enabled when using
> the resumewait command line parameter.
Any time it happens faster doesn't hurt and
can therefore could resume faster no?
> Is this an incorrect checkpatch warning? The message from checkpatch
> implies using msleep for smaller values can be misleading.
That's true, but it doesn't mean it's required
to change the code.
> - Why not msleep for (1ms - 20ms)?
> Explained originally here:
> http://lkml.org/lkml/2007/8/3/250
> msleep(1~20) may not do what the caller intends, and
> will often sleep longer (~20 ms actual sleep for any
> value given in the 1~20ms range). In many cases this
> is not the desired behavior.
>
> When I look at kernel/timers.c in my current kernel, I see msleep is
> using msecs_to_jiffies + 1, and on my current platform this appears to
> be ~20msec as the jiffies are 10ms.
And on platforms where HZ is 1000, it's
still slightly faster.
I'd just leave it alone.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-04 23:45 ` Joe Perches
0 siblings, 0 replies; 35+ messages in thread
From: Joe Perches @ 2014-02-04 23:45 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown, Rafael J. Wysocki
On Tue, 2014-02-04 at 14:05 -0800, Sebastian Capella wrote:
> Quoting Joe Perches (2014-02-04 13:21:02)
> > On Tue, 2014-02-04 at 12:43 -0800, Sebastian Capella wrote:
> > > Checkpatch reports several warnings in hibernate.c
> > > printk use removed, long lines wrapped, whitespace cleanup,
> > > extend short msleeps, while loops on two lines.
> > []
> > > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> > []
> > > @@ -765,7 +762,7 @@ static int software_resume(void)
> > > if (isdigit(resume_file[0]) && resume_wait) {
> > > int partno;
> > > while (!get_gendisk(swsusp_resume_device, &partno))
> > > - msleep(10);
> > > + msleep(20);
> >
> > What good is changing this from 10 to 20?
> >
> > > @@ -776,8 +773,9 @@ static int software_resume(void)
> > > wait_for_device_probe();
> > >
> > > if (resume_wait) {
> > > - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> > > - msleep(10);
> > > + while ((swsusp_resume_device =
> > > + name_to_dev_t(resume_file)) == 0)
> > > + msleep(20);
> >
> > here too.
>
> Thanks Joe!
>
> I'm happy to make whatever change is best. I just ran into one
> checkpatch warning around a printk I indented and figured I'd try to get
> them all if I could.
Shutting up checkpatch for the sake of shutting of
checkpatch is sometimes not the right thing to do.
> The delays in question didn't appear timing critical as both are looping
> waiting for device discovery to complete. They're only enabled when using
> the resumewait command line parameter.
Any time it happens faster doesn't hurt and
can therefore could resume faster no?
> Is this an incorrect checkpatch warning? The message from checkpatch
> implies using msleep for smaller values can be misleading.
That's true, but it doesn't mean it's required
to change the code.
> - Why not msleep for (1ms - 20ms)?
> Explained originally here:
> http://lkml.org/lkml/2007/8/3/250
> msleep(1~20) may not do what the caller intends, and
> will often sleep longer (~20 ms actual sleep for any
> value given in the 1~20ms range). In many cases this
> is not the desired behavior.
>
> When I look at kernel/timers.c in my current kernel, I see msleep is
> using msecs_to_jiffies + 1, and on my current platform this appears to
> be ~20msec as the jiffies are 10ms.
And on platforms where HZ is 1000, it's
still slightly faster.
I'd just leave it alone.
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 20:43 ` Sebastian Capella
@ 2014-02-04 21:36 ` Rafael J. Wysocki
-1 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-04 21:36 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 12:43:50 PM Sebastian Capella wrote:
> Checkpatch reports several warnings in hibernate.c
> printk use removed, long lines wrapped, whitespace cleanup,
> extend short msleeps, while loops on two lines.
Well, this isn't a trivial patch.
> Signed-off-by: Sebastian Capella <sebastian.capella@linaro.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> ---
> kernel/power/hibernate.c | 62 ++++++++++++++++++++++++----------------------
> 1 file changed, 32 insertions(+), 30 deletions(-)
>
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index 0121dab..cd1e30c 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -94,7 +94,7 @@ EXPORT_SYMBOL(system_entering_hibernation);
> #ifdef CONFIG_PM_DEBUG
> static void hibernation_debug_sleep(void)
> {
> - printk(KERN_INFO "hibernation debug: Waiting for 5 seconds.\n");
> + pr_info("hibernation debug: Waiting for 5 seconds.\n");
> mdelay(5000);
> }
>
> @@ -239,7 +239,7 @@ void swsusp_show_speed(struct timeval *start, struct timeval *stop,
> centisecs = 1; /* avoid div-by-zero */
> k = nr_pages * (PAGE_SIZE / 1024);
> kps = (k * 100) / centisecs;
> - printk(KERN_INFO "PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
> + pr_info("PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
> msg, k,
> centisecs / 100, centisecs % 100,
> kps / 1000, (kps % 1000) / 10);
> @@ -260,8 +260,7 @@ static int create_image(int platform_mode)
>
> error = dpm_suspend_end(PMSG_FREEZE);
> if (error) {
> - printk(KERN_ERR "PM: Some devices failed to power down, "
> - "aborting hibernation\n");
> + pr_err("PM: Some devices failed to power down, aborting hibernation\n");
> return error;
> }
>
> @@ -277,8 +276,7 @@ static int create_image(int platform_mode)
>
> error = syscore_suspend();
> if (error) {
> - printk(KERN_ERR "PM: Some system devices failed to power down, "
> - "aborting hibernation\n");
> + pr_err("PM: Some system devices failed to power down, aborting hibernation\n");
> goto Enable_irqs;
> }
>
> @@ -289,8 +287,7 @@ static int create_image(int platform_mode)
> save_processor_state();
> error = swsusp_arch_suspend();
> if (error)
> - printk(KERN_ERR "PM: Error %d creating hibernation image\n",
> - error);
> + pr_err("PM: Error %d creating hibernation image\n", error);
> /* Restore control flow magically appears here */
> restore_processor_state();
> if (!in_suspend) {
> @@ -413,8 +410,7 @@ static int resume_target_kernel(bool platform_mode)
>
> error = dpm_suspend_end(PMSG_QUIESCE);
> if (error) {
> - printk(KERN_ERR "PM: Some devices failed to power down, "
> - "aborting resume\n");
> + pr_err("PM: Some devices failed to power down, aborting resume\n");
> return error;
> }
>
> @@ -550,7 +546,8 @@ int hibernation_platform_enter(void)
>
> hibernation_ops->enter();
> /* We should never get here */
> - while (1);
> + while (1)
> + ;
Please remove this change from the patch. I don't care about checkpatch
complaining here.
>
> Power_up:
> syscore_resume();
> @@ -611,8 +608,7 @@ static void power_down(void)
> */
> error = swsusp_unmark();
> if (error)
> - printk(KERN_ERR "PM: Swap will be unusable! "
> - "Try swapon -a.\n");
> + pr_err("PM: Swap will be unusable! Try swapon -a.\n");
> return;
> #endif
> }
> @@ -621,8 +617,9 @@ static void power_down(void)
> * Valid image is on the disk, if we continue we risk serious data
> * corruption after resume.
> */
> - printk(KERN_CRIT "PM: Please power down manually\n");
> - while(1);
> + pr_crit("PM: Please power down manually\n");
> + while (1)
> + ;
Same here.
> }
>
> /**
> @@ -644,9 +641,9 @@ int hibernate(void)
> if (error)
> goto Exit;
>
> - printk(KERN_INFO "PM: Syncing filesystems ... ");
> + pr_info("PM: Syncing filesystems ... ");
> sys_sync();
> - printk("done.\n");
> + pr_cont("done.\n");
>
> error = freeze_processes();
> if (error)
> @@ -670,7 +667,7 @@ int hibernate(void)
> if (nocompress)
> flags |= SF_NOCOMPRESS_MODE;
> else
> - flags |= SF_CRC32_MODE;
> + flags |= SF_CRC32_MODE;
>
> pr_debug("PM: writing image.\n");
> error = swsusp_write(flags);
> @@ -750,7 +747,7 @@ static int software_resume(void)
> pr_debug("PM: Checking hibernation image partition %s\n", resume_file);
>
> if (resume_delay) {
> - printk(KERN_INFO "Waiting %dsec before reading resume device...\n",
> + pr_info("Waiting %dsec before reading resume device...\n",
> resume_delay);
> ssleep(resume_delay);
> }
> @@ -765,7 +762,7 @@ static int software_resume(void)
> if (isdigit(resume_file[0]) && resume_wait) {
> int partno;
> while (!get_gendisk(swsusp_resume_device, &partno))
> - msleep(10);
> + msleep(20);
That's the reason why it is not trivial.
First, the change being made doesn't belong in this patch.
Second, what's the problem with the original value?
> }
>
> if (!swsusp_resume_device) {
> @@ -776,8 +773,9 @@ static int software_resume(void)
> wait_for_device_probe();
>
> if (resume_wait) {
> - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> - msleep(10);
> + while ((swsusp_resume_device =
> + name_to_dev_t(resume_file)) == 0)
> + msleep(20);
And here?
> async_synchronize_full();
> }
>
> @@ -826,7 +824,7 @@ static int software_resume(void)
> if (!error)
> hibernation_restore(flags & SF_PLATFORM_MODE);
>
> - printk(KERN_ERR "PM: Failed to load hibernation image, recovering.\n");
> + pr_err("PM: Failed to load hibernation image, recovering.\n");
> swsusp_free();
> free_basic_memory_bitmaps();
> Thaw:
> @@ -965,7 +963,7 @@ power_attr(disk);
> static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
> char *buf)
> {
> - return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
> + return sprintf(buf, "%d:%d\n", MAJOR(swsusp_resume_device),
> MINOR(swsusp_resume_device));
> }
>
> @@ -986,7 +984,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
> lock_system_sleep();
> swsusp_resume_device = res;
> unlock_system_sleep();
> - printk(KERN_INFO "PM: Starting manual resume from disk\n");
> + pr_info("PM: Starting manual resume from disk\n");
> noresume = 0;
> software_resume();
> ret = n;
> @@ -996,13 +994,15 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
>
> power_attr(resume);
>
> -static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
> +static ssize_t image_size_show(struct kobject *kobj,
> + struct kobj_attribute *attr,
> char *buf)
Why can't you leave the code as is here?
> {
> return sprintf(buf, "%lu\n", image_size);
> }
>
> -static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
> +static ssize_t image_size_store(struct kobject *kobj,
> + struct kobj_attribute *attr,
> const char *buf, size_t n)
And here?
> {
> unsigned long size;
> @@ -1039,7 +1039,7 @@ static ssize_t reserved_size_store(struct kobject *kobj,
>
> power_attr(reserved_size);
>
> -static struct attribute * g[] = {
> +static struct attribute *g[] = {
> &disk_attr.attr,
> &resume_attr.attr,
> &image_size_attr.attr,
> @@ -1066,7 +1066,7 @@ static int __init resume_setup(char *str)
> if (noresume)
> return 1;
>
> - strncpy( resume_file, str, 255 );
> + strncpy(resume_file, str, 255);
> return 1;
> }
>
> @@ -1106,7 +1106,9 @@ static int __init resumewait_setup(char *str)
>
> static int __init resumedelay_setup(char *str)
> {
> - resume_delay = simple_strtoul(str, NULL, 0);
> + int ret = kstrtoint(str, 0, &resume_delay);
> + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> + (void)ret;
And that's not a trivial change surely?
And why didn't you do (void)kstrtoint(str, 0, &resume_delay); instead?
> return 1;
> }
>
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-04 21:36 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-04 21:36 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 12:43:50 PM Sebastian Capella wrote:
> Checkpatch reports several warnings in hibernate.c
> printk use removed, long lines wrapped, whitespace cleanup,
> extend short msleeps, while loops on two lines.
Well, this isn't a trivial patch.
> Signed-off-by: Sebastian Capella <sebastian.capella@linaro.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> ---
> kernel/power/hibernate.c | 62 ++++++++++++++++++++++++----------------------
> 1 file changed, 32 insertions(+), 30 deletions(-)
>
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index 0121dab..cd1e30c 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -94,7 +94,7 @@ EXPORT_SYMBOL(system_entering_hibernation);
> #ifdef CONFIG_PM_DEBUG
> static void hibernation_debug_sleep(void)
> {
> - printk(KERN_INFO "hibernation debug: Waiting for 5 seconds.\n");
> + pr_info("hibernation debug: Waiting for 5 seconds.\n");
> mdelay(5000);
> }
>
> @@ -239,7 +239,7 @@ void swsusp_show_speed(struct timeval *start, struct timeval *stop,
> centisecs = 1; /* avoid div-by-zero */
> k = nr_pages * (PAGE_SIZE / 1024);
> kps = (k * 100) / centisecs;
> - printk(KERN_INFO "PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
> + pr_info("PM: %s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n",
> msg, k,
> centisecs / 100, centisecs % 100,
> kps / 1000, (kps % 1000) / 10);
> @@ -260,8 +260,7 @@ static int create_image(int platform_mode)
>
> error = dpm_suspend_end(PMSG_FREEZE);
> if (error) {
> - printk(KERN_ERR "PM: Some devices failed to power down, "
> - "aborting hibernation\n");
> + pr_err("PM: Some devices failed to power down, aborting hibernation\n");
> return error;
> }
>
> @@ -277,8 +276,7 @@ static int create_image(int platform_mode)
>
> error = syscore_suspend();
> if (error) {
> - printk(KERN_ERR "PM: Some system devices failed to power down, "
> - "aborting hibernation\n");
> + pr_err("PM: Some system devices failed to power down, aborting hibernation\n");
> goto Enable_irqs;
> }
>
> @@ -289,8 +287,7 @@ static int create_image(int platform_mode)
> save_processor_state();
> error = swsusp_arch_suspend();
> if (error)
> - printk(KERN_ERR "PM: Error %d creating hibernation image\n",
> - error);
> + pr_err("PM: Error %d creating hibernation image\n", error);
> /* Restore control flow magically appears here */
> restore_processor_state();
> if (!in_suspend) {
> @@ -413,8 +410,7 @@ static int resume_target_kernel(bool platform_mode)
>
> error = dpm_suspend_end(PMSG_QUIESCE);
> if (error) {
> - printk(KERN_ERR "PM: Some devices failed to power down, "
> - "aborting resume\n");
> + pr_err("PM: Some devices failed to power down, aborting resume\n");
> return error;
> }
>
> @@ -550,7 +546,8 @@ int hibernation_platform_enter(void)
>
> hibernation_ops->enter();
> /* We should never get here */
> - while (1);
> + while (1)
> + ;
Please remove this change from the patch. I don't care about checkpatch
complaining here.
>
> Power_up:
> syscore_resume();
> @@ -611,8 +608,7 @@ static void power_down(void)
> */
> error = swsusp_unmark();
> if (error)
> - printk(KERN_ERR "PM: Swap will be unusable! "
> - "Try swapon -a.\n");
> + pr_err("PM: Swap will be unusable! Try swapon -a.\n");
> return;
> #endif
> }
> @@ -621,8 +617,9 @@ static void power_down(void)
> * Valid image is on the disk, if we continue we risk serious data
> * corruption after resume.
> */
> - printk(KERN_CRIT "PM: Please power down manually\n");
> - while(1);
> + pr_crit("PM: Please power down manually\n");
> + while (1)
> + ;
Same here.
> }
>
> /**
> @@ -644,9 +641,9 @@ int hibernate(void)
> if (error)
> goto Exit;
>
> - printk(KERN_INFO "PM: Syncing filesystems ... ");
> + pr_info("PM: Syncing filesystems ... ");
> sys_sync();
> - printk("done.\n");
> + pr_cont("done.\n");
>
> error = freeze_processes();
> if (error)
> @@ -670,7 +667,7 @@ int hibernate(void)
> if (nocompress)
> flags |= SF_NOCOMPRESS_MODE;
> else
> - flags |= SF_CRC32_MODE;
> + flags |= SF_CRC32_MODE;
>
> pr_debug("PM: writing image.\n");
> error = swsusp_write(flags);
> @@ -750,7 +747,7 @@ static int software_resume(void)
> pr_debug("PM: Checking hibernation image partition %s\n", resume_file);
>
> if (resume_delay) {
> - printk(KERN_INFO "Waiting %dsec before reading resume device...\n",
> + pr_info("Waiting %dsec before reading resume device...\n",
> resume_delay);
> ssleep(resume_delay);
> }
> @@ -765,7 +762,7 @@ static int software_resume(void)
> if (isdigit(resume_file[0]) && resume_wait) {
> int partno;
> while (!get_gendisk(swsusp_resume_device, &partno))
> - msleep(10);
> + msleep(20);
That's the reason why it is not trivial.
First, the change being made doesn't belong in this patch.
Second, what's the problem with the original value?
> }
>
> if (!swsusp_resume_device) {
> @@ -776,8 +773,9 @@ static int software_resume(void)
> wait_for_device_probe();
>
> if (resume_wait) {
> - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0)
> - msleep(10);
> + while ((swsusp_resume_device =
> + name_to_dev_t(resume_file)) == 0)
> + msleep(20);
And here?
> async_synchronize_full();
> }
>
> @@ -826,7 +824,7 @@ static int software_resume(void)
> if (!error)
> hibernation_restore(flags & SF_PLATFORM_MODE);
>
> - printk(KERN_ERR "PM: Failed to load hibernation image, recovering.\n");
> + pr_err("PM: Failed to load hibernation image, recovering.\n");
> swsusp_free();
> free_basic_memory_bitmaps();
> Thaw:
> @@ -965,7 +963,7 @@ power_attr(disk);
> static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
> char *buf)
> {
> - return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
> + return sprintf(buf, "%d:%d\n", MAJOR(swsusp_resume_device),
> MINOR(swsusp_resume_device));
> }
>
> @@ -986,7 +984,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
> lock_system_sleep();
> swsusp_resume_device = res;
> unlock_system_sleep();
> - printk(KERN_INFO "PM: Starting manual resume from disk\n");
> + pr_info("PM: Starting manual resume from disk\n");
> noresume = 0;
> software_resume();
> ret = n;
> @@ -996,13 +994,15 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
>
> power_attr(resume);
>
> -static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
> +static ssize_t image_size_show(struct kobject *kobj,
> + struct kobj_attribute *attr,
> char *buf)
Why can't you leave the code as is here?
> {
> return sprintf(buf, "%lu\n", image_size);
> }
>
> -static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
> +static ssize_t image_size_store(struct kobject *kobj,
> + struct kobj_attribute *attr,
> const char *buf, size_t n)
And here?
> {
> unsigned long size;
> @@ -1039,7 +1039,7 @@ static ssize_t reserved_size_store(struct kobject *kobj,
>
> power_attr(reserved_size);
>
> -static struct attribute * g[] = {
> +static struct attribute *g[] = {
> &disk_attr.attr,
> &resume_attr.attr,
> &image_size_attr.attr,
> @@ -1066,7 +1066,7 @@ static int __init resume_setup(char *str)
> if (noresume)
> return 1;
>
> - strncpy( resume_file, str, 255 );
> + strncpy(resume_file, str, 255);
> return 1;
> }
>
> @@ -1106,7 +1106,9 @@ static int __init resumewait_setup(char *str)
>
> static int __init resumedelay_setup(char *str)
> {
> - resume_delay = simple_strtoul(str, NULL, 0);
> + int ret = kstrtoint(str, 0, &resume_delay);
> + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> + (void)ret;
And that's not a trivial change surely?
And why didn't you do (void)kstrtoint(str, 0, &resume_delay); instead?
> return 1;
> }
>
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 21:36 ` Rafael J. Wysocki
(?)
@ 2014-02-04 22:37 ` Sebastian Capella
2014-02-04 23:22 ` Sebastian Capella
2014-02-04 23:59 ` Rafael J. Wysocki
-1 siblings, 2 replies; 35+ messages in thread
From: Sebastian Capella @ 2014-02-04 22:37 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> Well, this isn't a trivial patch.
I'll remove the trivial, thanks!
Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> On Tuesday, February 04, 2014 12:43:50 PM Sebastian Capella wrote:
> > + while (1)
> > + ;
> Please remove this change from the patch. I don't care about checkpatch
> complaining here.
> > + while (1)
> > + ;
> Same here.
Will do, thanks!
> > @@ -765,7 +762,7 @@ static int software_resume(void)
> > if (isdigit(resume_file[0]) && resume_wait) {
> > int partno;
> > while (!get_gendisk(swsusp_resume_device, &partno))
> > - msleep(10);
> > + msleep(20);
>
> That's the reason why it is not trivial.
>
> First, the change being made doesn't belong in this patch.
Thanks I'll separate it if it remains.
> Second, what's the problem with the original value?
The warning from checkpatch implies that it's misleading to
msleep < 20ms since msleep is using msec_to_jiffies + 1 for
the duration. In any case, this is polling for devices discovery to
complete. It is used when resumewait is specified on the command
line telling hibernate to wait for the resume device to appear.
> > -static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
> > +static ssize_t image_size_show(struct kobject *kobj,
> > + struct kobj_attribute *attr,
> Why can't you leave the code as is here?
> > -static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
> > +static ssize_t image_size_store(struct kobject *kobj,
> > + struct kobj_attribute *attr,
> And here?
Purely long line cleanup. (>80 colunms)
> > static int __init resumedelay_setup(char *str)
> > {
> > - resume_delay = simple_strtoul(str, NULL, 0);
> > + int ret = kstrtoint(str, 0, &resume_delay);
> > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > + (void)ret;
>
> And that's not a trivial change surely?
I'll include this and the msleep as a separate, non-trivial checkpatch
cleanup patch if the changes remain after this discussion.
>
> And why didn't you do (void)kstrtoint(str, 0, &resume_delay); instead?
Better thanks!
Sebastian
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 22:37 ` Sebastian Capella
@ 2014-02-04 23:22 ` Sebastian Capella
2014-02-05 0:03 ` Rafael J. Wysocki
2014-02-04 23:59 ` Rafael J. Wysocki
1 sibling, 1 reply; 35+ messages in thread
From: Sebastian Capella @ 2014-02-04 23:22 UTC (permalink / raw)
To: Sebastian Capella, Rafael J. Wysocki
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
Quoting Sebastian Capella (2014-02-04 14:37:33)
> Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > static int __init resumedelay_setup(char *str)
> > > {
> > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > + (void)ret;
One unintended consequence of this change is that it'll now accept a
negative integer parameter. I'll rework this to have the same behavior
as before.
BTW, one question, is the __must_check really needed on kstrtoint?
Wouldn't it be acceptable to rely on kstrtoint to not update resume_delay
if it's unable to parse an integer out of the string? Couldn't that be
a sufficient effect without requiring checking the return?
Thanks,
Sebastian
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 23:22 ` Sebastian Capella
@ 2014-02-05 0:03 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-05 0:03 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> Quoting Sebastian Capella (2014-02-04 14:37:33)
> > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > static int __init resumedelay_setup(char *str)
> > > > {
> > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > + (void)ret;
>
> One unintended consequence of this change is that it'll now accept a
> negative integer parameter.
Well, what about using kstrtouint(), then?
> I'll rework this to have the same behavior as before.
>
> BTW, one question, is the __must_check really needed on kstrtoint?
> Wouldn't it be acceptable to rely on kstrtoint to not update resume_delay
> if it's unable to parse an integer out of the string? Couldn't that be
> a sufficient effect without requiring checking the return?
Well, kstrtoint() is used in some security-sensitive places AFAICS, so it
really is better to check its return value in general. The __must_check
reminds people about that.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-05 0:03 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-05 0:03 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> Quoting Sebastian Capella (2014-02-04 14:37:33)
> > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > static int __init resumedelay_setup(char *str)
> > > > {
> > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > + (void)ret;
>
> One unintended consequence of this change is that it'll now accept a
> negative integer parameter.
Well, what about using kstrtouint(), then?
> I'll rework this to have the same behavior as before.
>
> BTW, one question, is the __must_check really needed on kstrtoint?
> Wouldn't it be acceptable to rely on kstrtoint to not update resume_delay
> if it's unable to parse an integer out of the string? Couldn't that be
> a sufficient effect without requiring checking the return?
Well, kstrtoint() is used in some security-sensitive places AFAICS, so it
really is better to check its return value in general. The __must_check
reminds people about that.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-05 0:03 ` Rafael J. Wysocki
(?)
@ 2014-02-05 0:06 ` Sebastian Capella
2014-02-05 0:28 ` Rafael J. Wysocki
-1 siblings, 1 reply; 35+ messages in thread
From: Sebastian Capella @ 2014-02-05 0:06 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
Quoting Rafael J. Wysocki (2014-02-04 16:03:29)
> On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> > Quoting Sebastian Capella (2014-02-04 14:37:33)
> > > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > > static int __init resumedelay_setup(char *str)
> > > > > {
> > > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > > + (void)ret;
> >
> > One unintended consequence of this change is that it'll now accept a
> > negative integer parameter.
>
> Well, what about using kstrtouint(), then?
I was thinking of doing something like:
int delay, res;
res = kstrtoint(str, 0, &delay);
if (!res && delay >= 0)
resume_delay = delay;
return 1;
> Well, kstrtoint() is used in some security-sensitive places AFAICS, so it
> really is better to check its return value in general. The __must_check
> reminds people about that.
Thanks!
Sebastian
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-05 0:06 ` Sebastian Capella
@ 2014-02-05 0:28 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-05 0:28 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 04:06:42 PM Sebastian Capella wrote:
> Quoting Rafael J. Wysocki (2014-02-04 16:03:29)
> > On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> > > Quoting Sebastian Capella (2014-02-04 14:37:33)
> > > > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > > > static int __init resumedelay_setup(char *str)
> > > > > > {
> > > > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > > > + (void)ret;
> > >
> > > One unintended consequence of this change is that it'll now accept a
> > > negative integer parameter.
> >
> > Well, what about using kstrtouint(), then?
> I was thinking of doing something like:
>
> int delay, res;
> res = kstrtoint(str, 0, &delay);
> if (!res && delay >= 0)
> resume_delay = delay;
> return 1;
It uses simple_strtoul() for a reason. You can change the type of resume_delay
to match, but the basic question is:
Why exactly do you want to change that thing?
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-05 0:28 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-05 0:28 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 04:06:42 PM Sebastian Capella wrote:
> Quoting Rafael J. Wysocki (2014-02-04 16:03:29)
> > On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> > > Quoting Sebastian Capella (2014-02-04 14:37:33)
> > > > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > > > static int __init resumedelay_setup(char *str)
> > > > > > {
> > > > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > > > + (void)ret;
> > >
> > > One unintended consequence of this change is that it'll now accept a
> > > negative integer parameter.
> >
> > Well, what about using kstrtouint(), then?
> I was thinking of doing something like:
>
> int delay, res;
> res = kstrtoint(str, 0, &delay);
> if (!res && delay >= 0)
> resume_delay = delay;
> return 1;
It uses simple_strtoul() for a reason. You can change the type of resume_delay
to match, but the basic question is:
Why exactly do you want to change that thing?
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-05 0:28 ` Rafael J. Wysocki
(?)
@ 2014-02-05 0:24 ` Sebastian Capella
2014-02-05 11:07 ` Rafael J. Wysocki
-1 siblings, 1 reply; 35+ messages in thread
From: Sebastian Capella @ 2014-02-05 0:24 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
Quoting Rafael J. Wysocki (2014-02-04 16:28:13)
> On Tuesday, February 04, 2014 04:06:42 PM Sebastian Capella wrote:
> > Quoting Rafael J. Wysocki (2014-02-04 16:03:29)
> > > On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> > > > Quoting Sebastian Capella (2014-02-04 14:37:33)
> > > > > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > > > > static int __init resumedelay_setup(char *str)
> > > > > > > {
> > > > > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > > > > + (void)ret;
> > > >
> > > > One unintended consequence of this change is that it'll now accept a
> > > > negative integer parameter.
> > >
> > > Well, what about using kstrtouint(), then?
> > I was thinking of doing something like:
> >
> > int delay, res;
> > res = kstrtoint(str, 0, &delay);
> > if (!res && delay >= 0)
> > resume_delay = delay;
> > return 1;
>
> It uses simple_strtoul() for a reason. You can change the type of resume_delay
> to match, but the basic question is:
>
> Why exactly do you want to change that thing?
This entire patch is a result of a single checkpatch warning from a printk
that I indented.
I was hoping to be helpful by removing all of the warnings from this
file, since I was going to have a separate cleanup patch for the printk.
I can see this is not a good direction.
Would it be better also to leave the file's printks as they were and drop
the cleanup patch completely?
Thanks,
Sebastian
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-05 0:24 ` Sebastian Capella
@ 2014-02-05 11:07 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-05 11:07 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 04:24:13 PM Sebastian Capella wrote:
> Quoting Rafael J. Wysocki (2014-02-04 16:28:13)
> > On Tuesday, February 04, 2014 04:06:42 PM Sebastian Capella wrote:
> > > Quoting Rafael J. Wysocki (2014-02-04 16:03:29)
> > > > On Tuesday, February 04, 2014 03:22:22 PM Sebastian Capella wrote:
> > > > > Quoting Sebastian Capella (2014-02-04 14:37:33)
> > > > > > Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > > > > > > > static int __init resumedelay_setup(char *str)
> > > > > > > > {
> > > > > > > > - resume_delay = simple_strtoul(str, NULL, 0);
> > > > > > > > + int ret = kstrtoint(str, 0, &resume_delay);
> > > > > > > > + /* mask must_check warn; on failure, leaves resume_delay unchanged */
> > > > > > > > + (void)ret;
> > > > >
> > > > > One unintended consequence of this change is that it'll now accept a
> > > > > negative integer parameter.
> > > >
> > > > Well, what about using kstrtouint(), then?
> > > I was thinking of doing something like:
> > >
> > > int delay, res;
> > > res = kstrtoint(str, 0, &delay);
> > > if (!res && delay >= 0)
> > > resume_delay = delay;
> > > return 1;
> >
> > It uses simple_strtoul() for a reason. You can change the type of resume_delay
> > to match, but the basic question is:
> >
> > Why exactly do you want to change that thing?
>
> This entire patch is a result of a single checkpatch warning from a printk
> that I indented.
>
> I was hoping to be helpful by removing all of the warnings from this
> file, since I was going to have a separate cleanup patch for the printk.
>
> I can see this is not a good direction.
>
> Would it be better also to leave the file's printks as they were and drop
> the cleanup patch completely?
Well, I had considered changing them to pr_something, but decided that it
wasn't worth the effort. Quite frankly, I'd leave the code as is. :-)
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 35+ messages in thread
* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
2014-02-04 22:37 ` Sebastian Capella
@ 2014-02-04 23:59 ` Rafael J. Wysocki
2014-02-04 23:59 ` Rafael J. Wysocki
1 sibling, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-04 23:59 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 02:37:33 PM Sebastian Capella wrote:
> Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > Well, this isn't a trivial patch.
>
> I'll remove the trivial, thanks!
>
> Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > On Tuesday, February 04, 2014 12:43:50 PM Sebastian Capella wrote:
> > > + while (1)
> > > + ;
> > Please remove this change from the patch. I don't care about checkpatch
> > complaining here.
> > > + while (1)
> > > + ;
> > Same here.
>
> Will do, thanks!
>
> > > @@ -765,7 +762,7 @@ static int software_resume(void)
> > > if (isdigit(resume_file[0]) && resume_wait) {
> > > int partno;
> > > while (!get_gendisk(swsusp_resume_device, &partno))
> > > - msleep(10);
> > > + msleep(20);
> >
> > That's the reason why it is not trivial.
> >
> > First, the change being made doesn't belong in this patch.
>
> Thanks I'll separate it if it remains.
>
> > Second, what's the problem with the original value?
>
> The warning from checkpatch implies that it's misleading to
> msleep < 20ms since msleep is using msec_to_jiffies + 1 for
> the duration. In any case, this is polling for devices discovery to
> complete. It is used when resumewait is specified on the command
> line telling hibernate to wait for the resume device to appear.
What checkpatch is saying is about *new* code, not the existing one.
You need to have a *reason* to change the way the existing code works
and the above explanation doesn't sound like a good one to me in this
particular case.
> > > -static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
> > > +static ssize_t image_size_show(struct kobject *kobj,
> > > + struct kobj_attribute *attr,
> > Why can't you leave the code as is here?
> > > -static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
> > > +static ssize_t image_size_store(struct kobject *kobj,
> > > + struct kobj_attribute *attr,
> > And here?
>
> Purely long line cleanup. (>80 colunms)
Please don't do any >80 columns cleanups in any patches you want me to apply.
Seriously. This is irritating and unuseful.
And if you don't want checkpatch to complain about that, please send a patch
to modify checkpatch accordingly.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 35+ messages in thread* Re: [PATCH v7 2/3] trivial: PM / Hibernate: clean up checkpatch in hibernate.c
@ 2014-02-04 23:59 ` Rafael J. Wysocki
0 siblings, 0 replies; 35+ messages in thread
From: Rafael J. Wysocki @ 2014-02-04 23:59 UTC (permalink / raw)
To: Sebastian Capella
Cc: linux-kernel, linux-mm, linux-pm, linaro-kernel, patches,
Pavel Machek, Len Brown
On Tuesday, February 04, 2014 02:37:33 PM Sebastian Capella wrote:
> Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > Well, this isn't a trivial patch.
>
> I'll remove the trivial, thanks!
>
> Quoting Rafael J. Wysocki (2014-02-04 13:36:29)
> > On Tuesday, February 04, 2014 12:43:50 PM Sebastian Capella wrote:
> > > + while (1)
> > > + ;
> > Please remove this change from the patch. I don't care about checkpatch
> > complaining here.
> > > + while (1)
> > > + ;
> > Same here.
>
> Will do, thanks!
>
> > > @@ -765,7 +762,7 @@ static int software_resume(void)
> > > if (isdigit(resume_file[0]) && resume_wait) {
> > > int partno;
> > > while (!get_gendisk(swsusp_resume_device, &partno))
> > > - msleep(10);
> > > + msleep(20);
> >
> > That's the reason why it is not trivial.
> >
> > First, the change being made doesn't belong in this patch.
>
> Thanks I'll separate it if it remains.
>
> > Second, what's the problem with the original value?
>
> The warning from checkpatch implies that it's misleading to
> msleep < 20ms since msleep is using msec_to_jiffies + 1 for
> the duration. In any case, this is polling for devices discovery to
> complete. It is used when resumewait is specified on the command
> line telling hibernate to wait for the resume device to appear.
What checkpatch is saying is about *new* code, not the existing one.
You need to have a *reason* to change the way the existing code works
and the above explanation doesn't sound like a good one to me in this
particular case.
> > > -static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
> > > +static ssize_t image_size_show(struct kobject *kobj,
> > > + struct kobj_attribute *attr,
> > Why can't you leave the code as is here?
> > > -static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
> > > +static ssize_t image_size_store(struct kobject *kobj,
> > > + struct kobj_attribute *attr,
> > And here?
>
> Purely long line cleanup. (>80 colunms)
Please don't do any >80 columns cleanups in any patches you want me to apply.
Seriously. This is irritating and unuseful.
And if you don't want checkpatch to complain about that, please send a patch
to modify checkpatch accordingly.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 35+ messages in thread