|
@@ -187,7 +187,6 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
|
|
|
|
|
|
cdev_init(&chip->cdev, &tpm_fops);
|
|
cdev_init(&chip->cdev, &tpm_fops);
|
|
chip->cdev.owner = THIS_MODULE;
|
|
chip->cdev.owner = THIS_MODULE;
|
|
- chip->cdev.kobj.parent = &chip->dev.kobj;
|
|
|
|
|
|
|
|
return chip;
|
|
return chip;
|
|
|
|
|
|
@@ -230,27 +229,16 @@ static int tpm_add_char_device(struct tpm_chip *chip)
|
|
{
|
|
{
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
- rc = cdev_add(&chip->cdev, chip->dev.devt, 1);
|
|
|
|
|
|
+ rc = cdev_device_add(&chip->cdev, &chip->dev);
|
|
if (rc) {
|
|
if (rc) {
|
|
dev_err(&chip->dev,
|
|
dev_err(&chip->dev,
|
|
- "unable to cdev_add() %s, major %d, minor %d, err=%d\n",
|
|
|
|
|
|
+ "unable to cdev_device_add() %s, major %d, minor %d, err=%d\n",
|
|
dev_name(&chip->dev), MAJOR(chip->dev.devt),
|
|
dev_name(&chip->dev), MAJOR(chip->dev.devt),
|
|
MINOR(chip->dev.devt), rc);
|
|
MINOR(chip->dev.devt), rc);
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
- rc = device_add(&chip->dev);
|
|
|
|
- if (rc) {
|
|
|
|
- dev_err(&chip->dev,
|
|
|
|
- "unable to device_register() %s, major %d, minor %d, err=%d\n",
|
|
|
|
- dev_name(&chip->dev), MAJOR(chip->dev.devt),
|
|
|
|
- MINOR(chip->dev.devt), rc);
|
|
|
|
-
|
|
|
|
- cdev_del(&chip->cdev);
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/* Make the chip available. */
|
|
/* Make the chip available. */
|
|
mutex_lock(&idr_lock);
|
|
mutex_lock(&idr_lock);
|
|
idr_replace(&dev_nums_idr, chip, chip->dev_num);
|
|
idr_replace(&dev_nums_idr, chip, chip->dev_num);
|
|
@@ -261,8 +249,7 @@ static int tpm_add_char_device(struct tpm_chip *chip)
|
|
|
|
|
|
static void tpm_del_char_device(struct tpm_chip *chip)
|
|
static void tpm_del_char_device(struct tpm_chip *chip)
|
|
{
|
|
{
|
|
- cdev_del(&chip->cdev);
|
|
|
|
- device_del(&chip->dev);
|
|
|
|
|
|
+ cdev_device_del(&chip->cdev, &chip->dev);
|
|
|
|
|
|
/* Make the chip unavailable. */
|
|
/* Make the chip unavailable. */
|
|
mutex_lock(&idr_lock);
|
|
mutex_lock(&idr_lock);
|