Skip to contentSkip to conversation

fix RTC-CMOS message

PATCH In review Krzysztof Halasa 3 participants 7 messages Apr 2, 2009 – Apr 15, 2009 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix RTC-CMOS message

With no IRQ available/defined, RTC-CMOS driver prints something like:

	rtc0: alarms up to one no, y3k, 114 bytes nvram
                              ^^^^

I guess the following is a bit easier to understand:
rtc0: no alarms, y3k, 114 bytes nvram

drivers/rtc/rtc-cmos.c +9 -11
@@ -794,17 +794,15 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 		goto cleanup2;
 	}
 
-	pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n",
-			cmos_rtc.rtc->dev.bus_id,
-			is_valid_irq(rtc_irq)
-				?  (cmos_rtc.mon_alrm
-					? "year"
-					: (cmos_rtc.day_alrm
-						? "month" : "day"))
-				: "no",
-			cmos_rtc.century ? ", y3k" : "",
-			nvram.size,
-			is_hpet_enabled() ? ", hpet irqs" : "");
+	pr_info("%s: %s%s, %zd bytes nvram%s\n",
+		cmos_rtc.rtc->dev.bus_id,
+		!is_valid_irq(rtc_irq) ? "no alarms" :
+		cmos_rtc.mon_alrm ? "alarms up to one year" :
+		cmos_rtc.day_alrm ? "alarms up to one month" :
+		"alarms up to one day",
+		cmos_rtc.century ? ", y3k" : "",
+		nvram.size,
+		is_hpet_enabled() ? ", hpet irqs" : "");
 
 	return 0;
 
Signature · 1 line
Krzysztof Halasa
#1 lore raw

Re: [PATCH] fix RTC-CMOS message, now with SOB

With no IRQ available/defined, RTC-CMOS driver prints something like:

	rtc0: alarms up to one no, y3k, 114 bytes nvram
                              ^^^^

I guess the following is a bit easier to understand:
rtc0: no alarms, y3k, 114 bytes nvram

drivers/rtc/rtc-cmos.c +9 -11
@@ -794,17 +794,15 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 		goto cleanup2;
 	}
 
-	pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n",
-			cmos_rtc.rtc->dev.bus_id,
-			is_valid_irq(rtc_irq)
-				?  (cmos_rtc.mon_alrm
-					? "year"
-					: (cmos_rtc.day_alrm
-						? "month" : "day"))
-				: "no",
-			cmos_rtc.century ? ", y3k" : "",
-			nvram.size,
-			is_hpet_enabled() ? ", hpet irqs" : "");
+	pr_info("%s: %s%s, %zd bytes nvram%s\n",
+		cmos_rtc.rtc->dev.bus_id,
+		!is_valid_irq(rtc_irq) ? "no alarms" :
+		cmos_rtc.mon_alrm ? "alarms up to one year" :
+		cmos_rtc.day_alrm ? "alarms up to one month" :
+		"alarms up to one day",
+		cmos_rtc.century ? ", y3k" : "",
+		nvram.size,
+		is_hpet_enabled() ? ", hpet irqs" : "");
 
 	return 0;
 
Signature · 1 line
Krzysztof Halasa
#2 lore raw

Re: [PATCH] fix RTC-CMOS message, now with SOB

Quoted 4 lines · Krzysztof Halasa

+               !is_valid_irq(rtc_irq) ? "no alarms" :
+               cmos_rtc.mon_alrm ? "alarms up to one year" :
+               cmos_rtc.day_alrm ? "alarms up to one month" :
+               "alarms up to one day",

Could you reformat that so it looks more like the compound-IF statement it really is? That is, display the nesting structure. And not use negative logic for that first test.

#3 lore raw

Re: [PATCH] fix RTC-CMOS message, now with SOB

Quoted 7 lines · David Brownell
Quoted 4 lines

+               !is_valid_irq(rtc_irq) ? "no alarms" :
+               cmos_rtc.mon_alrm ? "alarms up to one year" :
+               cmos_rtc.day_alrm ? "alarms up to one month" :
+               "alarms up to one day",

Could you reformat that so it looks more like the compound-IF statement it really is? That is, display the nesting structure.

You mean something like

Quoted 4 lines
Quoted 4 lines

+               !is_valid_irq(rtc_irq) ? "no alarms" :

+                       cmos_rtc.mon_alrm ? "alarms up to one year" :
+                       cmos_rtc.day_alrm ? "alarms up to one month" :
+                       "alarms up to one day",

Not this certainly?

Quoted 6 lines
Quoted 4 lines

+               !is_valid_irq(rtc_irq) ? "no alarms" :
+                cmos_rtc.mon_alrm ? "alarms up to one year" :
+                cmos_rtc.day_alrm ? "alarms up to one month" :
+                "alarms up to one day",

And not use negative logic for that first test.

I think it's worse WRT readability:

+ is_valid_irq(rtc_irq) ?
+ (cmos_rtc.mon_alrm ? "alarms up to one year" :
+ cmos_rtc.day_alrm ? "alarms up to one month" :
+ "alarms up to one day") :
+ "no alarms";

Feel free to use the following or your own version as long as the resulting message is correct.
Thanks.

