Example #1
0
static ssize_t umbrellary_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) {
    struct umbrellary_data * device_data = (struct umbrellary_data *) dev->platform_data;
    
    if (size > 4096) {
        printk(KERN_ALERT "f**k you!");
        return 0;
    }
    printk(KERN_ALERT "%s buffer is [%s]", "umbrellary_store", buf);
    
    if(strcmp(buf, "on\n") == 0){
        //INP_GPIO_04(device_data->gpioaddr);
        OUT_GPIO_04(device_data->gpioaddr);
        GPIO_SET_04(device_data->gpioaddr);
        printk(KERN_ALERT "%s", "gpio has turn on");
        
    }else if(strcmp(buf, "off\n") == 0){
        //INP_GPIO_04(device_data->gpioaddr);
        OUT_GPIO_04(device_data->gpioaddr);
        GPIO_CLR_04(device_data->gpioaddr);
        printk(KERN_ALERT "%s", "gpio has turn off");
    }
    
    return sprintf(((struct umbrellary_data *) dev->platform_data)->data, buf);
}
Example #2
0
static int hello_init(void)
{
    printk("Hello, LED World! \n");
    
    gpio = (volatile unsigned int *)ioremap(GPIO_BASE, 16);
    
    printk("gpio=%#x. \n", gpio);
    
    INP_GPIO_04(gpio);
    OUT_GPIO_04(gpio);
    
    init_timer(&led_timer);
    led_timer.function = hello_timer;
    led_timer.data = (unsigned long)&kbledstatus;
    led_timer.expires = jiffies + HZ;
    add_timer(&led_timer);
    
    return 0;
}