static int gpio_handler_probe(struct platform_device *pdev) { struct StructGpioHandlerData *pdata = NULL; int nErr = 0; int nIrq = 0; int i = 0; pdata = devm_kzalloc(&pdev->dev, sizeof(struct StructGpioHandlerData), GFP_KERNEL); if(!pdata) { printk(KERN_ERR "[%s:%4d] Failed to devm_kzalloc...\n", __FILENAME__, __LINE__); return -ENOMEM; } pdata->pdev = pdev; pdata->mdev.minor = MISC_DYNAMIC_MINOR; pdata->mdev.name = "gpio_handler"; pdata->mdev.fops = &gpio_handler_fops; nErr = misc_register(&pdata->mdev); if(nErr) { dev_err(&pdev->dev,"failed to register misc device\n"); devm_kfree(&pdev->dev, pdata); return nErr; } platform_set_drvdata(pdev, pdata); for(i = 0 ; i < 512 ; i++) { if(gpio_is_valid(i)) { //gpio_request_one(i, GPIOF_IN, "TEST"); if(devm_gpio_request(&pdev->dev, i, "TEST") < 0) { printk(KERN_ERR "[%s:%4d] Failed to gpio(%d)_request...\n", __FILENAME__, __LINE__, i); continue; } nIrq = gpio_to_irq(i); if (nIrq < 0) { printk(KERN_ERR "[%s:%4d] Failed to gpio(%d)_to_irq(%d).\n", __FILENAME__, __LINE__, i, nIrq); } else { printk(KERN_ERR "[%s:%4d] ***********************************gpio(%d)_to_irq(%d).\n", __FILENAME__, __LINE__, i, nIrq); } } else { printk(KERN_ERR "[%s:%4d] Failed to gpio(%d)_is_valid.\n", __FILENAME__, __LINE__, i); } } printk(KERN_DEBUG "[%s:%4d] Registered gpio_handler char driver. \n", __FILENAME__, __LINE__); return 0; }