All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh+dt@kernel.org>
To: Peter Rosin <peda@lysator.liu.se>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Peter Rosin <peda@axentia.se>, Wolfram Sang <wsa@the-dreams.de>,
	Peter Korsgaard <peter.korsgaard@barco.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Antti Palosaari <crope@iki.fi>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Frank Rowand <frowand.list@gmail.com>,
	Grant Likely <grant.likely@linaro.org>,
	Adriana Reus <adriana.reus@intel.com>,
	Viorel Suman <viorel.suman@intel.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Terry Heo <terryheo@google.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Tommi Rantala <tt.rantala@gmail.com>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH v4 14/18] of/unittest: convert to use an explicit i2c mux core
Date: Thu, 17 Mar 2016 08:33:57 -0500	[thread overview]
Message-ID: <CAL_JsqKbQpM+=Ajt528OmvYmmOCFv+JB--=FMe=84EosVWxSiA@mail.gmail.com> (raw)
In-Reply-To: <1457044050-15230-15-git-send-email-peda@lysator.liu.se>

On Thu, Mar 3, 2016 at 4:27 PM, Peter Rosin <peda@lysator.liu.se> wrote:
> From: Peter Rosin <peda@axentia.se>
>
> Allocate an explicit i2c mux core to handle parent and child adapters
> etc. Update the select op to be in terms of the i2c mux core instead
> of the child adapter.

