From: Jean Delvare <khali@linux-fr.org>
To: Andrew Armenia <andrew@asquaredlabs.com>
Cc: Ben Dooks <ben-linux@fluff.org>,
Wolfram Sang <w.sang@pengutronix.de>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] i2c-piix4: separate registration and probing code
Date: Thu, 14 Jun 2012 21:38:04 +0200 [thread overview]
Message-ID: <20120614213804.46ffe67d@endymion.delvare> (raw)
In-Reply-To: <1339606749-4578-3-git-send-email-andrew@asquaredlabs.com>
Hi Andrew,
On Wed, 13 Jun 2012 12:59:08 -0400, Andrew Armenia wrote:
> Some chipsets have multiple sets of SMBus registers each controlling a
> separate SMBus. Supporting these chipsets properly will require registering
> multiple I2C adapters for one piix4.
>
> The code to initialize and register the i2c_adapter structure has been
> separated from piix4_probe and allows registration of a piix4 adapter
> given its base address. Note that the i2c_adapter and i2c_piix4_adapdata
> structures are now dynamically allocated.
>
> Signed-off-by: Andrew Armenia <andrew@asquaredlabs.com>
> ---
> drivers/i2c/busses/i2c-piix4.c | 113 ++++++++++++++++++++++++++--------------
> 1 file changed, 73 insertions(+), 40 deletions(-)
> (...)
Applied, with the minor changes below:
> -static int piix4_transaction(unsigned short piix4_smba)
> +static int piix4_transaction(struct i2c_adapter *piix4_adapter)
> {
> int temp;
> int result = 0;
> int timeout = 0;
>
> - dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
> + struct i2c_piix4_adapdata *adapdata;
> + unsigned short piix4_smba;
> +
> + adapdata = i2c_get_adapdata(piix4_adapter);
> + piix4_smba = adapdata->smba;
It is customary to declare and assign all at once in this case:
struct i2c_piix4_adapdata *adapdata = i2c_get_adapdata(piix4_adapter);
unsigned short piix4_smba = adapdata->smba;
This makes the code more compact and more readable too. I've fixed it
and everywhere else.
> (...)
> +static int __devinit piix4_add_adapter(struct pci_dev *dev,
> + unsigned short smba,
> + struct i2c_adapter **padap)
> +{
> + struct i2c_adapter *adap;
> + struct i2c_piix4_adapdata *adapdata;
> +
> + int retval;
> +
> + adap = kzalloc(sizeof(*adap), GFP_KERNEL);
> + if (NULL == adap)
There's no point in inverting comparisons this way. Compilers would let
you know if you had it wrong, they do for at least 10 years now.
--
Jean Delvare
next prev parent reply other threads:[~2012-06-14 19:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120613094739.360967aa@endymion.delvare>
2012-06-13 16:59 ` [PATCH 0/3] i2c-piix4: Multiple piix4-compatible SMBus support (revised) Andrew Armenia
2012-06-13 16:59 ` [PATCH 1/3] i2c-piix4: eliminate piix4_smba global variable Andrew Armenia
2012-06-13 19:37 ` Jean Delvare
2012-06-13 16:59 ` [PATCH 2/3] i2c-piix4: separate registration and probing code Andrew Armenia
2012-06-14 19:38 ` Jean Delvare [this message]
2012-06-13 16:59 ` [PATCH 3/3] i2c-piix4: support AMD auxiliary SMBus controller Andrew Armenia
2012-06-15 8:31 ` Jean Delvare
2012-06-15 13:43 ` Andrew Armenia
2012-06-16 6:51 ` Jean Delvare
2012-06-04 7:16 [PATCH] i2c-piix4: support multiple PIIX4 SMBus hosts Jean Delvare
2012-06-05 1:49 ` [PATCH 0/3] Multiple piix4-compatible SMBus support Andrew Armenia
2012-06-05 1:49 ` [PATCH 2/3] i2c-piix4: separate registration and probing code Andrew Armenia
2012-06-12 12:10 ` Jean Delvare
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=20120614213804.46ffe67d@endymion.delvare \
--to=khali@linux-fr.org \
--cc=andrew@asquaredlabs.com \
--cc=ben-linux@fluff.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=w.sang@pengutronix.de \
/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