All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: "Ondřej Jirman" <megi@xff.cz>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Andrey Skvortsov <andrej.skvortzov@gmail.com>,
	Icenowy Zheng <icenowy@aosc.io>, <linux-iio@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Dalton Durst <dalton@ubports.com>,
	"Shoji Keita" <awaittrot@shjk.jp>
Subject: Re: [PATCH 4/4] iio: magnetometer: add a driver for Voltafield AF8133J magnetometer
Date: Wed, 14 Feb 2024 16:28:18 +0000	[thread overview]
Message-ID: <20240214162818.0000221a@Huawei.com> (raw)
In-Reply-To: <skmvl3wxom6jnfh4fcvpkmswswwkfj3yopb6ahvymcwrxw5ou4@ljzmreuqiwme>

On Mon, 12 Feb 2024 16:04:02 +0100
Ondřej Jirman <megi@xff.cz> wrote:

> Hi Jonathan,
> 
> thank you for the patch review.
> 
> On Mon, Feb 12, 2024 at 01:02:32PM +0000, Jonathan Cameron wrote:
> > On Sun, 11 Feb 2024 21:52:00 +0100
> > Ondřej Jirman <megi@xff.cz> wrote:
> >   
> > > From: Icenowy Zheng <icenowy@aosc.io>
> > > 
> > > AF8133J is a simple I2C-connected magnetometer, without interrupts.
> > > 
> > > Add a simple IIO driver for it.
> > > 
> > > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > > Signed-off-by: Dalton Durst <dalton@ubports.com>
> > > Signed-off-by: Shoji Keita <awaittrot@shjk.jp>
> > > Signed-off-by: Ondrej Jirman <megi@xff.cz>  
> > 
> > This is a lot of sign offs.  If accurate it menas.
> > 
> > Icenowy wrote teh driver,
> > Dalton then 'handled' it on the path to Shoji who
> > then 'handled' it on the path to Ondrej.
> > 
> > That's possible if it's been in various other trees for instance, but
> > I'd like some more explanation below the --- if that is the case.
> > Otherwise, maybe Co-developed-by: is appropriate for some of
> > the above list?  
> 
> Icenowy wrote basic driver, initially. Here's some older version with only Icenowy sign off:
> 
> https://github.com/Icenowy/linux/commit/468ceb921dae9d75064c46d13c60cab2b42362b3
Ok. So probably the author should be Icenowy as you have it.
> 
> I picked the patch into my linux tree a few years back from one of the Mobile
> Linux distributions, likely Mobian:
> 
> https://megous.com/git/linux/commit/?h=af8133j-5.17&id=1afd43b002a02cade051acbe7851101258e60194
> 
> So I guess Dalton and/or Shoji added the orientation matrix support, because
> that and addition of some error logging is the only difference between pure Icenowy
> version and the version with other sign offs.
ok.  If we can figure that out, seems like co-developed for them as well is appropriate.

> 
> Then I rewrote large parts of the driver and added a few new features, like
> support for changing the scale/range, RPM, and buffered mode.
Defintely a co-developed for you then!
> 
> So I don't know how to reflect this in the tags. :) It passed through all of
> these people, and all of them touched it in some way, I think.

Lots of co-developed probably most appropriate.  Basically add one for each
SoB other than Iceynow's