drivers/rtc/rtc-cmos.c +9 -11
@@ -794,17 +794,15 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 		goto cleanup2;
 	}
 
-	pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n",
-			cmos_rtc.rtc->dev.bus_id,
-			is_valid_irq(rtc_irq)
-				?  (cmos_rtc.mon_alrm
-					? "year"
-					: (cmos_rtc.day_alrm
-						? "month" : "day"))
-				: "no",
-			cmos_rtc.century ? ", y3k" : "",
-			nvram.size,
-			is_hpet_enabled() ? ", hpet irqs" : "");
+	pr_info("%s: %s%s, %zd bytes nvram%s\n",
+		cmos_rtc.rtc->dev.bus_id,
+		!is_valid_irq(rtc_irq) ? "no alarms" :
+			cmos_rtc.mon_alrm ? "alarms up to one year" :
+			cmos_rtc.day_alrm ? "alarms up to one month" :
+			"alarms up to one day",
+		cmos_rtc.century ? ", y3k" : "",
+		nvram.size,
+		is_hpet_enabled() ? ", hpet irqs" : "");
 
 	return 0;
 
Signature · 1 line
Krzysztof Halasa
#4 lore raw

Re: [PATCH] fix RTC-CMOS message, now with SOB

Quoted 10 lines · On Sat, 04 Apr 2009 21:32:27 +0200 Krzysztof Halasa <[email protected]> wrote:
(quoted diff) +4 -0
+		        (cmos_rtc.mon_alrm ? "alarms up to one year" :
+		                cmos_rtc.day_alrm ? "alarms up to one month" :
+		                        "alarms up to one day") :
+		        "no alarms";

Feel free to use the following or your own version as long as the resulting message is correct.
Thanks.

Please resend the full changelog (possibly with updates) with each updated version of a patch.

Quoted 18 lines
drivers/rtc/rtc-cmos.c +1 -11
@@ -794,17 +794,15 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 		goto cleanup2;
 	}
 
-	pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n",
-			cmos_rtc.rtc->dev.bus_id,
-			is_valid_irq(rtc_irq)
-				?  (cmos_rtc.mon_alrm
-					? "year"
-					: (cmos_rtc.day_alrm
-						? "month" : "day"))
-				: "no",
-			cmos_rtc.century ? ", y3k" : "",
-			nvram.size,
-			is_hpet_enabled() ? ", hpet irqs" : "");
+	pr_info("%s: %s%s, %zd bytes nvram%s\n",

drivers/rtc/rtc-cmos.c cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) · line 807

Quoted 10 lines
drivers/rtc/rtc-cmos.c +8 -0
+		cmos_rtc.rtc->dev.bus_id,
+		!is_valid_irq(rtc_irq) ? "no alarms" :
+			cmos_rtc.mon_alrm ? "alarms up to one year" :
+			cmos_rtc.day_alrm ? "alarms up to one month" :
+			"alarms up to one day",
+		cmos_rtc.century ? ", y3k" : "",
+		nvram.size,
+		is_hpet_enabled() ? ", hpet irqs" : "");
 
 	return 0;

The patch doesn't apply to current kernels (the driver core guys have been running rampant again, methinks). Please redo, retest, resend?

Thanks.

#5 lore raw

Re: [PATCH] fix RTC-CMOS message, now with SOB

Quoted 2 lines · Andrew Morton

The patch doesn't apply to current kernels (the driver core guys have been running rampant again, methinks). Please redo, retest, resend?

Sure, will do.

Signature · 1 line
Krzysztof Halasa
#6 lore raw

Re: [PATCH] fix RTC-CMOS message, against 2.6.30-rc2

In reply to Andrew Morton

With no IRQ available/defined, RTC-CMOS driver prints something like:

	rtc0: alarms up to one no, y3k, 114 bytes nvram
                              ^^^^

I guess the following is a bit easier to understand:
rtc0: no alarms, y3k, 114 bytes nvram

drivers/rtc/rtc-cmos.c +9 -11
index b6d35f5..23e10b6 100644
@@ -797,17 +797,15 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 		goto cleanup2;
 	}
 
-	pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n",
-			dev_name(&cmos_rtc.rtc->dev),
-			is_valid_irq(rtc_irq)
-				?  (cmos_rtc.mon_alrm
-					? "year"
-					: (cmos_rtc.day_alrm
-						? "month" : "day"))
-				: "no",
-			cmos_rtc.century ? ", y3k" : "",
-			nvram.size,
-			is_hpet_enabled() ? ", hpet irqs" : "");
+	pr_info("%s: %s%s, %zd bytes nvram%s\n",
+		dev_name(&cmos_rtc.rtc->dev),
+		!is_valid_irq(rtc_irq) ? "no alarms" :
+			cmos_rtc.mon_alrm ? "alarms up to one year" :
+			cmos_rtc.day_alrm ? "alarms up to one month" :
+			"alarms up to one day",
+		cmos_rtc.century ? ", y3k" : "",
+		nvram.size,
+		is_hpet_enabled() ? ", hpet irqs" : "");
 
 	return 0;
 
Signature · 1 line
Krzysztof Halasa