From: Peter Rosin <peda@lysator.liu.se>
To: Guenter Roeck <linux@roeck-us.net>, Wolfram Sang <wsa@the-dreams.de>
Cc: Peter Rosin <peda@axentia.se>, Rob Herring <robh+dt@kernel.org>,
Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Peter Korsgaard <peter.korsgaard@barco.com>,
linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/10] i2c-mux: add common core data for every mux instance
Date: Tue, 05 Jan 2016 10:05:17 +0100 [thread overview]
Message-ID: <568B874D.8020205@lysator.liu.se> (raw)
In-Reply-To: <568A919E.8040006@roeck-us.net>
Hi Guenter,
On 2016-01-04 16:37, Guenter Roeck wrote:
> On 01/04/2016 07:10 AM, Peter Rosin wrote:
>> From: Peter Rosin <peda@axentia.se>
>>
>> The initial core mux structure starts off small with only the parent
>> adapter pointer, which all muxes have, and a priv pointer for mux
>> driver private data.
>>
>> Add i2c_mux_alloc function to unify the creation of a mux.
>>
>> Where appropriate, pass around the mux core structure instead of the
>> parent adapter or the driver private data.
>>
>> Remove the parent adapter pointer from the driver private data for all
>> mux drivers.
>>
>> Signed-off-by: Peter Rosin <peda@axentia.se>
>> ---
>> drivers/i2c/i2c-mux.c | 35 ++++++++++++++++++++++++-----
>> drivers/i2c/muxes/i2c-arb-gpio-challenge.c | 24 +++++++++++---------
>> drivers/i2c/muxes/i2c-mux-gpio.c | 20 +++++++++--------
>> drivers/i2c/muxes/i2c-mux-pca9541.c | 36 ++++++++++++++++--------------
>> drivers/i2c/muxes/i2c-mux-pca954x.c | 22 +++++++++++++-----
>> drivers/i2c/muxes/i2c-mux-pinctrl.c | 24 +++++++++++---------
>> drivers/i2c/muxes/i2c-mux-reg.c | 25 ++++++++++++---------
>> include/linux/i2c-mux.h | 14 +++++++++++-
>> 8 files changed, 129 insertions(+), 71 deletions(-)
>>
*snip*
>> +struct i2c_mux_core *i2c_mux_alloc(struct device *dev, int sizeof_priv)
>> +{
>> + struct i2c_mux_core *muxc;
>> +
>> + muxc = devm_kzalloc(dev, sizeof(*muxc), GFP_KERNEL);
>> + if (!muxc)
>> + return NULL;
>> + if (sizeof_priv) {
>> + muxc->priv = devm_kzalloc(dev, sizeof_priv, GFP_KERNEL);
>> + if (!muxc->priv)
>> + goto fail;
>> + }
>
> Why not just allocate sizeof(*muxc) + sizeof_priv in a single operation
> and then assign muxc->priv to muxc + 1 if sizeof_priv > 0 ?
Why indeed, good suggestion.
*snip*
>> @@ -134,13 +134,14 @@ static int i2c_arbitrator_probe(struct platform_device *pdev)
>> return -EINVAL;
>> }
>>
>> - arb = devm_kzalloc(dev, sizeof(*arb), GFP_KERNEL);
>> - if (!arb) {
>> - dev_err(dev, "Cannot allocate i2c_arbitrator_data\n");
>> + muxc = i2c_mux_alloc(dev, sizeof(*arb));
>> + if (!muxc) {
>> + dev_err(dev, "Cannot allocate i2c_mux_core structure\n");
>
> Unnecessary error message.
>
Right, I'll remove that (and the others just like it).
I'll see if I can cook up a v2 that also converts the i2c muxes elsewhere in
drivers/ that I wasn't aware of.
Cheers,
Peter
next prev parent reply other threads:[~2016-01-05 9:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-04 15:10 [PATCH 00/10] i2c mux cleanup and locking update Peter Rosin
2016-01-04 15:10 ` [PATCH 01/10] i2c-mux: add common core data for every mux instance Peter Rosin
2016-01-04 15:37 ` Guenter Roeck
2016-01-05 9:05 ` Peter Rosin [this message]
[not found] ` <1451920215-29167-2-git-send-email-peda-SamgB31n2u5IcsJQ0EH25Q@public.gmane.org>
2016-01-04 15:46 ` kbuild test robot
2016-01-04 15:49 ` kbuild test robot
2016-01-04 15:10 ` [PATCH 02/10] i2c-mux: move select and deselect ops to i2c_mux_core Peter Rosin
2016-01-04 15:54 ` kbuild test robot
[not found] ` <1451920215-29167-3-git-send-email-peda-SamgB31n2u5IcsJQ0EH25Q@public.gmane.org>
2016-01-04 15:56 ` kbuild test robot
2016-01-04 16:01 ` kbuild test robot
2016-01-04 16:02 ` kbuild test robot
2016-01-04 15:10 ` [PATCH 03/10] i2c-mux: move the slave side adapter management " Peter Rosin
2016-01-04 16:02 ` kbuild test robot
2016-01-04 15:10 ` [PATCH 04/10] i2c-mux: remove the mux dev pointer from the mux per channel data Peter Rosin
2016-01-04 15:10 ` [PATCH 05/10] i2c-mux: pinctrl: get rid of the driver private struct device pointer Peter Rosin
2016-01-04 15:10 ` [PATCH 06/10] i2c: allow adapter drivers to override the adapter locking Peter Rosin
[not found] ` <1451920215-29167-1-git-send-email-peda-SamgB31n2u5IcsJQ0EH25Q@public.gmane.org>
2016-01-04 15:10 ` [PATCH 07/10] i2c: muxes always lock the parent adapter Peter Rosin
2016-01-04 15:10 ` [PATCH 08/10] i2c-mux: relax locking of the top i2c adapter during i2c controlled muxing Peter Rosin
2016-01-04 15:10 ` [PATCH 09/10] i2c: pca9541: get rid of the i2c deadlock workaround Peter Rosin
2016-01-04 15:10 ` [PATCH 10/10] i2c: pca954x: " Peter Rosin
2016-01-04 15:19 ` Lars-Peter Clausen
2016-01-04 15:45 ` Peter Rosin
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=568B874D.8020205@lysator.liu.se \
--to=peda@lysator.liu.se \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=peda@axentia.se \
--cc=peter.korsgaard@barco.com \
--cc=robh+dt@kernel.org \
--cc=wsa@the-dreams.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;
as well as URLs for NNTP newsgroup(s).