int __init x_init(void) { int res; x_class = class_create( THIS_MODULE, "x-class" ); if( IS_ERR( x_class ) ) printk( "bad class create\n" ); res = class_create_file( x_class, &class_attr_data1 ); res = class_create_file( x_class, &class_attr_data2 ); res = class_create_file( x_class, &class_attr_data3 ); printk("'yxxx' module initialized\n"); return 0; }
static int create_tv_attr(disp_module_info_t* info) { //create base class for display int i; info->base_class=class_create(THIS_MODULE,info->name); if(IS_ERR(info->base_class)) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create tv display class fail\n"); return -1 ; } //create class attr for(i=0;i<ARRAY_SIZE(tv_attr);i++) { if ( class_create_file(info->base_class,tv_attr[i])) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create disp attribute %s fail\n",tv_attr[i]->attr.name); } } sprintf(vdac_setting,"%x",get_current_vdac_setting()); #ifdef CONFIG_AML_VOUT_FRAMERATE_AUTOMATION sprintf(policy_fr_auto, "%d", DEFAULT_POLICY_FR_AUTO); #endif return 0; }
static int __init asus_oled_init(void) { int retval = 0; oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME); if (IS_ERR(oled_class)) { err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class"); return PTR_ERR(oled_class); } retval = class_create_file(oled_class, &class_attr_version.attr); if (retval) { err("Error creating class version file"); goto error; } retval = usb_register(&oled_driver); if (retval) { err("usb_register failed. Error number %d", retval); goto error; } return retval; error: class_destroy(oled_class); return retval; }
static int create_vout_attr(void) { //create base class for display int i; extern const vinfo_t *get_current_vinfo(void); vinfo_t * init_mode; vout_info.base_class=class_create(THIS_MODULE,VOUT_CLASS_NAME); if(IS_ERR(vout_info.base_class)) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create vout class fail\n"); return -1 ; } //create class attr for(i=0;i<VOUT_ATTR_MAX;i++) { if ( class_create_file(vout_info.base_class,vout_attr[i])) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create disp attribute %s fail\n",vout_attr[i]->attr.name); } } // Init /sys/class/display/mode value init_mode = (vinfo_t *)get_current_vinfo(); if(init_mode) strcpy(mode, init_mode->name); return 0; }
int amlmmc_dtb_init(struct mmc_card *card) { int ret = 0; card_dtb = card; pr_info("%s: register dtb chardev", __func__); ret = alloc_chrdev_region(&amlmmc_dtb_no, 0, 1, DTB_NAME); if (ret < 0) { pr_err("alloc dtb dev_t no failed"); ret = -1; goto exit_err; } cdev_init(&amlmmc_dtb, &dtb_ops); amlmmc_dtb.owner = THIS_MODULE; ret = cdev_add(&amlmmc_dtb, amlmmc_dtb_no, 1); if (ret) { pr_err("dtb dev add failed"); ret = -1; goto exit_err1; } amlmmc_dtb_class = class_create(THIS_MODULE, DTB_NAME); if (IS_ERR(amlmmc_dtb_class)) { pr_err("dtb dev add failed"); ret = -1; goto exit_err2; } ret = class_create_file(amlmmc_dtb_class, &class_attr_emmcdtb); if (ret) { pr_err("dtb dev add failed"); ret = -1; goto exit_err2; } dtb_dev = device_create(amlmmc_dtb_class, NULL, amlmmc_dtb_no, NULL, DTB_NAME); if (IS_ERR(dtb_dev)) { pr_err("dtb dev add failed"); ret = -1; goto exit_err3; } pr_info("%s: register dtb chardev OK", __func__); return ret; exit_err3: class_remove_file(amlmmc_dtb_class, &class_attr_emmcdtb); class_destroy(amlmmc_dtb_class); exit_err2: cdev_del(&amlmmc_dtb); exit_err1: unregister_chrdev_region(amlmmc_dtb_no, 1); exit_err: return ret; }
/* * test_class_file * make test call to class_create_file * and if that call is successful make * another call to class_remove_file */ static int test_class_file() { struct class * cls = &test_class; if (class_create_file(cls, &class_attr_test_id)) { printk("tbase: failed to create class sysfs file\n"); return 1; } else { printk("tbase: created class sysfs file\n"); class_remove_file(cls, &class_attr_test_id); return 0; } }
static int create_vout_attr(void) { //create base class for display int i; vout_info.base_class=class_create(THIS_MODULE,VOUT_CLASS_NAME); if(IS_ERR(vout_info.base_class)) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create vout class fail\r\n"); return -1 ; } //create class attr for(i=0;i<VOUT_ATTR_MAX;i++) { if ( class_create_file(vout_info.base_class,vout_attr[i])) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create disp attribute %s fail\r\n",vout_attr[i]->attr.name); } } return 0; }
static int create_tv_attr(disp_module_info_t* info) { //create base class for display int i; info->base_class=class_create(THIS_MODULE,info->name); if(IS_ERR(info->base_class)) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create tv display class fail\r\n"); return -1 ; } //create class attr for(i=0;i<ARRAY_SIZE(tv_attr);i++) { if ( class_create_file(info->base_class,tv_attr[i])) { amlog_mask_level(LOG_MASK_INIT,LOG_LEVEL_HIGH,"create disp attribute %s fail\r\n",tv_attr[i]->attr.name); } } sprintf(vdac_setting,"%x",get_current_vdac_setting()); return 0; }
static int create_tv_attr(struct disp_module_info_s *info) { /* create base class for display */ int i; info->base_class = class_create(THIS_MODULE, info->name); if (IS_ERR(info->base_class)) { vout_log_err("create tv display class fail\n"); return -1; } /* create class attr */ for (i = 0; i < ARRAY_SIZE(tv_attr); i++) { if (class_create_file(info->base_class, tv_attr[i])) vout_log_err("create disp attribute %s fail\n", tv_attr[i]->attr.name); } #ifdef CONFIG_AML_VOUT_FRAMERATE_AUTOMATION sprintf(policy_fr_auto, "%d", DEFAULT_POLICY_FR_AUTO); sprintf(policy_fr_auto_switch, "%d", DEFAULT_POLICY_FR_AUTO); #endif return 0; }
static int sii9234_probe(struct platform_device *pdev) { int ret; struct mhl_platform_data *mhl_pdata = pdev->dev.platform_data; struct mhl_dev *mhl_dev; unsigned int mhl_wakeup_irq; struct class *sec_mhl; struct input_dev *input; if (mhl_pdata == NULL) { pr_err("MHL probe fail\n"); return -ENODEV; } ret = i2c_add_driver(&sii9234_i2c_driver); if (ret != 0) { pr_err("[MHL SII9234] can't add i2c driver\n"); return ret; } else { pr_err("[MHL SII9234] add i2c driver\n"); } ret = i2c_add_driver(&sii9234a_i2c_driver); if (ret != 0) { pr_err("[MHL SII9234A] can't add i2c driver\n"); goto err_i2c_a_add; } else { pr_err("[MHL SII9234A] add i2c driver\n"); } ret = i2c_add_driver(&sii9234b_i2c_driver); if (ret != 0) { pr_err("[MHL SII9234B] can't add i2c driver\n"); goto err_i2c_b_add; } else { pr_err("[MHL SII9234B] add i2c driver\n"); } ret = i2c_add_driver(&sii9234c_i2c_driver); if (ret != 0) { pr_err("[MHL SII9234C] can't add i2c driver\n"); goto err_i2c_c_add; } else { pr_err("[MHL SII9234C] add i2c driver\n"); } mhl_dev = kzalloc(sizeof(struct mhl_dev), GFP_KERNEL); if (!mhl_dev) { ret = -ENOMEM; goto err_mem; } input = input_allocate_device(); if (!input) { pr_err("failed to allocate input device.\n"); ret = -ENOMEM; goto err_input; } set_bit(EV_KEY, input->evbit); bitmap_fill(input->keybit, KEY_MAX); mhl_dev->input = input; input_set_drvdata(input, mhl_dev); input->name = "sii9234_rcp"; input->id.bustype = BUS_I2C; ret = input_register_device(input); if (ret < 0) { pr_err("fail to register input device\n"); goto err_misc_register; } mhl_dev->pdata = mhl_pdata; mhl_dev->irq_gpio = mhl_pdata->mhl_int; mhl_dev->wake_up_gpio = mhl_pdata->mhl_wake_up; INIT_WORK(&mhl_dev->sii9234_int_work, sii9234_interrupt_event_work); mhl_dev->sii9234_wq = create_singlethread_workqueue("sii9234_wq"); mhl_dev->mdev.minor = MISC_DYNAMIC_MINOR; mhl_dev->mdev.name = "mhl"; mhl_dev->mdev.fops = &mhl_fops; dev_set_drvdata(&pdev->dev, mhl_dev); mhl_dev->process_dev = &pdev->dev; ret = misc_register(&mhl_dev->mdev); if (ret) { pr_err("mhl misc_register failed\n"); goto err_misc_register; } g_mhl_dev = mhl_dev; mhl_pdata->mhl_irq = gpio_to_irq(mhl_dev->irq_gpio); irq_set_irq_type(mhl_pdata->mhl_irq, IRQ_TYPE_EDGE_RISING); ret = request_threaded_irq(mhl_pdata->mhl_irq, NULL, mhl_int_irq_handler, IRQF_DISABLED, "mhl_int", mhl_dev); if (ret) { pr_err("unable to request irq mhl_int err:: %d\n", ret); goto err_irq_request; } Sii9234_int_irq_disable(); pr_info("create mhl sysfile\n"); sec_mhl = class_create(THIS_MODULE, "mhl"); if (IS_ERR(sec_mhl)) { pr_err("Failed to create class(sec_mhl)!\n"); goto err_exit; } ret = class_create_file(sec_mhl, &class_attr_test_result); if (ret) { pr_err("[ERROR] Failed to create device file in sysfs entries!\n"); goto err_exit; } #if 0 mhl_wakeup_irq = gpio_to_irq(mhl_dev->wake_up_gpio); set_irq_type(mhl_wakeup_irq, IRQ_TYPE_EDGE_RISING); ret = request_threaded_irq(mhl_wakeup_irq, NULL, mhl_wake_up_irq_handler, IRQF_DISABLED, "mhl_wake_up", mhl_dev); if (ret) { pr_err("unable to request irq mhl_wake_up err:: %d\n", ret); goto err_wake_up_irq_request; } #endif #if 0 disable_irq_nosync(mhl_irq); disable_irq_nosync(mhl_wakeup_irq); #endif return 0; err_exit: class_destroy(sec_mhl); err_wake_up_irq_request: free_irq(gpio_to_irq(mhl_dev->irq_gpio), mhl_dev); err_irq_request: mhl_pdata->mhl_irq = NULL; misc_deregister(&mhl_dev->mdev); err_misc_register: input_free_device(input); err_input: destroy_workqueue(mhl_dev->sii9234_wq); kfree(mhl_dev); err_mem: i2c_del_driver(&sii9234c_i2c_driver); err_i2c_c_add: i2c_del_driver(&sii9234b_i2c_driver); err_i2c_b_add: i2c_del_driver(&sii9234a_i2c_driver); err_i2c_a_add: i2c_del_driver(&sii9234_i2c_driver); return ret; }