From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: Peter Huewe <peterhuewe@gmx.de>,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
"moderated list:TPM DEVICE DRIVER"
<tpmdd-devel@lists.sourceforge.net>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tpm: Fix initialization of the cdev
Date: Wed, 1 Jul 2015 15:06:05 -0700 [thread overview]
Message-ID: <20150701220605.GD36579@dtor-ws> (raw)
In-Reply-To: <20150630191531.GA29764@obsidianresearch.com>
On Tue, Jun 30, 2015 at 01:15:31PM -0600, Jason Gunthorpe wrote:
> When a cdev is contained in a dynamic structure the cdev parent kobj
> should be set to the kobj that controls the lifetime of the enclosing
> structure. In TPM's case this is the embedded struct device.
>
> Also, cdev_init 0's the whole structure, so all sets must be after,
> not before. This fixes module ref counting and cdev.
>
> Fixes: 313d21eeab92 ("tpm: device class for tpm")
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Right, when embedding cdev its lifetime should be tied to the lifetime
of the enclosing structure.
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/char/tpm/tpm-chip.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> Peter, I've only compile tests this. Thanks
>
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index 283f00a7f036..1082d4bb016a 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -129,8 +129,9 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev,
>
> device_initialize(&chip->dev);
>
> - chip->cdev.owner = chip->pdev->driver->owner;
> cdev_init(&chip->cdev, &tpm_fops);
> + chip->cdev.owner = chip->pdev->driver->owner;
> + chip->cdev.kobj.parent = &chip->dev.kobj;
>
> return chip;
> }
> --
> 2.1.4
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Dmitry
prev parent reply other threads:[~2015-07-01 22:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 19:15 [PATCH] tpm: Fix initialization of the cdev Jason Gunthorpe
2015-07-01 22:06 ` Dmitry Torokhov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150701220605.GD36579@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=jgunthorpe@obsidianresearch.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=tpmdd-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox