Skip to contentSkip to conversation

__clocksource_register_scale return value use?

PATCH In review anish kumar 1 participant 3 messages Mar 7, 2013 – Mar 11, 2013 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 __clocksource_register_scale return value use?

__clocksource_register_scale() currently returns int but it should return void as there are no error paths in that function. Making it void would help some amount of code to be removed at various places.

clocksource_register_hz/khz() return value is checked in most of the places but I think it will translate to always if(true) so let's remove those checks as well(patch will be sent later for that).

Is this return value for some future usecase(?), if yes then my apologies.

---
 include/linux/clocksource.h |    6 +++---
 kernel/time/clocksource.c   |    7 +------
 2 files changed, 4 insertions(+), 9 deletions(-)
include/linux/clocksource.h +0 -0
index 27cfda4..2b074cc 100644
@@ -294,17 +294,17 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32

from, u32 to, u32 minsec);
* Don't call __clocksource_register_scale directly, use
* clocksource_register_hz/khz
*/
-extern int
+extern void
__clocksource_register_scale(struct clocksource *cs, u32 scale, u32
freq);
extern void
__clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32
freq);

-static inline int clocksource_register_hz(struct clocksource *cs, u32 hz)
+static inline void clocksource_register_hz(struct clocksource *cs, u32 hz)
{
return __clocksource_register_scale(cs, 1, hz);
}

-static inline int clocksource_register_khz(struct clocksource *cs, u32 khz)
+static inline void clocksource_register_khz(struct clocksource *cs, u32 khz)
{
return __clocksource_register_scale(cs, 1000, khz);
}

kernel/time/clocksource.c +0 -2
index c958338..1915550 100644
@@ -703,14 +703,11 @@ EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale);
  * @scale:	Scale factor multiplied against freq to get clocksource hz
  * @freq:	clocksource frequency (cycles per second) divided by scale
  *
- * Returns -EBUSY if registration fails, zero otherwise.
- *
  * This *SHOULD NOT* be called directly! Please use the
  * clocksource_register_hz() or clocksource_register_khz helper

functions.
*/
-int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
+void __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
{
-
/* Initialize mult/shift and max_idle_ns */ __clocksource_updatefreq_scale(cs, scale, freq);

@@ -720,11 +717,9 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
clocksource_enqueue_watchdog(cs); clocksource_select(); mutex_unlock(&clocksource_mutex);
- return 0;
}
EXPORT_SYMBOL_GPL(__clocksource_register_scale);

-
/**
* clocksource_register - Used to install new clocksources
* @cs: clocksource to be registered

Signature · 1 line
1.7.1
#1 lore raw

ping

Quoted 91 lines · anish kumar

__clocksource_register_scale() currently returns int but it should return void as there are no error paths in that function. Making it void would help some amount of code to be removed at various places.

clocksource_register_hz/khz() return value is checked in most of the places but I think it will translate to always if(true) so let's remove those checks as well(patch will be sent later for that).

Is this return value for some future usecase(?), if yes then my apologies.

---
 include/linux/clocksource.h |    6 +++---
 kernel/time/clocksource.c   |    7 +------
 2 files changed, 4 insertions(+), 9 deletions(-)
include/linux/clocksource.h +2 -3
index 27cfda4..2b074cc 100644
@@ -294,17 +294,17 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32
 from, u32 to, u32 minsec);
  * Don't call __clocksource_register_scale directly, use
  * clocksource_register_hz/khz
  */
-extern int
+extern void
 __clocksource_register_scale(struct clocksource *cs, u32 scale, u32
 freq);
 extern void
 __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32
 freq);
 
-static inline int clocksource_register_hz(struct clocksource *cs, u32
 hz)
+static inline void clocksource_register_hz(struct clocksource *cs, u32
 hz)
 {
        return __clocksource_register_scale(cs, 1, hz);
 }
 
-static inline int clocksource_register_khz(struct clocksource *cs, u32

khz)
+static inline void clocksource_register_khz(struct clocksource *cs, u32 khz)

 {
        return __clocksource_register_scale(cs, 1000, khz);

}

