static int amlogic_thermal_probe(struct platform_device *pdev) { int ret, trim_flag; struct amlogic_thermal_platform_data *pdata=NULL; device_rename(&pdev->dev, "thermal"); dbg_dev = &pdev->dev; ret = thermal_firmware_init(); if (ret < 0) { THERMAL_INFO("this chip is not trimmed, can't use thermal\n"); trim_flag = 0; return -ENODEV; } else { THERMAL_INFO("this chip is trimmed, use thermal\n"); trim_flag = 1; } pdata = amlogic_thermal_initialize(pdev, trim_flag); if (!pdata) { dev_err(&pdev->dev, "Failed to initialize thermal\n"); goto err; } mutex_init(&pdata->lock); pdev->dev.platform_data=pdata; platform_set_drvdata(pdev, pdata); ret = amlogic_register_thermal(pdata, pdev); if (ret) { dev_err(&pdev->dev, "Failed to register thermal interface\n"); goto err; } return 0; err: platform_set_drvdata(pdev, NULL); return ret; }
static int irda_probe(struct platform_device *pdev) { int ret; struct device_node *np; struct irda_private_data *pdata; np= pdev->dev.of_node; if (np ==NULL) { hwlog_err("none device\n"); ret = -ENODEV; goto error; } pdata = kzalloc(sizeof(struct irda_private_data), GFP_KERNEL); if (NULL == pdata) { hwlog_err("failed to allocate irda_private_data\n"); ret = -ENOMEM; goto error; } ret = device_rename(&pdev->dev, "irda_maxim"); if (ret) { hwlog_err("dev rename err\n"); goto free_data; } pdata->gpio_reset.gpio= of_get_named_gpio(np, IRDA_POWER_CONTROL_GPIO, 0); if (!gpio_is_valid(pdata->gpio_reset.gpio)) { hwlog_err("gpio is not valid\n"); ret = -EINVAL; goto free_data; } ret = gpio_request(pdata->gpio_reset.gpio, "irda_gpio"); if (ret) { hwlog_err("gpio[%ud] request faile", pdata->gpio_reset.gpio); goto free_data; } ret = device_create_file(&pdev->dev, &dev_attr_power_cfg); if (ret) { hwlog_err("create file err !\n"); goto free_gpio; } gpio_direction_output(pdata->gpio_reset.gpio, 0); platform_set_drvdata(pdev, pdata); hwlog_info("platform device probe success\n"); return 0; free_gpio: gpio_free(pdata->gpio_reset.gpio); free_data: kfree(pdata); error: return ret; }
int udev_device_rename(struct udev_device *udev_device, const char *name) { int r; assert(udev_device); r = device_rename(udev_device->device, name); if (r < 0) return r; return 0; }