linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the char-misc tree with the tpmdd tree
@ 2017-03-22  2:13 Stephen Rothwell
  2017-03-22  2:43 ` Logan Gunthorpe
  2017-03-23 21:36 ` Jarkko Sakkinen
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Rothwell @ 2017-03-22  2:13 UTC (permalink / raw)
  To: Greg KH, Arnd Bergmann, Jarkko Sakkinen
  Cc: linux-next, linux-kernel, Logan Gunthorpe, James Bottomley,
	Jason Gunthorpe

Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  drivers/char/tpm/tpm-chip.c

between commit:

  d7a97c3e6592 ("tpm: Use the right clean up after cdev_add completes")
  5f6b4fbc12c8 ("tpm: infrastructure for TPM spaces")
  1b50e13284d7 ("tpm: expose spaces via a device link /dev/tpmrm<n>")
  849246e7ce9c ("tpm2: add session handle context saving and restoring to the space code")

from the tpmdd tree and commits:

  8dbbf5825181 ("tpm-chip: utilize new cdev_device_add helper function")

from the char-misc tree.

I fixed it up (I hope, see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/char/tpm/tpm-chip.c
index 27a76e706cfd,935f0e92ad61..000000000000
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@@ -214,22 -186,7 +214,20 @@@ struct tpm_chip *tpm_chip_alloc(struct 
  		chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
  
  	cdev_init(&chip->cdev, &tpm_fops);
 +	cdev_init(&chip->cdevs, &tpmrm_fops);
  	chip->cdev.owner = THIS_MODULE;
 +	chip->cdevs.owner = THIS_MODULE;
- 	chip->cdev.kobj.parent = &chip->dev.kobj;
- 	chip->cdevs.kobj.parent = &chip->devs.kobj;
 +
 +	chip->work_space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 +	if (!chip->work_space.context_buf) {
 +		rc = -ENOMEM;
 +		goto out;
 +	}
 +	chip->work_space.session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 +	if (!chip->work_space.session_buf) {
 +		rc = -ENOMEM;
 +		goto out;
 +	}
  
  	return chip;
  
@@@ -269,69 -225,17 +267,44 @@@ struct tpm_chip *tpmm_chip_alloc(struc
  }
  EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
  
- static void tpm_del_char_device(struct tpm_chip *chip, bool with_device)
++static void tpm_del_char_device(struct tpm_chip *chip)
 +{
- 	cdev_del(&chip->cdev);
- 	if (with_device) {
- 		device_del(&chip->dev);
- 
- 		/* Make the chip unavailable. */
- 		mutex_lock(&idr_lock);
- 		idr_replace(&dev_nums_idr, NULL, chip->dev_num);
- 		mutex_unlock(&idr_lock);
- 	}
++	cdev_device_del(&chip->cdev, &chip->dev);
++
++	/* Make the chip unavailable. */
++	mutex_lock(&idr_lock);
++	idr_replace(&dev_nums_idr, NULL, chip->dev_num);
++	mutex_unlock(&idr_lock);
 +
 +	/* Make the driver uncallable. */
 +	down_write(&chip->ops_sem);
 +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
 +		tpm2_shutdown(chip, TPM2_SU_CLEAR);
 +	chip->ops = NULL;
 +	up_write(&chip->ops_sem);
 +}
 +
  static int tpm_add_char_device(struct tpm_chip *chip)
  {
  	int rc;
  
- 	rc = cdev_add(&chip->cdev, chip->dev.devt, 1);
- 	if (rc) {
- 		dev_err(&chip->dev,
- 			"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
- 			dev_name(&chip->dev), MAJOR(chip->dev.devt),
- 			MINOR(chip->dev.devt), rc);
- 		return rc;
- 	}
- 
- 	rc = device_add(&chip->dev);
+ 	rc = cdev_device_add(&chip->cdev, &chip->dev);
  	if (rc) {
  		dev_err(&chip->dev,
- 			"unable to device_register() %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),
  			MINOR(chip->dev.devt), rc);
- 		tpm_del_char_device(chip, false);
 +		return rc;
 +	}
  
 +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
- 		rc = cdev_add(&chip->cdevs, chip->devs.devt, 1);
++		rc = cdev_device_add(&chip->cdevs, &chip->devs);
 +	if (rc) {
 +		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->devs), MAJOR(chip->devs.devt),
 +			MINOR(chip->devs.devt), rc);
- 		tpm_del_char_device(chip, true);
- 		return rc;
- 	}
- 
- 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
- 		rc = device_add(&chip->devs);
- 	if (rc) {
- 		dev_err(&chip->dev,
- 			"unable to device_register() %s, major %d, minor %d, err=%d\n",
- 			dev_name(&chip->devs), MAJOR(chip->devs.devt),
- 			MINOR(chip->devs.devt), rc);
- 		cdev_del(&chip->cdevs);
- 		tpm_del_char_device(chip, true);
++		tpm_del_char_device(chip);
  		return rc;
  	}
  
@@@ -450,10 -371,6 +423,8 @@@ void tpm_chip_unregister(struct tpm_chi
  {
  	tpm_del_legacy_sysfs(chip);
  	tpm_bios_log_teardown(chip);
- 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
- 		cdev_del(&chip->cdevs);
- 		device_del(&chip->devs);
- 	}
- 	tpm_del_char_device(chip, true);
++	if (chip->flags & TPM_CHIP_FLAG_TPM2)
++		cdev_device_del(&chip->cdevs, &chip->devs);
+ 	tpm_del_char_device(chip);
  }
  EXPORT_SYMBOL_GPL(tpm_chip_unregister);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-next: manual merge of the char-misc tree with the tpmdd tree
  2017-03-22  2:13 linux-next: manual merge of the char-misc tree with the tpmdd tree Stephen Rothwell
@ 2017-03-22  2:43 ` Logan Gunthorpe
  2017-03-23 21:36 ` Jarkko Sakkinen
  1 sibling, 0 replies; 5+ messages in thread
From: Logan Gunthorpe @ 2017-03-22  2:43 UTC (permalink / raw)
  To: Stephen Rothwell, Greg KH, Arnd Bergmann, Jarkko Sakkinen
  Cc: linux-next, linux-kernel, James Bottomley, Jason Gunthorpe

Thanks Stephen,

I've reviewed the merge and it looks correct to me.

On 21/03/17 08:13 PM, Stephen Rothwell wrote:
> I fixed it up (I hope, see below) and can carry the fix as necessary.
> This is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.

Jarko and Jason both reviewed and were aware of my patch. No one
mentioned James' work or the potential for conflict.

Logan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-next: manual merge of the char-misc tree with the tpmdd tree
  2017-03-22  2:13 linux-next: manual merge of the char-misc tree with the tpmdd tree Stephen Rothwell
  2017-03-22  2:43 ` Logan Gunthorpe
@ 2017-03-23 21:36 ` Jarkko Sakkinen
  1 sibling, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2017-03-23 21:36 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Greg KH, Arnd Bergmann, linux-next, linux-kernel,
	Logan Gunthorpe, James Bottomley, Jason Gunthorpe

On Wed, Mar 22, 2017 at 01:13:19PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> Today's linux-next merge of the char-misc tree got a conflict in:
> 
>   drivers/char/tpm/tpm-chip.c
> 
> between commit:
> 
>   d7a97c3e6592 ("tpm: Use the right clean up after cdev_add completes")

I don't think this fix is critical so I could just drop this from my
tree and send it in a separate PR after security/next is synced with
the change mentioned below.

That said, I dropped it.

>   5f6b4fbc12c8 ("tpm: infrastructure for TPM spaces")
>   1b50e13284d7 ("tpm: expose spaces via a device link /dev/tpmrm<n>")
>   849246e7ce9c ("tpm2: add session handle context saving and restoring to the space code")
> 
> from the tpmdd tree and commits:
> 
>   8dbbf5825181 ("tpm-chip: utilize new cdev_device_add helper function")
> 
> from the char-misc tree.
> 
> I fixed it up (I hope, see below) and can carry the fix as necessary.
> This is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell

Thank you. I will keep this in mind.

/Jarkko

> diff --cc drivers/char/tpm/tpm-chip.c
> index 27a76e706cfd,935f0e92ad61..000000000000
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@@ -214,22 -186,7 +214,20 @@@ struct tpm_chip *tpm_chip_alloc(struct 
>   		chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
>   
>   	cdev_init(&chip->cdev, &tpm_fops);
>  +	cdev_init(&chip->cdevs, &tpmrm_fops);
>   	chip->cdev.owner = THIS_MODULE;
>  +	chip->cdevs.owner = THIS_MODULE;
> - 	chip->cdev.kobj.parent = &chip->dev.kobj;
> - 	chip->cdevs.kobj.parent = &chip->devs.kobj;
>  +
>  +	chip->work_space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
>  +	if (!chip->work_space.context_buf) {
>  +		rc = -ENOMEM;
>  +		goto out;
>  +	}
>  +	chip->work_space.session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
>  +	if (!chip->work_space.session_buf) {
>  +		rc = -ENOMEM;
>  +		goto out;
>  +	}
>   
>   	return chip;
>   
> @@@ -269,69 -225,17 +267,44 @@@ struct tpm_chip *tpmm_chip_alloc(struc
>   }
>   EXPORT_SYMBOL_GPL(tpmm_chip_alloc);
>   
> - static void tpm_del_char_device(struct tpm_chip *chip, bool with_device)
> ++static void tpm_del_char_device(struct tpm_chip *chip)
>  +{
> - 	cdev_del(&chip->cdev);
> - 	if (with_device) {
> - 		device_del(&chip->dev);
> - 
> - 		/* Make the chip unavailable. */
> - 		mutex_lock(&idr_lock);
> - 		idr_replace(&dev_nums_idr, NULL, chip->dev_num);
> - 		mutex_unlock(&idr_lock);
> - 	}
> ++	cdev_device_del(&chip->cdev, &chip->dev);
> ++
> ++	/* Make the chip unavailable. */
> ++	mutex_lock(&idr_lock);
> ++	idr_replace(&dev_nums_idr, NULL, chip->dev_num);
> ++	mutex_unlock(&idr_lock);
>  +
>  +	/* Make the driver uncallable. */
>  +	down_write(&chip->ops_sem);
>  +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
>  +		tpm2_shutdown(chip, TPM2_SU_CLEAR);
>  +	chip->ops = NULL;
>  +	up_write(&chip->ops_sem);
>  +}
>  +
>   static int tpm_add_char_device(struct tpm_chip *chip)
>   {
>   	int rc;
>   
> - 	rc = cdev_add(&chip->cdev, chip->dev.devt, 1);
> - 	if (rc) {
> - 		dev_err(&chip->dev,
> - 			"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
> - 			dev_name(&chip->dev), MAJOR(chip->dev.devt),
> - 			MINOR(chip->dev.devt), rc);
> - 		return rc;
> - 	}
> - 
> - 	rc = device_add(&chip->dev);
> + 	rc = cdev_device_add(&chip->cdev, &chip->dev);
>   	if (rc) {
>   		dev_err(&chip->dev,
> - 			"unable to device_register() %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),
>   			MINOR(chip->dev.devt), rc);
> - 		tpm_del_char_device(chip, false);
>  +		return rc;
>  +	}
>   
>  +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> - 		rc = cdev_add(&chip->cdevs, chip->devs.devt, 1);
> ++		rc = cdev_device_add(&chip->cdevs, &chip->devs);
>  +	if (rc) {
>  +		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->devs), MAJOR(chip->devs.devt),
>  +			MINOR(chip->devs.devt), rc);
> - 		tpm_del_char_device(chip, true);
> - 		return rc;
> - 	}
> - 
> - 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> - 		rc = device_add(&chip->devs);
> - 	if (rc) {
> - 		dev_err(&chip->dev,
> - 			"unable to device_register() %s, major %d, minor %d, err=%d\n",
> - 			dev_name(&chip->devs), MAJOR(chip->devs.devt),
> - 			MINOR(chip->devs.devt), rc);
> - 		cdev_del(&chip->cdevs);
> - 		tpm_del_char_device(chip, true);
> ++		tpm_del_char_device(chip);
>   		return rc;
>   	}
>   
> @@@ -450,10 -371,6 +423,8 @@@ void tpm_chip_unregister(struct tpm_chi
>   {
>   	tpm_del_legacy_sysfs(chip);
>   	tpm_bios_log_teardown(chip);
> - 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> - 		cdev_del(&chip->cdevs);
> - 		device_del(&chip->devs);
> - 	}
> - 	tpm_del_char_device(chip, true);
> ++	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> ++		cdev_device_del(&chip->cdevs, &chip->devs);
> + 	tpm_del_char_device(chip);
>   }
>   EXPORT_SYMBOL_GPL(tpm_chip_unregister);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: linux-next: manual merge of the char-misc tree with the tpmdd tree
  2017-03-24  3:33 Stephen Rothwell
@ 2017-03-24  6:55 ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2017-03-24  6:55 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Arnd Bergmann, Jarkko Sakkinen, linux-next, linux-kernel,
	Logan Gunthorpe, James Bottomley

On Fri, Mar 24, 2017 at 02:33:02PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> Today's linux-next merge of the char-misc tree got a conflict in:
> 
>   drivers/char/tpm/tpm-chip.c
> 
> between commits:
> 
>   67b67480db8b ("tpm: infrastructure for TPM spaces")
>   b8e3586e8536 ("tpm: expose spaces via a device link /dev/tpmrm<n>")
> 
> from the tpmdd tree and commit:
> 
>   8dbbf5825181 ("tpm-chip: utilize new cdev_device_add helper function")
> 
> from the char-misc tree.
> 
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging.  You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
> 
> -- 
> Cheers,
> Stephen Rothwell
> 
> diff --cc drivers/char/tpm/tpm-chip.c
> index aade6995f310,935f0e92ad61..000000000000
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@@ -214,22 -186,7 +214,20 @@@ struct tpm_chip *tpm_chip_alloc(struct 
>   		chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
>   
>   	cdev_init(&chip->cdev, &tpm_fops);
>  +	cdev_init(&chip->cdevs, &tpmrm_fops);
>   	chip->cdev.owner = THIS_MODULE;
>  +	chip->cdevs.owner = THIS_MODULE;
> - 	chip->cdev.kobj.parent = &chip->dev.kobj;
> - 	chip->cdevs.kobj.parent = &chip->devs.kobj;
>  +
>  +	chip->work_space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
>  +	if (!chip->work_space.context_buf) {
>  +		rc = -ENOMEM;
>  +		goto out;
>  +	}
>  +	chip->work_space.session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
>  +	if (!chip->work_space.session_buf) {
>  +		rc = -ENOMEM;
>  +		goto out;
>  +	}
>   
>   	return chip;
>   
> @@@ -273,44 -229,13 +271,22 @@@ static int tpm_add_char_device(struct t
>   {
>   	int rc;
>   
> - 	rc = cdev_add(&chip->cdev, chip->dev.devt, 1);
> + 	rc = cdev_device_add(&chip->cdev, &chip->dev);
>   	if (rc) {
>   		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),
>   			MINOR(chip->dev.devt), 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;
> - 	}
> - 
> - 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> - 		rc = cdev_add(&chip->cdevs, chip->devs.devt, 1);
> - 	if (rc) {
> - 		dev_err(&chip->dev,
> - 			"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
> - 			dev_name(&chip->devs), MAJOR(chip->devs.devt),
> - 			MINOR(chip->devs.devt), rc);
> - 		return rc;
> - 	}
> - 
>  +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> - 		rc = device_add(&chip->devs);
> ++		rc = cdev_device_add(&chip->cdevs, &chip->devs);
>  +	if (rc) {
>  +		dev_err(&chip->dev,
> - 			"unable to device_register() %s, major %d, minor %d, err=%d\n",
> ++			"unable to cdev_device_add() %s, major %d, minor %d, err=%d\n",
>  +			dev_name(&chip->devs), MAJOR(chip->devs.devt),
>  +			MINOR(chip->devs.devt), rc);
> - 		cdev_del(&chip->cdevs);
>   		return rc;
>   	}
>   
> @@@ -447,10 -371,6 +422,8 @@@ void tpm_chip_unregister(struct tpm_chi
>   {
>   	tpm_del_legacy_sysfs(chip);
>   	tpm_bios_log_teardown(chip);
> - 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> - 		cdev_del(&chip->cdevs);
> - 		device_del(&chip->devs);
> - 	}
> ++	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> ++		cdev_device_del(&chip->cdevs, &chip->devs);
>   	tpm_del_char_device(chip);
>   }
>   EXPORT_SYMBOL_GPL(tpm_chip_unregister);

Looks good to me, thanks!

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* linux-next: manual merge of the char-misc tree with the tpmdd tree
@ 2017-03-24  3:33 Stephen Rothwell
  2017-03-24  6:55 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2017-03-24  3:33 UTC (permalink / raw)
  To: Greg KH, Arnd Bergmann, Jarkko Sakkinen
  Cc: linux-next, linux-kernel, Logan Gunthorpe, James Bottomley

Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  drivers/char/tpm/tpm-chip.c

between commits:

  67b67480db8b ("tpm: infrastructure for TPM spaces")
  b8e3586e8536 ("tpm: expose spaces via a device link /dev/tpmrm<n>")

from the tpmdd tree and commit:

  8dbbf5825181 ("tpm-chip: utilize new cdev_device_add helper function")

from the char-misc tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/char/tpm/tpm-chip.c
index aade6995f310,935f0e92ad61..000000000000
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@@ -214,22 -186,7 +214,20 @@@ struct tpm_chip *tpm_chip_alloc(struct 
  		chip->flags |= TPM_CHIP_FLAG_VIRTUAL;
  
  	cdev_init(&chip->cdev, &tpm_fops);
 +	cdev_init(&chip->cdevs, &tpmrm_fops);
  	chip->cdev.owner = THIS_MODULE;
 +	chip->cdevs.owner = THIS_MODULE;
- 	chip->cdev.kobj.parent = &chip->dev.kobj;
- 	chip->cdevs.kobj.parent = &chip->devs.kobj;
 +
 +	chip->work_space.context_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 +	if (!chip->work_space.context_buf) {
 +		rc = -ENOMEM;
 +		goto out;
 +	}
 +	chip->work_space.session_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 +	if (!chip->work_space.session_buf) {
 +		rc = -ENOMEM;
 +		goto out;
 +	}
  
  	return chip;
  
@@@ -273,44 -229,13 +271,22 @@@ static int tpm_add_char_device(struct t
  {
  	int rc;
  
- 	rc = cdev_add(&chip->cdev, chip->dev.devt, 1);
+ 	rc = cdev_device_add(&chip->cdev, &chip->dev);
  	if (rc) {
  		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),
  			MINOR(chip->dev.devt), 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;
- 	}
- 
- 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
- 		rc = cdev_add(&chip->cdevs, chip->devs.devt, 1);
- 	if (rc) {
- 		dev_err(&chip->dev,
- 			"unable to cdev_add() %s, major %d, minor %d, err=%d\n",
- 			dev_name(&chip->devs), MAJOR(chip->devs.devt),
- 			MINOR(chip->devs.devt), rc);
- 		return rc;
- 	}
- 
 +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
- 		rc = device_add(&chip->devs);
++		rc = cdev_device_add(&chip->cdevs, &chip->devs);
 +	if (rc) {
 +		dev_err(&chip->dev,
- 			"unable to device_register() %s, major %d, minor %d, err=%d\n",
++			"unable to cdev_device_add() %s, major %d, minor %d, err=%d\n",
 +			dev_name(&chip->devs), MAJOR(chip->devs.devt),
 +			MINOR(chip->devs.devt), rc);
- 		cdev_del(&chip->cdevs);
  		return rc;
  	}
  
@@@ -447,10 -371,6 +422,8 @@@ void tpm_chip_unregister(struct tpm_chi
  {
  	tpm_del_legacy_sysfs(chip);
  	tpm_bios_log_teardown(chip);
- 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
- 		cdev_del(&chip->cdevs);
- 		device_del(&chip->devs);
- 	}
++	if (chip->flags & TPM_CHIP_FLAG_TPM2)
++		cdev_device_del(&chip->cdevs, &chip->devs);
  	tpm_del_char_device(chip);
  }
  EXPORT_SYMBOL_GPL(tpm_chip_unregister);

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-24  7:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-22  2:13 linux-next: manual merge of the char-misc tree with the tpmdd tree Stephen Rothwell
2017-03-22  2:43 ` Logan Gunthorpe
2017-03-23 21:36 ` Jarkko Sakkinen
2017-03-24  3:33 Stephen Rothwell
2017-03-24  6:55 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).