untabify
This commit is contained in:
@ -17,19 +17,19 @@ static int dt_probe(struct platform_device *pdev);
|
||||
static void dt_remove(struct platform_device *pdev);
|
||||
|
||||
static struct of_device_id my_driver_ids[] = {
|
||||
{
|
||||
.compatible = "hottis,counter",
|
||||
}, { /* sentinel */ }
|
||||
{
|
||||
.compatible = "hottis,counter",
|
||||
}, { /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, my_driver_ids);
|
||||
|
||||
static struct platform_driver my_driver = {
|
||||
.probe = dt_probe,
|
||||
.remove = dt_remove,
|
||||
.driver = {
|
||||
.name = "my_device_driver",
|
||||
.of_match_table = my_driver_ids,
|
||||
},
|
||||
.probe = dt_probe,
|
||||
.remove = dt_remove,
|
||||
.driver = {
|
||||
.name = "my_device_driver",
|
||||
.of_match_table = my_driver_ids,
|
||||
},
|
||||
};
|
||||
|
||||
/* GPIO variable */
|
||||
@ -41,70 +41,70 @@ static struct gpio_desc *blue_led = NULL;
|
||||
* @brief This function is called on loading the driver
|
||||
*/
|
||||
static int dt_probe(struct platform_device *pdev) {
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device *dev = &pdev->dev;
|
||||
|
||||
printk("counter - probing\n");
|
||||
printk("counter - probing\n");
|
||||
|
||||
if(!device_property_present(dev, "red-led-gpio")) {
|
||||
printk("counter - Error! Device property 'red-led-gpio' not found!\n");
|
||||
return -1;
|
||||
}
|
||||
if(!device_property_present(dev, "blue-led-gpio")) {
|
||||
printk("counter - Error! Device property 'blue-led-gpio' not found!\n");
|
||||
return -1;
|
||||
}
|
||||
if(!device_property_present(dev, "red-led-gpio")) {
|
||||
printk("counter - Error! Device property 'red-led-gpio' not found!\n");
|
||||
return -1;
|
||||
}
|
||||
if(!device_property_present(dev, "blue-led-gpio")) {
|
||||
printk("counter - Error! Device property 'blue-led-gpio' not found!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Init GPIO */
|
||||
red_led = gpiod_get(dev, "red-led", GPIOD_OUT_LOW);
|
||||
if(IS_ERR(red_led)) {
|
||||
printk("counter - Error! Could not setup the GPIO red-led\n");
|
||||
return -1 * IS_ERR(red_led);
|
||||
}
|
||||
blue_led = gpiod_get(dev, "blue-led", GPIOD_OUT_LOW);
|
||||
if(IS_ERR(blue_led)) {
|
||||
printk("counter - Error! Could not setup the GPIO blue-led\n");
|
||||
return -1 * IS_ERR(blue_led);
|
||||
}
|
||||
/* Init GPIO */
|
||||
red_led = gpiod_get(dev, "red-led", GPIOD_OUT_LOW);
|
||||
if(IS_ERR(red_led)) {
|
||||
printk("counter - Error! Could not setup the GPIO red-led\n");
|
||||
return -1 * IS_ERR(red_led);
|
||||
}
|
||||
blue_led = gpiod_get(dev, "blue-led", GPIOD_OUT_LOW);
|
||||
if(IS_ERR(blue_led)) {
|
||||
printk("counter - Error! Could not setup the GPIO blue-led\n");
|
||||
return -1 * IS_ERR(blue_led);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is called on unloading the driver
|
||||
*/
|
||||
static void dt_remove(struct platform_device *pdev) {
|
||||
printk("counter - removing\n");
|
||||
gpiod_put(red_led);
|
||||
gpiod_put(blue_led);
|
||||
printk("counter - removing\n");
|
||||
gpiod_put(red_led);
|
||||
gpiod_put(blue_led);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is called, when the module is loaded into the kernel
|
||||
*/
|
||||
static int __init my_init(void) {
|
||||
printk("counter - Loading the driver...\n");
|
||||
if(platform_driver_register(&my_driver)) {
|
||||
printk("dt_gpio - Error! Could not load driver\n");
|
||||
return -1;
|
||||
}
|
||||
printk("counter - Loading the driver...\n");
|
||||
if(platform_driver_register(&my_driver)) {
|
||||
printk("dt_gpio - Error! Could not load driver\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printk("counter - red led on\n");
|
||||
gpiod_set_value(red_led, 1);
|
||||
printk("counter - red led on\n");
|
||||
gpiod_set_value(red_led, 1);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is called, when the module is removed from the kernel
|
||||
*/
|
||||
static void __exit my_exit(void) {
|
||||
printk("counter - Unload driver");
|
||||
printk("counter - Unload driver");
|
||||
|
||||
printk("counter - red led off\n");
|
||||
gpiod_set_value(red_led, 0);
|
||||
printk("counter - red led off\n");
|
||||
gpiod_set_value(red_led, 0);
|
||||
|
||||
platform_driver_unregister(&my_driver);
|
||||
platform_driver_unregister(&my_driver);
|
||||
}
|
||||
|
||||
module_init(my_init);
|
||||
|
Reference in New Issue
Block a user