Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1527430

Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister)

From Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister)
Date 2016-11-22 12:30 +0100
Message-ID <sGhqV-6tz-9@gated-at.bofh.it> (permalink)
References <sDmn7-5BA-3@gated-at.bofh.it> <sDmn8-5BA-13@gated-at.bofh.it>
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Show all headers | View raw


On Mon, Nov 14, 2016 at 05:00:51AM -0500, Nayna Jain wrote:
> Check for TPM2 chip in tpm_sysfs_add_device, tpm_bios_log_setup and
> tpm_bios_log_teardown in order to make code flow cleaner and to enable
> to implement TPM 2.0 support later on. This is partially derived from
> the commit by Nayna Jain with the extension that also tpm1_chip_register
> is dropped.
> 
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

This commit remains unreviewed and tested. I'm in the author role here
so I cannot help with this. If that does not happen soon I cannot put
this into the pull request.

/Jarkko

> ---
>  drivers/char/tpm/tpm-chip.c     | 31 +++++--------------------------
>  drivers/char/tpm/tpm-sysfs.c    |  3 +++
>  drivers/char/tpm/tpm_eventlog.c |  3 +++
>  3 files changed, 11 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index d0c1872..250a651 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -276,28 +276,6 @@ static void tpm_del_char_device(struct tpm_chip *chip)
>  	up_write(&chip->ops_sem);
>  }
>  
> -static int tpm1_chip_register(struct tpm_chip *chip)
> -{
> -	int rc;
> -
> -	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> -		return 0;
> -
> -	tpm_sysfs_add_device(chip);
> -
> -	rc = tpm_bios_log_setup(chip);
> -
> -	return rc;
> -}
> -
> -static void tpm1_chip_unregister(struct tpm_chip *chip)
> -{
> -	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> -		return;
> -
> -	tpm_bios_log_teardown(chip);
> -}
> -
>  static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
>  {
>  	struct attribute **i;
> @@ -364,7 +342,9 @@ int tpm_chip_register(struct tpm_chip *chip)
>  			return rc;
>  	}
>  
> -	rc = tpm1_chip_register(chip);
> +	tpm_sysfs_add_device(chip);
> +
> +	rc = tpm_bios_log_setup(chip);
>  	if (rc)
>  		return rc;
>  
> @@ -372,7 +352,7 @@ int tpm_chip_register(struct tpm_chip *chip)
>  
>  	rc = tpm_add_char_device(chip);
>  	if (rc) {
> -		tpm1_chip_unregister(chip);
> +		tpm_bios_log_teardown(chip);
>  		return rc;
>  	}
>  
> @@ -402,8 +382,7 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
>  void tpm_chip_unregister(struct tpm_chip *chip)
>  {
>  	tpm_del_legacy_sysfs(chip);
> -
> -	tpm1_chip_unregister(chip);
> +	tpm_bios_log_teardown(chip);
>  	tpm_del_char_device(chip);
>  }
>  EXPORT_SYMBOL_GPL(tpm_chip_unregister);
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
> index 59a1ead..848ad65 100644
> --- a/drivers/char/tpm/tpm-sysfs.c
> +++ b/drivers/char/tpm/tpm-sysfs.c
> @@ -284,6 +284,9 @@ static const struct attribute_group tpm_dev_group = {
>  
>  void tpm_sysfs_add_device(struct tpm_chip *chip)
>  {
> +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> +		return;
> +
>  	/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
>  	 * is called before ops is null'd and the sysfs core synchronizes this
>  	 * removal so that no callbacks are running or can run again
> diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
> index 62e9da6..57ac862 100644
> --- a/drivers/char/tpm/tpm_eventlog.c
> +++ b/drivers/char/tpm/tpm_eventlog.c
> @@ -373,6 +373,9 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
>  	const char *name = dev_name(&chip->dev);
>  	unsigned int cnt;
>  
> +	if (chip->flags & TPM_CHIP_FLAG_TPM2)
> +		return 0;
> +
>  	cnt = 0;
>  	chip->bios_dir[cnt] = securityfs_create_dir(name, NULL);
>  	if (is_bad(chip->bios_dir[cnt]))
> -- 
> 2.5.0
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 0/9] tpm: cleanup/fixes in existing event log support  Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
  [PATCH v6 9/9] tpm: cleanup of printk error messages Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
    Re: [PATCH v6 9/9] tpm: cleanup of printk error messages Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-14 23:30 +0100
      Re: [PATCH v6 9/9] tpm: cleanup of printk error messages Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 01:20 +0100
  [PATCH v6 2/9] tpm: replace symbolic permission with octal for securityfs files Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
    Re: [PATCH v6 2/9] tpm: replace symbolic permission with octal for  securityfs files Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-14 23:20 +0100
    Re: [PATCH v6 2/9] tpm: replace symbolic permission with octal for  securityfs files Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-14 23:30 +0100
      Re: [tpmdd-devel] [PATCH v6 2/9] tpm: replace symbolic permission  with octal for securityfs files Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 01:20 +0100
  [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister) Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
    Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister) Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-22 12:30 +0100
      Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister) Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-22 17:50 +0100
        Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister) Nayna <nayna@linux.vnet.ibm.com> - 2016-11-24 04:20 +0100
          Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister) Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-24 13:00 +0100
        Re: [PATCH v6 4/9] tpm: drop tpm1_chip_register(/unregister) Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-24 13:00 +0100
  [PATCH v6 5/9] tpm: have event log use the tpm_chip Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
    Re: [PATCH v6 5/9] tpm: have event log use the tpm_chip Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 00:50 +0100
      Re: [PATCH v6 5/9] tpm: have event log use the tpm_chip Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 01:20 +0100
  [PATCH v6 6/9] tpm: fix the missing .owner in tpm_bios_measurements_ops Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
    Re: [PATCH v6 6/9] tpm: fix the missing .owner in  tpm_bios_measurements_ops Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-14 23:30 +0100
      Re: [PATCH v6 6/9] tpm: fix the missing .owner in  tpm_bios_measurements_ops Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 01:20 +0100
  [PATCH v6 1/9] tpm: define a generic open() method for ascii & bios measurements Nayna Jain <nayna@linux.vnet.ibm.com> - 2016-11-14 11:10 +0100
  Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-14 23:40 +0100
    Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 01:30 +0100
      Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 01:40 +0100
      Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 03:20 +0100
        Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Nayna <nayna@linux.vnet.ibm.com> - 2016-11-15 06:40 +0100
          Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 18:50 +0100
            Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-15 19:10 +0100
              Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-15 20:00 +0100
                Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-19 19:40 +0100
                Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-11-20 11:00 +0100
                Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-21 19:30 +0100

csiph-web