set_bit(chip->dev_num, dev_mask);
- scnprintf(chip->devname, sizeof(chip->devname), "tpm%d", chip->dev_num);
+ device_initialize(&chip->dev);
dev_set_drvdata(dev, chip);
else
chip->dev.devt = MKDEV(MAJOR(tpm_devt), chip->dev_num);
- dev_set_name(&chip->dev, "%s", chip->devname);
-
- device_initialize(&chip->dev);
+ rc = dev_set_name(&chip->dev, "tpm%d", chip->dev_num);
+ if (rc)
+ goto out;
cdev_init(&chip->cdev, &tpm_fops);
chip->cdev.owner = dev->driver->owner;
}
return chip;
+
+out:
+ put_device(&chip->dev);
+ return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
if (rc) {
dev_err(&chip->dev,
"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
- chip->devname, MAJOR(chip->dev.devt),
+ dev_name(&chip->dev), MAJOR(chip->dev.devt),
MINOR(chip->dev.devt), rc);
return rc;
if (rc) {
dev_err(&chip->dev,
"unable to device_register() %s, major %d, minor %d, err=%d\n",
- chip->devname, MAJOR(chip->dev.devt),
+ dev_name(&chip->dev), MAJOR(chip->dev.devt),
MINOR(chip->dev.devt), rc);
cdev_del(&chip->cdev);
if (rc)
return rc;
- chip->bios_dir = tpm_bios_log_setup(chip->devname);
+ chip->bios_dir = tpm_bios_log_setup(dev_name(&chip->dev));
return 0;
}
u8 original_int_vec;
if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags,
- chip->devname, chip) != 0) {
+ dev_name(&chip->dev), chip) != 0) {
dev_info(&chip->dev, "Unable to request irq: %d for probe\n",
irq);
return -1;