RTC: fix double free in rtc_register_device() error path
PATCH 1/4 RTC: fix double free in rtc_register_device() error path
Commit 59cca865f21e9e7beab73fcf79ba4eb776a4c228 correctly noted that naked kfree() should not be used after failed device_register() call, however, while it added the needed put_device() it forgot to remove the original kfree() causing double-free.
--- drivers/rtc/class.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/rtc/class.c +2 -4
@@ -234,8 +234,9 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, err =device_register (&rtc->dev);if (err) { +/* This will free both memory and the ID */ put_device (&rtc->dev); - goto exit_kfree; + goto exit; }rtc_dev_add_device (rtc);
@@ -247,9 +248,6 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,return rtc; -exit_kfree: -kfree (rtc); - exit_ida:ida_simple_remove (&rtc_ida, id);
Signature · 12 lines
2.4.3.573.g4eafbef -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH 2/4 RTC: remove unnecessary device_get() in rtc_device_unregister
Technically the address of rtc->dev can never be NULL, so get_device() can never fail. Also caller of rtc_device_unregister() supposed to be the owner of the device and thus have a valid reference. Therefore call to get_device() is not needed here.
--- drivers/rtc/class.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/rtc/class.c +12 -13
@@ -266,19 +266,18 @@ EXPORT_SYMBOL_GPL(rtc_device_register);*/ void rtc_device_unregister (struct rtc_device *rtc) { -if (get_device (&rtc->dev) !=NULL ) { -mutex_lock (&rtc->ops_lock); -/* remove innards of this RTC, then disable it, before -* letting any rtc_class_open() users access it again -*/ -rtc_sysfs_del_device (rtc); -rtc_dev_del_device (rtc); -rtc_proc_del_device (rtc); -device_unregister (&rtc->dev); - rtc->ops =NULL ; -mutex_unlock (&rtc->ops_lock); -put_device (&rtc->dev); - } +mutex_lock (&rtc->ops_lock); +/* +* Remove innards of this RTC, then disable it, before +* letting any rtc_class_open() users access it again +*/ +rtc_sysfs_del_device (rtc); +rtc_dev_del_device (rtc); +rtc_proc_del_device (rtc); +device_del (&rtc->dev); + rtc->ops =NULL ; +mutex_unlock (&rtc->ops_lock); +put_device (&rtc->dev); }EXPORT_SYMBOL_GPL (rtc_device_unregister);
Signature · 12 lines
2.4.3.573.g4eafbef -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH 3/4 RTC: properly manage lifetime of dev and cdev in rtc device
In reply to Dmitry Torokhovstruct rtc embeds both struct dev and struct cdev. Unfortunately character device structure may outlive the parent rtc structure unless we set it up as parent of character device so that it will stay pinned until character device is freed.
--- drivers/rtc/rtc-dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-dev.c +1 -0
@@ -477,6 +477,7 @@ void rtc_dev_prepare(struct rtc_device *rtc)cdev_init (&rtc->char_dev, &rtc_dev_fops); rtc->char_dev.owner = rtc->owner; + rtc->char_dev.kobj.parent = &rtc->dev.kobj; }void rtc_dev_add_device (struct rtc_device *rtc)
Signature · 12 lines
2.4.3.573.g4eafbef -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PATCH 4/4 RTC: switch to using is_visible() to control sysfs attributes
In reply to Dmitry TorokhovInstead of creating an attribute manually, after the device has been registered, let's rely on facilities provided by the attribute groups to control which attributes are visible and which are not. This allows to to create all needed attributes at once, at the same time that we register RTC class device.
--- drivers/rtc/class.c | 4 +-- drivers/rtc/rtc-core.h | 19 ++----------- drivers/rtc/rtc-sysfs.c | 75 +++++++++++++++++++++++++------------------------ 3 files changed, 42 insertions(+), 56 deletions(-)
drivers/rtc/class.c +1 -3
@@ -202,6 +202,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, rtc->max_user_freq =64 ; rtc->dev.parent = dev; rtc->dev.class = rtc_class; + rtc->dev.groups =rtc_get_dev_attribute_groups (); rtc->dev.release = rtc_device_release;mutex_init (&rtc->ops_lock);
@@ -240,7 +241,6 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, }rtc_dev_add_device (rtc); -rtc_sysfs_add_device (rtc);rtc_proc_add_device (rtc); dev_info(dev, "rtc core: registered %s as %s\n",
@@ -271,7 +271,6 @@ void rtc_device_unregister(struct rtc_device *rtc)* Remove innards of this RTC, then disable it, before * letting any rtc_class_open() users access it again */ -rtc_sysfs_del_device (rtc);rtc_dev_del_device (rtc);rtc_proc_del_device (rtc);device_del (&rtc->dev);
@@ -360,7 +359,6 @@ static int __init rtc_init(void) } rtc_class->pm =RTC_CLASS_DEV_PM_OPS ;rtc_dev_init (); -rtc_sysfs_init (rtc_class);return 0 ; }
drivers/rtc/rtc-core.h +3 -16
@@ -48,23 +48,10 @@ static inline void rtc_proc_del_device(struct rtc_device *rtc)#endif #ifdef CONFIG_RTC_INTF_SYSFS - -extern void __init rtc_sysfs_init (struct class *); -extern void rtc_sysfs_add_device (struct rtc_device *rtc); -extern void rtc_sysfs_del_device (struct rtc_device *rtc); - +const struct attribute_group **rtc_get_dev_attribute_groups (void );#else - -static inline void rtc_sysfs_init (struct class *rtc) -{ -} - -static inline void rtc_sysfs_add_device (struct rtc_device *rtc) +static inline const struct attribute_group **rtc_get_dev_attribute_groups (void ) { +return NULL ; } - -static inline void rtc_sysfs_del_device (struct rtc_device *rtc) -{ -} -#endif
drivers/rtc/rtc-sysfs.c +38 -37
110 lines not on this page · raw message
Signature · 12 lines
2.4.3.573.g4eafbef -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
Quoted 10 lines
Commit
59cca865f21e9e7beab73fcf79ba4eb776a4c228correctly noted that nakedkfree()should not be used after faileddevice_register()call, however, while it added the neededput_device()it forgot to remove the originalkfree()causing double-free.Cc Vasiliy Kulikov <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/class.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
I think it can be cc'ed stable (with fixes tag).
Best regards,
Krzysztof
Signature · 9 lines
-- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [rtc-linux] [PATCH 2/4] RTC: remove unnecessary device_get() in rtc_device_unregister
In reply to Dmitry Torokhov2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
Quoted 9 lines
Technically the address of
rtc->devcan never be NULL, soget_device()can never fail. Also caller ofrtc_device_unregister()supposed to be the owner of the device and thus have a valid reference. Therefore call toget_device()is not needed here.Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/class.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
Makes sense.
Best regards,
Krzysztof
Signature · 9 lines
-- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Quoted 6 lines · Krzysztof Kozlowski
2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
Quoted 5 lines
Commit
59cca865f21e9e7beab73fcf79ba4eb776a4c228correctly noted that nakedkfree()should not be used after faileddevice_register()call, however, while it added the neededput_device()it forgot to remove the originalkfree()causing double-free.
Quoted 7 lines
Quoted 5 lines
Cc Vasiliy Kulikov <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/class.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)I think it can be cc'ed stable (with fixes tag).
I considered that, but it does not happen on normally working systems. I'll leave it up to maintainers to annotate as they see fit.
Thanks.
Signature · 12 lines
Dmitry -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [rtc-linux] [PATCH 3/4] RTC: properly manage lifetime of dev and cdev in rtc device
In reply to Dmitry Torokhov2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
Quoted 9 lines
struct rtc embeds both struct dev and struct cdev. Unfortunately character device structure may outlive the parent rtc structure unless we set it up as parent of character device so that it will stay pinned until character device is freed.
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/rtc-dev.c | 1 + 1 file changed, 1 insertion(+)
Best regards,
Krzysztof
Signature · 9 lines
-- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [rtc-linux] [PATCH 4/4] RTC: switch to using is_visible() to control sysfs attributes
In reply to Dmitry Torokhov2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
Quoted 116 lines
Instead of creating an attribute manually, after the device has been registered, let's rely on facilities provided by the attribute groups to control which attributes are visible and which are not. This allows to to create all needed attributes at once, at the same time that we register RTC class device.
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/class.c | 4 +-- drivers/rtc/rtc-core.h | 19 ++----------- drivers/rtc/rtc-sysfs.c | 75 +++++++++++++++++++++++++------------------------ 3 files changed, 42 insertions(+), 56 deletions(-)drivers/rtc/class.c +1
-3@@ -202,6 +202,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, rtc->max_user_freq =64 ; rtc->dev.parent = dev; rtc->dev.class = rtc_class; + rtc->dev.groups =rtc_get_dev_attribute_groups (); rtc->dev.release = rtc_device_release;mutex_init (&rtc->ops_lock);@@ -240,7 +241,6 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, }rtc_dev_add_device (rtc); -rtc_sysfs_add_device (rtc);rtc_proc_add_device (rtc); dev_info(dev, "rtc core: registered %s as %s\n",@@ -271,7 +271,6 @@ void rtc_device_unregister(struct rtc_device *rtc)* Remove innards of this RTC, then disable it, before * letting any rtc_class_open() users access it again */ -rtc_sysfs_del_device (rtc);rtc_dev_del_device (rtc);rtc_proc_del_device (rtc);device_del (&rtc->dev);@@ -360,7 +359,6 @@ static int __init rtc_init(void) } rtc_class->pm =RTC_CLASS_DEV_PM_OPS ;rtc_dev_init (); -rtc_sysfs_init (rtc_class);return 0 ; }drivers/rtc/rtc-core.h +3
-16@@ -48,23 +48,10 @@ static inline void rtc_proc_del_device(struct rtc_device *rtc)#endif #ifdef CONFIG_RTC_INTF_SYSFS - -extern void __init rtc_sysfs_init (struct class *); -extern void rtc_sysfs_add_device (struct rtc_device *rtc); -extern void rtc_sysfs_del_device (struct rtc_device *rtc); - +const struct attribute_group **rtc_get_dev_attribute_groups (void );#else - -static inline void rtc_sysfs_init (struct class *rtc) -{ -} - -static inline void rtc_sysfs_add_device (struct rtc_device *rtc) +static inline const struct attribute_group **rtc_get_dev_attribute_groups (void ) { +return NULL ; } - -static inline void rtc_sysfs_del_device (struct rtc_device *rtc) -{ -} -#endif drivers/rtc/rtc-sysfs.c +2
-14@@ -122,20 +122,8 @@ hctosys_show(struct device *dev, struct device_attribute *attr, char *buf) }static DEVICE_ATTR_RO (hctosys); -static struct attribute *rtc_attrs[] = { - &dev_attr_name.attr, - &dev_attr_date.attr, - &dev_attr_time.attr, - &dev_attr_since_epoch.attr, - &dev_attr_max_user_freq.attr, - &dev_attr_hctosys.attr, -NULL , -}; -ATTRIBUTE_GROUPS (rtc); -static ssize_t -rtc_sysfs_show_wakealarm (struct device *dev,struct device_attribute *attr, -char *buf) +wakealarm_show (struct device *dev,struct device_attribute *attr,char *buf) {ssize_t retval;unsigned long alarm;@@ -159,7 +147,7 @@ rtc_sysfs_show_wakealarm(struct device *dev, struct device_attribute *attr, }static ssize_t -rtc_sysfs_set_wakealarm (struct device *dev,struct device_attribute *attr, +wakealarm_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t n) {ssize_t retval;
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 212
Quoted 6 lines
drivers/rtc/rtc-sysfs.c +1
-2@@ -221,45 +209,58 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, retval =rtc_set_alarm (rtc, &alm);return (retval <0 ) ? retval : n; } -static DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR, - rtc_sysfs_show_wakealarm, rtc_sysfs_set_wakealarm); +static DEVICE_ATTR_RW (wakealarm);
This and renaming of show/store functions look unrelated
Quoted 18 lines
drivers/rtc/rtc-sysfs.c +12
-1+static struct attribute *rtc_attrs[] = { + &dev_attr_name.attr, + &dev_attr_date.attr, + &dev_attr_time.attr, + &dev_attr_since_epoch.attr, + &dev_attr_max_user_freq.attr, + &dev_attr_hctosys.attr, + &dev_attr_wakealarm.attr, +NULL , +}; -/* The reason to trigger an alarm with no process watching it (via sysfs) +/* +* The reason to trigger an alarm with no process watching it (via sysfs) * is its side effect: waking from a system state like suspend-to-RAM or * suspend-to-disk. So: no attribute unless that side effect is possible. * (Userspace may disable that mechanism later.)
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 237
Quoted 10 lines
drivers/rtc/rtc-sysfs.c +3
-2*/ -static inline int rtc_does_wakealarm (struct rtc_device *rtc) +static bool rtc_does_wakealarm (struct rtc_device *rtc) {if (!device_can_wakeup (rtc->dev.parent)) -return 0 ; +return false; +return rtc->ops->set_alarm !=NULL ; }
This looks unrelated too and confuses me. Could you split such cleanup from main goal of the patch?
Best regards,
Krzysztof
Signature · 9 lines
-- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Quoted 10 lines · Dmitry Torokhov
Commit
59cca865f21e9e7beab73fcf79ba4eb776a4c228correctly noted that nakedkfree()should not be used after faileddevice_register()call, however, while it added the neededput_device()it forgot to remove the originalkfree()causing double-free.Cc Vasiliy Kulikov <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/class.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Applied after fixing the commit description in the commit log, thanks.
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Alexandre Belloni
AppliedRe: [PATCH 2/4] RTC: remove unnecessary device_get() in rtc_device_unregister
In reply to Dmitry TorokhovQuoted 9 lines · Dmitry Torokhov
Technically the address of
rtc->devcan never be NULL, soget_device()can never fail. Also caller ofrtc_device_unregister()supposed to be the owner of the device and thus have a valid reference. Therefore call toget_device()is not needed here.Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/class.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
Applied, thanks.
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Alexandre Belloni
AppliedRe: [PATCH 3/4] RTC: properly manage lifetime of dev and cdev in rtc device
In reply to Dmitry TorokhovQuoted 9 lines · Dmitry Torokhov
struct rtc embeds both struct dev and struct cdev. Unfortunately character device structure may outlive the parent rtc structure unless we set it up as parent of character device so that it will stay pinned until character device is freed.
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/rtc/rtc-dev.c | 1 + 1 file changed, 1 insertion(+)
Applied, thanks.
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [PATCH 4/4] RTC: switch to using is_visible() to control sysfs attributes
In reply to Dmitry TorokhovHi,
Seems mostly good, a few comments on top of Krzysztof's below:
Quoted 3 lines · Dmitry Torokhov
Instead of creating an attribute manually, after the device has been registered, let's rely on facilities provided by the attribute groups to control which attributes are visible and which are not. This allows to to
too many 'to' here --------------------------------------------------^
[...]
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 263
Quoted 2 lines
drivers/rtc/rtc-sysfs.c +1
-1-void __init rtc_sysfs_init (struct class *rtc_class) +const struct attribute_group **rtc_get_dev_attribute_groups (void )
That space is not properly placed ^, this should be:
const struct attribute_group **rtc_get_dev_attribute_groups(void)
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [rtc-linux] [PATCH 4/4] RTC: switch to using is_visible() to control sysfs attributes
In reply to Krzysztof Kozlowski(Krzysztof, be careful, Dmitry was not in copy of your maili, you should probably check your mailer config)
Quoted 17 lines · Krzysztof Kozlowski
2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 212
Quoted 13 lines
static
ssize_tdrivers/rtc/rtc-sysfs.c +2
-3-rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, +wakealarm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) { ssize_t retval;@@ -221,45 +209,58 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, retval =rtc_set_alarm (rtc, &alm);return (retval <0 ) ? retval : n; } -static DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR, - rtc_sysfs_show_wakealarm, rtc_sysfs_set_wakealarm); +static DEVICE_ATTR_RW (wakealarm);This and renaming of show/store functions look unrelated
I don't really mind that one but I would also prefer if it could be separated.
Quoted 23 lines
Quoted 23 lines
drivers/rtc/rtc-sysfs.c +13
-2+static struct attribute *rtc_attrs[] = { + &dev_attr_name.attr, + &dev_attr_date.attr, + &dev_attr_time.attr, + &dev_attr_since_epoch.attr, + &dev_attr_max_user_freq.attr, + &dev_attr_hctosys.attr, + &dev_attr_wakealarm.attr, +NULL , +}; -/* The reason to trigger an alarm with no process watching it (via sysfs) +/* +* The reason to trigger an alarm with no process watching it (via sysfs) * is its side effect: waking from a system state like suspend-to-RAM or * suspend-to-disk. So: no attribute unless that side effect is possible. * (Userspace may disable that mechanism later.) */ -static inline int rtc_does_wakealarm (struct rtc_device *rtc) +static bool rtc_does_wakealarm (struct rtc_device *rtc) {if (!device_can_wakeup (rtc->dev.parent))
Quoted 9 lines
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 237
Quoted 5 lines
drivers/rtc/rtc-sysfs.c +2
-1-return 0 ; +return false; +return rtc->ops->set_alarm !=NULL ; }This looks unrelated too and confuses me. Could you split such cleanup from main goal of the patch?
That one is bothering me too.
Signature · 14 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [rtc-linux] [PATCH 4/4] RTC: switch to using is_visible() to control sysfs attributes
Quoted 22 lines · Alexandre Belloni
(Krzysztof, be careful, Dmitry was not in copy of your maili, you should probably check your mailer config)
Quoted 17 lines · Krzysztof Kozlowski
2015-07-21 8:02 GMT+09:00 Dmitry Torokhov <[email protected]>:
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 212
Quoted 13 lines
static
ssize_tdrivers/rtc/rtc-sysfs.c +2
-3-rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, +wakealarm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) { ssize_t retval;@@ -221,45 +209,58 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, retval =rtc_set_alarm (rtc, &alm);return (retval <0 ) ? retval : n; } -static DEVICE_ATTR(wakealarm, S_IRUGO | S_IWUSR, - rtc_sysfs_show_wakealarm, rtc_sysfs_set_wakealarm); +static DEVICE_ATTR_RW (wakealarm);This and renaming of show/store functions look unrelated
Quoted 2 lines
I don't really mind that one but I would also prefer if it could be separated.
OK, I will.
Quoted 34 lines
Quoted 24 lines
Quoted 24 lines
drivers/rtc/rtc-sysfs.c +13
-2+static struct attribute *rtc_attrs[] = { + &dev_attr_name.attr, + &dev_attr_date.attr, + &dev_attr_time.attr, + &dev_attr_since_epoch.attr, + &dev_attr_max_user_freq.attr, + &dev_attr_hctosys.attr, + &dev_attr_wakealarm.attr, +NULL , +}; -/* The reason to trigger an alarm with no process watching it (via sysfs) +/* +* The reason to trigger an alarm with no process watching it (via sysfs) * is its side effect: waking from a system state like suspend-to-RAM or * suspend-to-disk. So: no attribute unless that side effect is possible. * (Userspace may disable that mechanism later.) */ -static inline int rtc_does_wakealarm (struct rtc_device *rtc) +static bool rtc_does_wakealarm (struct rtc_device *rtc) {if (!device_can_wakeup (rtc->dev.parent))Quoted 9 lines
drivers/rtc/rtc-sysfs.c rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, · line 237
Quoted 5 lines
drivers/rtc/rtc-sysfs.c +2
-1-return 0 ; +return false; +return rtc->ops->set_alarm !=NULL ; }This looks unrelated too and confuses me. Could you split such cleanup from main goal of the patch?
Quoted 1 line
That one is bothering me too.
Will separate this too.
Thanks.
Signature · 12 lines
Dmitry -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
Re: [rtc-linux] [PATCH 4/4] RTC: switch to using is_visible() to control sysfs attributes
In reply to Alexandre Belloni2015-07-23 5:57 GMT+09:00 Alexandre Belloni
<[email protected]>:
Quoted 2 lines
(Krzysztof, be careful, Dmitry was not in copy of your maili, you should probably check your mailer config)
Right, I need to fix my Google group settings. Thank you for pointing this. Probably my other emails also were not sent to Dmitry...
Best regards,
Krzysztof
Signature · 9 lines
-- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.