X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmisc%2Fhdpuftrs%2Fhdpu_cpustate.c;fp=drivers%2Fmisc%2Fhdpuftrs%2Fhdpu_cpustate.c;h=11a801be71c88f9b39cd04c41336fdf1c25d6ee0;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=7501fab349e4ce5271cbe7b517b2f32f945ed954;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c index 7501fab34..11a801be7 100644 --- a/drivers/misc/hdpuftrs/hdpu_cpustate.c +++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c @@ -14,21 +14,20 @@ * */ -#include #include #include #include #include #include #include -#include +#include #include #include #define SKY_CPUSTATE_VERSION "1.1" -static int hdpu_cpustate_probe(struct device *ddev); -static int hdpu_cpustate_remove(struct device *ddev); +static int hdpu_cpustate_probe(struct platform_device *pdev); +static int hdpu_cpustate_remove(struct platform_device *pdev); struct cpustate_t cpustate; @@ -159,11 +158,12 @@ static int cpustate_read_proc(char *page, char **start, off_t off, return len; } -static struct device_driver hdpu_cpustate_driver = { - .name = HDPU_CPUSTATE_NAME, - .bus = &platform_bus_type, +static struct platform_driver hdpu_cpustate_driver = { .probe = hdpu_cpustate_probe, .remove = hdpu_cpustate_remove, + .driver = { + .name = HDPU_CPUSTATE_NAME, + }, }; /* @@ -188,26 +188,40 @@ static struct miscdevice cpustate_dev = { &cpustate_fops }; -static int hdpu_cpustate_probe(struct device *ddev) +static int hdpu_cpustate_probe(struct platform_device *pdev) { - struct platform_device *pdev = to_platform_device(ddev); struct resource *res; + struct proc_dir_entry *proc_de; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); cpustate.set_addr = (unsigned long *)res->start; cpustate.clr_addr = (unsigned long *)res->end - 1; - misc_register(&cpustate_dev); - create_proc_read_entry("sky_cpustate", 0, 0, cpustate_read_proc, NULL); + ret = misc_register(&cpustate_dev); + if (ret) { + printk(KERN_WARNING "sky_cpustate: Unable to register misc " + "device.\n"); + cpustate.set_addr = NULL; + cpustate.clr_addr = NULL; + return ret; + } + + proc_de = create_proc_read_entry("sky_cpustate", 0, 0, + cpustate_read_proc, NULL); + if (proc_de == NULL) + printk(KERN_WARNING "sky_cpustate: Unable to create proc " + "dir entry\n"); printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n"); return 0; } -static int hdpu_cpustate_remove(struct device *ddev) + +static int hdpu_cpustate_remove(struct platform_device *pdev) { - cpustate.set_addr = 0; - cpustate.clr_addr = 0; + cpustate.set_addr = NULL; + cpustate.clr_addr = NULL; remove_proc_entry("sky_cpustate", NULL); misc_deregister(&cpustate_dev); @@ -218,13 +232,13 @@ static int hdpu_cpustate_remove(struct device *ddev) static int __init cpustate_init(void) { int rc; - rc = driver_register(&hdpu_cpustate_driver); + rc = platform_driver_register(&hdpu_cpustate_driver); return rc; } static void __exit cpustate_exit(void) { - driver_unregister(&hdpu_cpustate_driver); + platform_driver_unregister(&hdpu_cpustate_driver); } module_init(cpustate_init);