From: Andrew Morton <akpm@linux-foundation.org>
To: Richard MUSIL <richard.musil@st.com>
Cc: Greg KH <greg@kroah.com>,
linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net,
Marcel Selhorst <tpm@selhorst.net>
Subject: Re: [PATCH] - TPM device driver layer (tpm.c|h) - repost
Date: Mon, 19 Nov 2007 22:37:46 -0800 [thread overview]
Message-ID: <20071119223746.5f0e938f.akpm@linux-foundation.org> (raw)
In-Reply-To: <46F909CA.3030101@st.com>
On Tue, 25 Sep 2007 15:14:50 +0200 Richard MUSIL <richard.musil@st.com> wrote:
> Hello all,
>
> sometime ago I submitted patch to TPM layer, originally I thought this
> patch could be accepted into kernel (see below). However,
> since this did not happen, I wonder, if there are some problems with the
> patch or whether I am expected to do/provide something else, in order to
> have it accepted.
>
> The patch follows even more below.
>
Thanks. We prefer that contributors sign off their work as per
Documentation/SubmittingPatches. Please review that and if agrereable,
send a Signed-off-by: for this work.
> /*
> + * Once all references to platform device are down to 0,
> + * release all allocated structures.
> + * In case vendor provided release function,
> + * call it too.
> + */
> +static void tpm_dev_release(struct device *dev)
> +{
> + struct tpm_chip *chip = dev_get_drvdata(dev);
> + /* call vendor release, if defined */
That's not the most useful of comments ;)
> + if (chip->vendor.release)
> + chip->vendor.release(dev);
> +
> + /* it *should* be: chip->release != NULL */
And that one's actually wrong in the context of kernel coding practices.
But whatever.
> + if (likely(chip->release))
> + chip->release(dev);
>From my reading, neither of these fields can ever be NULL, so the tests
simply aren't needed?
> + clear_bit(chip->dev_num, dev_mask);
> + kfree(chip->vendor.miscdev.name);
> + kfree(chip);
> +}
> +
> +/*
> * Called from tpm_<specific>.c probe function only for devices
> * the driver has determined it should claim. Prior to calling
> * this function the specific probe function has called pci_enable_device
> @@ -1136,23 +1153,21 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
>
> chip->vendor.miscdev.parent = dev;
> chip->dev = get_device(dev);
> + chip->release = dev->release;
> + dev->release = tpm_dev_release;
> + dev_set_drvdata(dev, chip);
>
> if (misc_register(&chip->vendor.miscdev)) {
> dev_err(chip->dev,
> "unable to misc_register %s, minor %d\n",
> chip->vendor.miscdev.name,
> chip->vendor.miscdev.minor);
> - put_device(dev);
> - clear_bit(chip->dev_num, dev_mask);
> - kfree(chip);
> - kfree(devname);
> + put_device(chip->dev);
> return NULL;
> }
>
> spin_lock(&driver_lock);
>
> - dev_set_drvdata(dev, chip);
> -
> list_add(&chip->list, &tpm_chip_list);
>
> spin_unlock(&driver_lock);
> @@ -1160,10 +1175,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
> if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
> list_del(&chip->list);
> misc_deregister(&chip->vendor.miscdev);
> - put_device(dev);
> - clear_bit(chip->dev_num, dev_mask);
> - kfree(chip);
> - kfree(devname);
> + put_device(chip->dev);
> return NULL;
> }
>
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index b2e2b00..f1c265e 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -74,6 +74,7 @@ struct tpm_vendor_specific {
> int (*send) (struct tpm_chip *, u8 *, size_t);
> void (*cancel) (struct tpm_chip *);
> u8 (*status) (struct tpm_chip *);
> + void (*release) (struct device *);
> struct miscdevice miscdev;
> struct attribute_group *attr_group;
> struct list_head list;
> @@ -106,6 +107,7 @@ struct tpm_chip {
> struct dentry **bios_dir;
>
> struct list_head list;
> + void (*release) (struct device *);
> };
>
> #define to_tpm_chip(n) container_of(n, struct tpm_chip, vendor)
next prev parent reply other threads:[~2007-11-20 6:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-23 8:46 [PATCH] - TPM device driver layer (tpm.c|h) Richard MUSIL
2007-08-23 9:26 ` Greg KH
2007-09-25 13:14 ` [PATCH] - TPM device driver layer (tpm.c|h) - repost Richard MUSIL
2007-09-25 14:11 ` Greg KH
2007-09-28 8:08 ` [tpmdd-devel] " Marcel Selhorst
2007-11-20 6:37 ` Andrew Morton [this message]
2007-11-20 12:32 ` [PATCH] - TPM device driver layer (tpm.c|h) - 2nd repost Richard MUSIL
2007-11-20 12:53 ` Richard MUSIL
2007-11-20 20:06 ` Andrew Morton
2007-11-18 23:13 ` [tpmdd-devel] [PATCH] - TPM device driver layer (tpm.c|h) Marcel Selhorst
2007-11-19 5:09 ` Greg KH
2007-11-19 6:42 ` Marcel Selhorst
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=20071119223746.5f0e938f.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.musil@st.com \
--cc=tpm@selhorst.net \
--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