Skip to contentSkip to conversation

RTC subsystem, test device/driver

RFC PATCH In review Alessandro Zummo 2 participants 3 messages Dec 26, 2005 – Dec 27, 2005 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 7/7 RTC subsystem, test device/driver

This is a software RTC which can be
used to test the RTC subsystem APIs. It gets
the time from the system clock.

Interrupts can be generated by
echo "alarm|tick|update" >/sys/class/rtc/rtcX/device/irq

--

 drivers/rtc/Kconfig    |   15 +++
 drivers/rtc/Makefile   |    1 
 drivers/rtc/rtc-test.c |  196 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 212 insertions(+)
drivers/rtc/Kconfig +15 -0
@@ -65,4 +65,19 @@
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-x1205.
 
+config RTC_DRV_TEST
+	tristate "Test driver/device"
+	depends on RTC_CLASS
+	help
+	  If you say yes here you get support for the
+	  RTC test driver. It's a software RTC which can be
+	  used to test the RTC subsystem APIs. It gets
+	  the time from the system clock.
+	  You want this driver only if you are doing development
+	  on the RTC subsystem. Please read the source code
+	  for further details.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-test.
+
 endmenu
drivers/rtc/Makefile +1 -0
@@ -10,4 +10,5 @@
 obj-$(CONFIG_RTC_INTF_DEV)	+= rtc-dev.o
 
 obj-$(CONFIG_RTC_DRV_X1205)	+= rtc-x1205.o
+obj-$(CONFIG_RTC_DRV_TEST)	+= rtc-test.o
 
drivers/rtc/rtc-test.c new file +196 -0

196 lines not on this page · raw message

#1 lore raw

drivers/rtc/rtc-test.c line 165

Quoted 12 lines · Alessandro Zummo
drivers/rtc/rtc-test.c new file +12 -0
+struct platform_device test_dev_zero = {
+	.name	= "rtc-test",
+	.id	= 0,
+	.dev.release = test_release,
+};
+
+struct platform_device test_dev_one = {
+	.name	= "rtc-test",
+	.id	= 1,
+	.dev.release = test_release,
+};
+

You should never ever statically allicate devices that can be unregistered. Guess what will happen if one does this:

rmmod rtc_test < /sys/class/rtc/rtcX/date

where rctX is class device created by rtc-test0 or rtc-test1.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 6 lines · On Mon, 26 Dec 2005 18:45:34 -0500 Dmitry Torokhov <[email protected]>…

You should never ever statically allicate devices that can be unregistered. Guess what will happen if one does this:

rmmod rtc_test < /sys/class/rtc/rtcX/date

where rctX is class device created by rtc-test0 or rtc-test1.

Will fix, thanks!

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Turin, Italy

  http://www.towertech.it