> > > +
> > > +static int af8133j_power_up(struct af8133j_data *data)
> > > +{
> > > +	struct device *dev = &data->client->dev;
> > > +	int ret;
> > > +
> > > +	if (data->powered)
> > > +		return 0;
> > > +
> > > +	ret = regulator_bulk_enable(AF8133J_NUM_SUPPLIES, data->supplies);
> > > +	if (ret) {
> > > +		dev_err(dev, "Could not enable regulators\n");
> > > +		return ret;
> > > +	}
> > > +
> > > +	gpiod_set_value_cansleep(data->reset_gpiod, 0);
> > > +
> > > +	/* Wait for power on reset */
> > > +	usleep_range(15000, 16000);
> > > +
> > > +	data->powered = true;  
> > 
> > Why is this needed?  The RPM code is reference counted, so I don't think
> > we should need this.  
> 
> It's here because of code in af8133j_remove just disables RPM and then calls
> af8133j_power_down(). I guess it can be done via RPM, too, by disabling
> autosuspend and leaving it to RPM callbacks.

ah. Don't use a flag for that, add a little utility function
that takes it as an explicit parameter.  Make sure you wake the device
up using runtime_pm then disable runtime pm before powering it down manually.

> 
> > > +	return 0;

...


> > > +
> > > +	ret = af8133j_take_measurement(data);
> > > +	if (ret == 0)
> > > +		ret = regmap_bulk_read(data->regmap, AF8133J_REG_OUT,
> > > +				       buf, sizeof(__le16) * 3);
> > > +
> > > +	mutex_unlock(&data->mutex);
> > > +
> > > +	pm_runtime_mark_last_busy(dev);
> > > +	if (pm_runtime_put_autosuspend(dev))
> > > +		dev_err(dev, "failed to power off\n");  
> > I think this will only happen if suspend returns non 0 and yours
> > doesn't.  What else might cause this?  
> 
> I don't know, there's quite a deep callflow under
> https://elixir.bootlin.com/linux/latest/source/include/linux/pm_runtime.h#L470
> with a lot of error paths. I'd say it's very unlikely to get na error here.
> 
> I can drop it if you like.

I would.  If something odd is going on a developer can easily
add a check back in to debug it.
> 
> > > +
> > > +	return ret;
> > > +}  

...

> >   
> > > +	pm_runtime_enable(dev);
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static void af8133j_remove(struct i2c_client *client)
> > > +{
> > > +	struct iio_dev *indio_dev = i2c_get_clientdata(client);
> > > +	struct af8133j_data *data = iio_priv(indio_dev);
> > > +	struct device *dev = &data->client->dev;
> > > +
> > > +	pm_runtime_disable(dev);
> > > +	pm_runtime_set_suspended(dev);
> > > +
> > > +	af8133j_power_down(data);  
> > 
> > Can normally push these into callbacks using
> > devm_add_action_or_reset() 
> > That avoids need for either explicit error handling or a remove()
> > 
> > You power the device down here, but there isn't a matching call to
> > power it up in probe() (as it is powered down in there - which you
> > should leave to runtime_pm())  
> 
> Yes, that's the reason for powered tracking in the driver.
> 
ok.  Try and avoid that and just let runtime pm deal with it for you.

For future reference, crop out anything you have commented on in
a review. It saves on scrolling and reduces chances of stuff being
missed in the dicussion.


Jonathan


  reply	other threads:[~2024-02-14 16:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-11 20:51 [PATCH 0/4] Add support for AF8133J magnetometer Ondřej Jirman
2024-02-11 20:51 ` [PATCH 1/4] dt-bindings: vendor-prefix: Add prefix for Voltafield Ondřej Jirman
2024-02-12  7:58   ` Krzysztof Kozlowski
2024-02-11 20:51 ` [PATCH 2/4] dt-bindings: iio: magnetometer: Add DT binding for Voltafield AF8133J Ondřej Jirman
2024-02-11 22:32   ` Rob Herring
2024-02-12 11:47   ` Jonathan Cameron
2024-02-12 13:38     ` Ondřej Jirman
2024-02-14 16:31       ` Jonathan Cameron
2024-02-14 17:29         ` Conor Dooley
2024-02-14 17:44         ` Ondřej Jirman
2024-02-12 12:05   ` kernel test robot
2024-02-11 20:51 ` [PATCH 3/4] MAINTAINERS: Add an entry for AF8133J driver Ondřej Jirman
2024-02-12  7:59   ` Krzysztof Kozlowski
2024-02-11 20:52 ` [PATCH 4/4] iio: magnetometer: add a driver for Voltafield AF8133J magnetometer Ondřej Jirman
2024-02-12 12:04   ` kernel test robot
2024-02-12 13:02   ` Jonathan Cameron
2024-02-12 15:04     ` Ondřej Jirman
2024-02-14 16:28       ` Jonathan Cameron [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-02-12 10:17 kernel test robot

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=20240214162818.0000221a@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=andrej.skvortzov@gmail.com \
    --cc=awaittrot@shjk.jp \
    --cc=conor+dt@kernel.org \
    --cc=dalton@ubports.com \
    --cc=devicetree@vger.kernel.org \
    --cc=icenowy@aosc.io \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=megi@xff.cz \
    --cc=robh+dt@kernel.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 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.