Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dev_pm_ops

  • Loading branch information...
commit a0e1629bb683cd7a7198f96c7acf43c85917a5e8 1 parent 673c00b
Constantine authored
Showing with 15 additions and 19 deletions.
  1. +1 −8 Makefile
  2. +1 −1  README.md
  3. +1 −1  ctracer.h
  4. +12 −9 ldt.c
9 Makefile
View
@@ -8,6 +8,7 @@ ccflags-y+=-D USE_PLATFORM_DEVICE
obj-m+= ldt.o
obj-m+= ldt_plat_drv.o # implements platform_driver only
obj-m+= ldt_plat_dev.o # implements platform_device and resource
+#obj-m+= chrdev_region_sample.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
@@ -22,16 +23,8 @@ modules_install:
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions modules.order Module.symvers dio *.tmp *.log
-depend .depend dep:
- $(CC) $(ccflags-y) -M *.c > .depend
-
-
dio: CPPFLAGS+= -D CTRACER_ON -include ctracer.h -g
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
-
_src=dio.c ldt.c ldt_plat_dev.c ldt_plat_drv.c ctracer.h
checkpatch:
2  README.md
View
@@ -2,7 +2,7 @@
LDT project is useful for Linux driver development beginners and as starting point for a new drivers.
The driver uses following Linux facilities:
-module, platform driver, file operations (read/write, mmap, ioctl, blocking and nonblocking mode, polling), kfifo, completion, interrupt, tasklet, work, kthread, timer, misc device, proc fs, UART 0x3f8, HW loopback, SW loopback, ftracer.
+module, platform driver, file operations (read/write, mmap, ioctl, blocking and nonblocking mode, polling), kfifo, completion, interrupt, tasklet, work, kthread, timer, simple misc device, multiple char devices, Device Model, proc fs, UART 0x3f8, HW loopback, SW loopback, ftracer.
## Usage:
2  ctracer.h
View
@@ -78,6 +78,7 @@ extern __thread int ret;
#define trl_in() do_statement(trace_time(); trlm("{");)
#define trl_out() do_statement(trace_time(); trlm("}");)
+#define empty_statement() do { } while (0)
#define trace_mem(P, N) \
IFTRACE({ int i = 0; tracef("%s=", #P); for (; i < (int)(N) ; i++) \
@@ -221,7 +222,6 @@ do { \
#else /* !CTRACER_ON */
#define trllog(args ...)
-#define empty_statement() do { } while (0)
static inline int empty_function(void)
{
return 0;
21 ldt.c
View
@@ -28,6 +28,7 @@
* platform_driver and platform_device in another module
* simple UART driver on port 0x3f8 with IRQ 4
* Device Model (class, device)
+ * Power Management (dev_pm_ops)
*
* TODO:
* classic tracing
@@ -493,7 +494,7 @@ static int uart_probe(void)
outb(inb(port + UART_MCR) | UART_MCR_LOOP, port + UART_MCR);
}
if (!uart_detected && loopback) {
- pr_warn("Emulating loopback is software\n");
+ pr_warn("Emulating loopback in software\n");
ret = -ENODEV;
}
}
@@ -665,29 +666,31 @@ static int __devexit ldt_remove(struct platform_device *pdev)
#ifdef CONFIG_PM
-int ldt_suspend(struct platform_device *pdev, pm_message_t state)
+static int ldt_suspend(struct device *dev)
{
-_entry:
return 0;
}
-int ldt_resume(struct platform_device *pdev)
+static int ldt_resume(struct device *dev)
{
-_entry:
return 0;
}
+static const struct dev_pm_ops ldt_pm = {
+ .suspend = ldt_suspend,
+.resume = ldt_resume,
+};
+
+#define ldt_pm_ops (&ldt_pm)
#else
-#define ldt_suspend NULL
-#define ldt_resume NULL
+#define ldt_pm_ops NULL
#endif
static struct platform_driver ldt_driver = {
.driver.name = "ldt_device_name",
.driver.owner = THIS_MODULE,
+ .driver.pm = ldt_pm_ops,
.probe = ldt_probe,
- .suspend = ldt_suspend,
- .resume = ldt_resume,
.remove = __devexit_p(ldt_remove),
};
Please sign in to comment.
Something went wrong with that request. Please try again.