diff options
| author | John Ogness <john.ogness@linutronix.de> | 2019-02-15 12:55:00 +0106 |
|---|---|---|
| committer | John Ogness <john.ogness@linutronix.de> | 2019-02-15 12:55:00 +0106 |
| commit | ec79ca947b4942cb3f818e92a2c577ca252fd63e (patch) | |
| tree | c62020666c34196b7e956b4c8b563122c20424d5 | |
| parent | f8e64cb0858afabcbcccb18e77ca9902c8280e01 (diff) | |
schulung_tools: hellodriver: cleanup code
- add SPDX license identifier
- cleanup goto target names
- remove an obsolete setting of owner to THIS_MODULE
- update the module version
Signed-off-by: John Ogness <john.ogness@linutronix.de>
| -rw-r--r-- | schulung_tools/drivers/modules/hellodriver/hello.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/schulung_tools/drivers/modules/hellodriver/hello.c b/schulung_tools/drivers/modules/hellodriver/hello.c index 328c587..7f78d06 100644 --- a/schulung_tools/drivers/modules/hellodriver/hello.c +++ b/schulung_tools/drivers/modules/hellodriver/hello.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> @@ -93,7 +94,7 @@ static int hello_probe(struct platform_device *pdev) ret = of_property_read_u32(pdev->dev.of_node, "index", &hello->minor); if (ret < 0) { dev_err(&pdev->dev, "no index specified\n"); - goto err_out1; + goto err_out; } #else hello->minor = (unsigned)pdev->id; @@ -102,7 +103,7 @@ static int hello_probe(struct platform_device *pdev) if (hello->minor >= HELLO_MAX_DEVICES) { dev_err(&pdev->dev, "invalid index: %u\n", hello->minor); ret = -EINVAL; - goto err_out1; + goto err_out; } hello->dev = &pdev->dev; @@ -115,7 +116,7 @@ static int hello_probe(struct platform_device *pdev) ret = cdev_add(&hello->cdev, devt, 1); if (ret != 0) { dev_err(&pdev->dev, "cdev_add failed\n"); - goto err_out1; + goto err_drvdata; } dev = device_create(hello_class, &pdev->dev, devt, hello, @@ -123,17 +124,18 @@ static int hello_probe(struct platform_device *pdev) if (IS_ERR(dev)) { dev_err(&pdev->dev, "device_create failed\n"); ret = PTR_ERR(dev); - goto err_out2; + goto err_cdev; } dev_info(&pdev->dev, "HELLO! I am hello device %d!\n", hello->minor); return 0; -err_out2: +err_cdev: cdev_del(&hello->cdev); -err_out1: +err_drvdata: platform_set_drvdata(pdev, NULL); +err_out: return ret; } @@ -158,7 +160,6 @@ static const struct of_device_id hello_match[] = { static struct platform_driver hello_driver = { .driver = { .name = "hello", - .owner = THIS_MODULE, .of_match_table = hello_match, }, .probe = hello_probe, @@ -183,12 +184,12 @@ static int __init hello_init(void) if (IS_ERR(hello_class)) { printk(KERN_ERR "%s: failed to create class\n", __func__); ret = PTR_ERR(hello_class); - goto err_out1; + goto err_region; } ret = platform_driver_register(&hello_driver); if (ret != 0) - goto err_out2; + goto err_class; #ifndef CONFIG_OF pdevs[0] = platform_device_register_simple("hello", 1, NULL, 0); @@ -198,9 +199,9 @@ static int __init hello_init(void) return 0; -err_out2: +err_class: class_destroy(hello_class); -err_out1: +err_region: unregister_chrdev_region(hello_devt, HELLO_MAX_DEVICES); return ret; } @@ -226,4 +227,4 @@ module_exit(hello_exit); MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>"); MODULE_DESCRIPTION("a great module for hello-ing!"); MODULE_LICENSE("GPL v2"); -MODULE_VERSION("20160607"); +MODULE_VERSION("20190101"); |
