From: Jonathan Cameron <jic23@kernel.org>
To: Dmitry Rokosov <DDRokosov@sberdevices.ru>
Cc: "robh+dt@kernel.org" <robh+dt@kernel.org>,
"stano.jakubek@gmail.com" <stano.jakubek@gmail.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"lars@metafoo.de" <lars@metafoo.de>,
"andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
"stephan@gerhold.net" <stephan@gerhold.net>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
kernel <kernel@sberdevices.ru>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver
Date: Sat, 13 Aug 2022 16:34:28 +0100 [thread overview]
Message-ID: <20220813163428.0a181cc3@jic23-huawei> (raw)
In-Reply-To: <20220809094754.akfed7hxcdvxoacj@CAB-WSD-L081021.sigma.sbrf.ru>
On Tue, 9 Aug 2022 09:47:54 +0000
Dmitry Rokosov <DDRokosov@sberdevices.ru> wrote:
> Hello Jonathan,
>
> On Sat, Aug 06, 2022 at 04:32:04PM +0100, Jonathan Cameron wrote:
>
> [...]
>
> > > +/**
> > > + * struct msa311_priv - MSA311 internal private state
> > > + * @regs: Underlying I2C bus adapter used to abstract slave
> > > + * register accesses
> > > + * @fields: Abstract objects for each registers fields access
> > > + * @dev: Device handler associated with appropriate bus client
> > > + * @lock: Protects msa311 device state between setup and data access routines
> > > + * (power transitions, samp_freq/scale tune, retrieving axes data, etc)
> > > + * @new_data_trig: Optional NEW_DATA interrupt driven trigger used
> > > + * to notify external consumers a new sample is ready
> > > + * @vdd: Optional external voltage regulator for the device power supply
> > > + */
> > > +struct msa311_priv {
> > > + struct regmap *regs;
> > > + struct regmap_field *fields[F_MAX_FIELDS];
> > > +
> > > + struct device *dev;
> > > + struct mutex lock; /* state guard */
> >
> > Shouldn't need this comment given documentation above that provides
> > more information.
>
> Without this comment checkpatch.pl raises a warning about uncommented
> lock definition.
> I agree with you, above comment is redundant, but is it okay to ignore
> such warnings before sending the patch?
>
> I'm talking about below checkpatch condition:
> =====
> # check for spinlock_t definitions without a comment.
> if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ ||
> $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
> my $which = $1;
> if (!ctx_has_comment($first_line, $linenr)) {
> CHK("UNCOMMENTED_DEFINITION",
> "$1 definition without comment\n" . $herecurr);
> }
> }
> =====
Hmm. I guess checkpatch is more stupid than I thought on this. Definitely
fine to ignore that shortcoming of checkpatch.
>
> >
> > > +
> > > + struct iio_trigger *new_data_trig;
> > > + struct regulator *vdd;
> > > +};
> > >
> >
> >
> > > +static irqreturn_t msa311_irq_thread(int irq, void *p)
> > > +{
> > > + struct msa311_priv *msa311 = iio_priv(p);
> > > + unsigned int new_data_int_enabled;
> > > + struct device *dev = msa311->dev;
> > > + int err;
> > > +
> > > + mutex_lock(&msa311->lock);
> >
> > > +
> > > + /*
> > > + * We do not check NEW_DATA int status, because of based on
> > > + * specification it's cleared automatically after a fixed time.
> > > + * So just check that is enabled by driver logic.
> >
> > That is going to be very problematic if we can have this and events coming
> > through the same interrupt pin. Not harmful for now though given you are
> > only supporting NEW_DATA for now. Just something to watch out for.
> >
>
> Actually, I have run some experiments with NEW_DATA status bits. And
> looks like we can't determince actual status of NEW_DATA virtual
> interrupt when physical IRQ is raised. I will back to this problem when
> begin Motion Events feature implementation.
>
> [...]
>
> > > + err = devm_pm_runtime_enable(dev);
> > > + if (err)
> > > + return err;
> > > +
> > > + pm_runtime_get_noresume(dev);
> > > + pm_runtime_set_autosuspend_delay(dev, MSA311_PWR_SLEEP_DELAY_MS);
> > > + pm_runtime_use_autosuspend(dev);
> > > +
> > > + err = msa311_chip_init(msa311);
> > > + if (err)
> > > + return err;
> > > +
> > > + indio_dev->modes = 0; /* setup buffered mode later */
> >
> > As per other branch, I led you astray here it seems.
> >
>
> Sorry, I've made a mistake. Comment about INDIO_DIRECT_MODE was left
> by Andy here:
>
> https://lore.kernel.org/linux-iio/CAHp75Vc0+ckNnm2tzLMPrjeFRjwoj3zy0C4koNShFRG3kP8b6w@mail.gmail.com/
>
> [...]
No problem. That's an odd historical corner case. I liked having
clear values for 'currentmode' (now in iio_opaque) and those matching
the bits set in available modes. So even if we didn't set it we'd end up
with a reserved bit which would add extra confusion.
The direct mode is currently just used as a placeholder for 'not a buffered mode',
rather than the state variable has never been set.
Jonathan
>
prev parent reply other threads:[~2022-08-13 15:24 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 13:11 [PATCH v4 0/3] iio: accel: add MSA311 accelerometer driver Dmitry Rokosov
2022-08-03 13:11 ` [PATCH v4 1/3] dt-bindings: vendor-prefixes: add MEMSensing Microsystems Co., Ltd Dmitry Rokosov
2022-08-03 13:11 ` [PATCH v4 3/3] dt-bindings: iio: accel: add dt-binding schema for msa311 accel driver Dmitry Rokosov
2022-08-03 23:41 ` Rob Herring
2022-08-03 13:11 ` [PATCH v4 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver Dmitry Rokosov
2022-08-03 17:49 ` Andy Shevchenko
2022-08-03 19:16 ` Dmitry Rokosov
2022-08-04 18:17 ` Dmitry Rokosov
2022-08-04 18:30 ` Andy Shevchenko
2022-08-05 14:04 ` Dmitry Rokosov
2022-08-05 16:03 ` Andy Shevchenko
2022-08-05 16:20 ` Dmitry Rokosov
2022-08-05 17:59 ` Andy Shevchenko
2022-08-04 18:28 ` Andy Shevchenko
2022-08-05 14:19 ` Dmitry Rokosov
2022-08-06 14:55 ` Jonathan Cameron
2022-08-09 9:52 ` Dmitry Rokosov
2022-08-09 10:05 ` Andy Shevchenko
2022-08-09 10:35 ` Dmitry Rokosov
2022-08-13 15:27 ` Jonathan Cameron
2022-08-13 15:39 ` Jonathan Cameron
2022-08-03 18:11 ` Christophe JAILLET
2022-08-03 18:39 ` Dmitry Rokosov
2022-08-03 19:18 ` Christophe JAILLET
2022-08-03 19:26 ` Dmitry Rokosov
2022-08-06 15:32 ` Jonathan Cameron
2022-08-09 9:47 ` Dmitry Rokosov
2022-08-13 15:34 ` Jonathan Cameron [this message]
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=20220813163428.0a181cc3@jic23-huawei \
--to=jic23@kernel.org \
--cc=DDRokosov@sberdevices.ru \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=kernel@sberdevices.ru \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=shawnguo@kernel.org \
--cc=stano.jakubek@gmail.com \
--cc=stephan@gerhold.net \
/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).