From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Christophe Ricard
<christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: PeterHuewe-Mmb7MZpHnFY@public.gmane.org,
ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org,
tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
christophe-h.ricard-qxv4g6HH51o@public.gmane.org,
jean-luc.blanc-qxv4g6HH51o@public.gmane.org,
benoit.houyere-qxv4g6HH51o@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
Subject: Re: [PATCH v1 08/10] tpm/tpm_i2c_stm_st33: Split tpm_i2c_tpm_st33 in 2 layers (core + phy)
Date: Mon, 12 Jan 2015 13:26:53 -0700 [thread overview]
Message-ID: <20150112202653.GC11295@obsidianresearch.com> (raw)
In-Reply-To: <1420888831-17491-9-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
On Sat, Jan 10, 2015 at 12:20:29PM +0100, Christophe Ricard wrote:
For reference:
> -static int tpm_stm_i2c_remove(struct i2c_client *client)
> -{
> - struct tpm_chip *chip =
> - (struct tpm_chip *) i2c_get_clientdata(client);
> -
> - if (chip)
> - tpm_chip_unregister(chip);
> -
> - return 0;
> -}
Became:
> +static int st33zp24_i2c_remove(struct i2c_client *client)
> +{
> + void *tpm_data = i2c_get_clientdata(client);
> +
> + if (tpm_data)
> + st33zp24_remove(tpm_data);
> +
> + return 0;
> +}
The value of i2c_get_clientdata hasn't/can't be changed, it must be
the tpm_chip, so tpm_data should be tpm_chip *, not void *.
The 'if (tpm_data)' is an anti-pattern, please remove it
Same comment applies to patch 9
> +int st33zp24_remove(void *tpm_data)
> +{
> + struct st33zp24_dev *tpm_dev = (struct st33zp24_dev *)tpm_data;
> + struct tpm_chip *chip = tpm_dev->chip;
> +
> + if (chip)
> + tpm_chip_unregister(chip);
> +
> + return 0;
> +}
Now this looks wrong. st33zp24_dev is the TPM_VPRIV of the chip, but
tpm_data is the tpm_chip already, so that cast is surely wrong.
Again, remove the 'if (chip)' anti-pattern.
> +static struct st33zp24_phy_ops i2c_phy_ops = {
> + .send = st33zp24_i2c_send,
> + .recv = st33zp24_i2c_recv,
> +};
Should be 'static const struct', same comment for patch 9
> + tpm_dev = devm_kzalloc(dev, sizeof(struct st33zp24_dev),
> + GFP_KERNEL);
> + if (!tpm_dev)
> + return -ENOMEM;
> +
> + chip = tpmm_chip_alloc(dev, &st33zp24_tpm);
> + if (IS_ERR(chip))
> + return PTR_ERR(chip);
It is idomatic in the TPM drivers for the tpmm_chip_alloc to be first,
then the priv allocation to be second. Someday we might merge the two
calls.
Jason
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-01-12 20:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-10 11:20 [PATCH v1 00/10] st33zp24 new architecture proposal and st33zp24 spi driver Christophe Ricard
[not found] ` <1420888831-17491-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2015-01-10 11:20 ` [PATCH v1 01/10] tpm/tpm_i2c_stm_st33: Remove sparse spaces Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 02/10] tpm/tpm_i2c_stm_st33: Sanity cleanup Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 03/10] tpm/tpm_i2c_stm_st33: Replace remaining r by ret Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 04/10] tpm/tpm_i2c_stm_st33: Replace access to io_lpcpd from struct st33zp24_platform_data to tpm_stm_dev Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 05/10] tpm/tpm_i2c_stm_st33: Change tpm_i2c_stm_st33.h to tpm_stm_st33.h Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 06/10] tpm/tpm_i2c_stm_st33: Add status check when reading data on the FIFO Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 07/10] tpm/tpm_i2c_stm_st33/dts/st33zp24-i2c: Rename st33zp24 dts documentation Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 08/10] tpm/tpm_i2c_stm_st33: Split tpm_i2c_tpm_st33 in 2 layers (core + phy) Christophe Ricard
[not found] ` <1420888831-17491-9-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2015-01-12 20:26 ` Jason Gunthorpe [this message]
2015-01-10 11:20 ` [PATCH v1 09/10] tpm/st33zp24/spi: Add st33zp24 spi phy Christophe Ricard
2015-01-10 11:20 ` [PATCH v1 10/10] tpm/st33zp24/dts/st33zp24-spi: Add dts documentation for " Christophe Ricard
2015-01-12 18:26 ` [PATCH v1 00/10] st33zp24 new architecture proposal and st33zp24 spi driver Jason Gunthorpe
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=20150112202653.GC11295@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=PeterHuewe-Mmb7MZpHnFY@public.gmane.org \
--cc=ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org \
--cc=benoit.houyere-qxv4g6HH51o@public.gmane.org \
--cc=christophe-h.ricard-qxv4g6HH51o@public.gmane.org \
--cc=christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=jean-luc.blanc-qxv4g6HH51o@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).