kernel/time/clocksource.c +0 -2
index c958338..1915550 100644
@@ -703,14 +703,11 @@ EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale);
  * @scale:     Scale factor multiplied against freq to get clocksource hz
  * @freq:      clocksource frequency (cycles per second) divided by scale
  *
- * Returns -EBUSY if registration fails, zero otherwise.
- *
  * This *SHOULD NOT* be called directly! Please use the
  * clocksource_register_hz() or clocksource_register_khz helper

functions.
*/
-int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
+void __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
{

kernel/time/clocksource.c +0 -3
-
        /* Initialize mult/shift and max_idle_ns */
        __clocksource_updatefreq_scale(cs, scale, freq);
@@ -720,11 +717,9 @@ int __clocksource_register_scale(struct clocksource
 *cs, u32 scale, u32 freq)
        clocksource_enqueue_watchdog(cs);
        clocksource_select();
        mutex_unlock(&clocksource_mutex);
-       return 0;
 }
 EXPORT_SYMBOL_GPL(__clocksource_register_scale);
 
-
 /**
  * clocksource_register - Used to install new clocksources

* @cs: clocksource to be registered
--
1.7.1

#2 lore raw

ACK or NACK this patch please.

Quoted 94 lines · anish singh

ping

Quoted 91 lines · anish kumar

__clocksource_register_scale() currently returns int but it should return void as there are no error paths in that function. Making it void would help some amount of code to be removed at various places.

clocksource_register_hz/khz() return value is checked in most of the places but I think it will translate to always if(true) so let's remove those checks as well(patch will be sent later for that).

Is this return value for some future usecase(?), if yes then my apologies.

---
 include/linux/clocksource.h |    6 +++---
 kernel/time/clocksource.c   |    7 +------
 2 files changed, 4 insertions(+), 9 deletions(-)
include/linux/clocksource.h +2 -3
index 27cfda4..2b074cc 100644
@@ -294,17 +294,17 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32
 from, u32 to, u32 minsec);
  * Don't call __clocksource_register_scale directly, use
  * clocksource_register_hz/khz
  */
-extern int
+extern void
 __clocksource_register_scale(struct clocksource *cs, u32 scale, u32
 freq);
 extern void
 __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32
 freq);
 
-static inline int clocksource_register_hz(struct clocksource *cs, u32
 hz)
+static inline void clocksource_register_hz(struct clocksource *cs, u32
 hz)
 {
        return __clocksource_register_scale(cs, 1, hz);
 }
 
-static inline int clocksource_register_khz(struct clocksource *cs, u32

khz)
+static inline void clocksource_register_khz(struct clocksource *cs, u32 khz)

 {
        return __clocksource_register_scale(cs, 1000, khz);

}

kernel/time/clocksource.c +0 -2
index c958338..1915550 100644
@@ -703,14 +703,11 @@ EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale);
  * @scale:     Scale factor multiplied against freq to get clocksource hz
  * @freq:      clocksource frequency (cycles per second) divided by scale
  *
- * Returns -EBUSY if registration fails, zero otherwise.
- *
  * This *SHOULD NOT* be called directly! Please use the
  * clocksource_register_hz() or clocksource_register_khz helper

functions.
*/
-int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
+void __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
{

kernel/time/clocksource.c +0 -3
-
        /* Initialize mult/shift and max_idle_ns */
        __clocksource_updatefreq_scale(cs, scale, freq);
@@ -720,11 +717,9 @@ int __clocksource_register_scale(struct clocksource
 *cs, u32 scale, u32 freq)
        clocksource_enqueue_watchdog(cs);
        clocksource_select();
        mutex_unlock(&clocksource_mutex);
-       return 0;
 }
 EXPORT_SYMBOL_GPL(__clocksource_register_scale);
 
-
 /**
  * clocksource_register - Used to install new clocksources

* @cs: clocksource to be registered
--
1.7.1