This doesn't tell me why
>
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/of/unittest.c | 40 +++++++++++++++-------------------------
>  1 file changed, 15 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index 979b6e415cea..a6dc4b18047e 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -1687,13 +1687,7 @@ static struct i2c_driver unittest_i2c_dev_driver = {
>
>  #if IS_BUILTIN(CONFIG_I2C_MUX)
>
> -struct unittest_i2c_mux_data {
> -       int nchans;
> -       struct i2c_adapter *adap[];
> -};
> -
> -static int unittest_i2c_mux_select_chan(struct i2c_adapter *adap,
> -                              void *client, u32 chan)
> +static int unittest_i2c_mux_select_chan(struct i2c_mux_core *muxc, u32 chan)
>  {
>         return 0;
>  }
> @@ -1701,11 +1695,11 @@ static int unittest_i2c_mux_select_chan(struct i2c_adapter *adap,
>  static int unittest_i2c_mux_probe(struct i2c_client *client,
>                 const struct i2c_device_id *id)
>  {
> -       int ret, i, nchans, size;
> +       int ret, i, nchans;
>         struct device *dev = &client->dev;
>         struct i2c_adapter *adap = to_i2c_adapter(dev->parent);
>         struct device_node *np = client->dev.of_node, *child;
> -       struct unittest_i2c_mux_data *stm;
> +       struct i2c_mux_core *muxc;
>         u32 reg, max_reg;
>
>         dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name);
> @@ -1729,25 +1723,23 @@ static int unittest_i2c_mux_probe(struct i2c_client *client,
>                 return -EINVAL;
>         }
>
> -       size = offsetof(struct unittest_i2c_mux_data, adap[nchans]);
> -       stm = devm_kzalloc(dev, size, GFP_KERNEL);
> -       if (!stm) {
> -               dev_err(dev, "Out of memory\n");
> +       muxc = i2c_mux_alloc(adap, dev, 0, 0,
> +                            unittest_i2c_mux_select_chan, NULL);
> +       if (!muxc)
>                 return -ENOMEM;
> -       }
> -       stm->nchans = nchans;
> +       ret = i2c_mux_reserve_adapters(muxc, nchans);
> +       if (ret)
> +               return ret;
>         for (i = 0; i < nchans; i++) {
> -               stm->adap[i] = i2c_add_mux_adapter(adap, dev, client,
> -                               0, i, 0, unittest_i2c_mux_select_chan, NULL);
> -               if (!stm->adap[i]) {
> +               ret = i2c_mux_add_adapter(muxc, 0, i, 0);
> +               if (ret) {
>                         dev_err(dev, "Failed to register mux #%d\n", i);
> -                       for (i--; i >= 0; i--)
> -                               i2c_del_mux_adapter(stm->adap[i]);
> +                       i2c_mux_del_adapters(muxc);
>                         return -ENODEV;
>                 }
>         }
>
> -       i2c_set_clientdata(client, stm);
> +       i2c_set_clientdata(client, muxc);
>
>         return 0;
>  };
> @@ -1756,12 +1748,10 @@ static int unittest_i2c_mux_remove(struct i2c_client *client)
>  {
>         struct device *dev = &client->dev;
>         struct device_node *np = client->dev.of_node;
> -       struct unittest_i2c_mux_data *stm = i2c_get_clientdata(client);
> -       int i;
> +       struct i2c_mux_core *muxc = i2c_get_clientdata(client);
>
>         dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name);
> -       for (i = stm->nchans - 1; i >= 0; i--)
> -               i2c_del_mux_adapter(stm->adap[i]);
> +       i2c_mux_del_adapters(muxc);
>         return 0;
>  }
>
> --
> 2.1.4
>

  reply	other threads:[~2016-03-17 13:33 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 22:27 [PATCH v4 00/18] i2c mux cleanup and locking update Peter Rosin
2016-03-03 22:27 ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 01/18] i2c-mux: add common data for every i2c-mux instance Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 02/18] i2c: i2c-mux-gpio: convert to use an explicit i2c mux core Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 03/18] i2c: i2c-mux-pinctrl: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 04/18] i2c: i2c-arb-gpio-challenge: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 05/18] i2c: i2c-mux-pca9541: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 06/18] i2c: i2c-mux-pca954x: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 07/18] i2c: i2c-mux-reg: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 08/18] iio: imu: inv_mpu6050: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 09/18] [media] m88ds3103: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 10/18] [media] rtl2830: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 11/18] [media] rtl2832: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 12/18] [media] si2168: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 13/18] [media] cx231xx: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 14/18] of/unittest: " Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-17 13:33   ` Rob Herring [this message]
2016-03-03 22:27 ` [PATCH v4 15/18] i2c-mux: drop old unused i2c-mux api Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 16/18] i2c: allow adapter drivers to override the adapter locking Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-04  5:58   ` kbuild test robot
2016-03-04  5:58     ` kbuild test robot
2016-03-04  9:33   ` Peter Rosin
2016-03-04  9:33     ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 17/18] i2c: muxes always lock the parent adapter Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-03 22:27 ` [PATCH v4 18/18] i2c-mux: relax locking of the top i2c adapter during i2c controlled muxing Peter Rosin
2016-03-03 22:27   ` Peter Rosin
2016-03-04  5:21   ` kbuild test robot
2016-03-04  5:21     ` kbuild test robot
2016-03-04  7:10   ` Peter Rosin
2016-03-04  7:10     ` Peter Rosin
2016-03-04 17:44   ` kbuild test robot
2016-03-04 17:44     ` kbuild test robot
2016-03-04 11:01 ` [PATCH v4 00/18] i2c mux cleanup and locking update Peter Rosin
2016-03-04 14:49   ` Peter Rosin
2016-03-04 14:49     ` Peter Rosin
2016-03-15 14:09 ` Peter Rosin
2016-03-15 17:08   ` Antti Palosaari
2016-03-15 17:08     ` Antti Palosaari

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='CAL_JsqKbQpM+=Ajt528OmvYmmOCFv+JB--=FMe=84EosVWxSiA@mail.gmail.com' \
    --to=robh+dt@kernel.org \
    --cc=adriana.reus@intel.com \
    --cc=arnd@arndb.de \
    --cc=crope@iki.fi \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=hans.verkuil@cisco.com \
    --cc=jic23@kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mchehab@osg.samsung.com \
    --cc=peda@axentia.se \
    --cc=peda@lysator.liu.se \
    --cc=peter.korsgaard@barco.com \
    --cc=pmeerw@pmeerw.net \
    --cc=terryheo@google.com \
    --cc=tt.rantala@gmail.com \
    --cc=viorel.suman@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.