Linux SOC development
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy@kernel.org>
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>,
	Arnd Bergmann <arnd@arndb.de>,
	soc@kernel.org, arm@kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-gpio@vger.kernel.org,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	linux-rtc@vger.kernel.org,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 2/7] platform: cznic: Add preliminary support for Turris Omnia MCU
Date: Wed, 20 Sep 2023 16:19:53 +0200	[thread overview]
Message-ID: <20230920161953.6d952392@dellmb> (raw)
In-Reply-To: <ZQnn+Gi0xVlsGCYA@smile.fi.intel.com>

Hello Andy,

On Tue, 19 Sep 2023 21:27:04 +0300
Andy Shevchenko <andy@kernel.org> wrote:

> On Tue, Sep 19, 2023 at 05:16:38PM +0200, Marek Behún wrote:
> > On Tue, 19 Sep 2023 15:29:08 +0300
> > Andy Shevchenko <andy@kernel.org> wrote:  
> > > On Tue, Sep 19, 2023 at 12:38:10PM +0200, Marek Behún wrote:  
> 
> ...
> 
> > > >  obj-$(CONFIG_GOLDFISH)		+= goldfish/
> > > >  obj-$(CONFIG_CHROME_PLATFORMS)	+= chrome/
> > > >  obj-$(CONFIG_SURFACE_PLATFORMS)	+= surface/
> > > > +obj-$(CONFIG_CZNIC_PLATFORMS)	+= cznic/    
> > > 
> > > Why not ordered (to some extent) here (as you did in the other file)?  
> > 
> > Where should I put it? The other entries are not ordered, see
> >   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/Makefile?h=v6.6-rc2  
> 
> With the visible context above, at least after chrome already much better, no?

OK

... 
> > > Missing types.h, sysfs.h, mod_devicetable.h, i2c.h, ...  
> > 
> > i2c.h comes from turris-omnia-mcu.h. The others I will fix. Does the
> > the .c file also include all those headers if it includes a local
> > header already?  
> 
> For generic ones, yes.

OK

> > > > +	if (ret < 0)    
> > > 
> > > Can it return positive value? What would be the meaning of it?  
> > 
> > Originally I had it return 0 on success, but recently I've had a
> > discussion about this same thing with LED subsystem maintainer about
> > some LED patches, Lee Jones, who requested the _read function to return
> > number of bytes read on success. See at
> >   https://lore.kernel.org/linux-leds/20230821122644.GJ1380343@google.com/
> > where he says:
> >   Read and write APIs, even abstracted ones such as these generally
> >   return the number of bytes successfully read and written respectively.
> >   If you are going to normalise, then please do so against this
> >   standard.
> > I do not agree with him, since this is a local command accessor which
> > only succeeds if all the bytes are read/written as requested. But I
> > adjusted my code as per his request since he is the maintainer.  
> 
> This is strange. For example, regmap APIs never returns amount of data written
> or read. I think it's solely depends on the API. It might be useful for i²c
> APIs, in case you can do something about it. but if you have wrappers on top
> of that already (meaning not using directly the i2c_*() calls, I dunno the
> positive return is anyhow useful.

I shall change it back then.

...

> > > > +	int status;    
> > > 
> > > My gosh, it's a _third_ name for the same!  
> > 
> > The variable holds value of the status register, which is needed at
> > another point in this function. I thought naming it just "ret" would
> > cause confusions... Do you really propose to rename it such?  
> 
> It's not bad per se, just put yourself on the place of somebody who would like
> to understand the semantics of all these variables. Maybe you can add a comment
> on top explaining that (in short)?

OK

> > > > +	for (int i = 0; i < ARRAY_SIZE(features); ++i) {    
> > > 
> > > Why signed?  
> > 
> > Because it is shorter and makes no difference and there are tons of
> >   for (int i = 0; i < ARRAY_SIZE(x); i++)
> > in the kernel already. But if you really want, I can change it. Please
> > let me know.  
> 
> It just makes harder to get the code, because of possible unneeded questions
> like "if it's a signed type, maybe it's on purpose?"

OK

> > > Why pre-increment?  
> > 
> > Again, it makes no difference, is widely used in the kernel and I
> > personally prefer it. But I will change it if you want.  
> 
> Pre-increment usually also a sign of something special about the iterator
> variable. In non-special cases we use post-increment. And if you count
> the use of each you will see the difference.

OK

...

> > > > +	if (likely(ret == ARRAY_SIZE(msgs)))    
> > > 
> > > Why likely()? Please, justify.  
> > 
> > Becuase it is unlikely the I2C transaction will fail. In most cases, it
> > does not.  
> 
> Yes, but why likely() is needed? So, i.o.w. what's the benefit in _this_ case?

Compiler optimization (one branch avoided). But I guess this isn't a
hot path, since I2C is insanely slow anyway. OK, I shall remove the
likely() usage.

> ...
> 
> > > > +enum commands_e {    
> > > 
> > > Are you sure the name is unique enough / properly namespaced?
> > > Same Q to all enums.  
> > 
> > I can change it. I wanted it to be compatible with the header in the
> > firmware repository.  
> 
> Are these being generated, or also statically written in that repo?
> If the latter, I think better to use more unique naming schema in
> the kernel.

OK, I shall add some prefix.

Marek

  reply	other threads:[~2023-09-20 14:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 10:38 [PATCH v2 0/7] Turris Omnia MCU driver Marek Behún
2023-09-19 10:38 ` [PATCH v2 1/7] dt-bindings: arm: add cznic,turris-omnia-mcu binding Marek Behún
2023-09-20 12:37   ` Krzysztof Kozlowski
2023-09-19 10:38 ` [PATCH v2 2/7] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2023-09-19 12:29   ` Andy Shevchenko
2023-09-19 15:16     ` Marek Behún
2023-09-19 18:27       ` Andy Shevchenko
2023-09-20 14:19         ` Marek Behún [this message]
2023-09-20 14:47           ` Andy Shevchenko
2023-09-19 10:38 ` [PATCH v2 3/7] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2023-09-19 13:00   ` Andy Shevchenko
2023-09-20 17:08     ` Marek Behún
2023-09-21  9:55       ` Andy Shevchenko
2023-09-21 20:25         ` Marek Behún
2023-09-22 14:18           ` Andy Shevchenko
2023-09-25 10:03             ` Marek Behún
2023-09-25 10:29               ` Andy Shevchenko
2023-09-21 18:42     ` Marek Behún
2023-09-22 14:14       ` Andy Shevchenko
2023-09-20 11:58   ` Linus Walleij
2023-09-20 13:36     ` Andy Shevchenko
2023-09-21 19:45     ` Marek Behún
2023-09-21 20:14       ` Marek Behún
2023-09-22 14:21         ` Andy Shevchenko
2023-09-19 10:38 ` [PATCH v2 4/7] platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup Marek Behún
2023-09-19 10:38 ` [PATCH v2 5/7] platform: cznic: turris-omnia-mcu: Add support for MCU watchdog Marek Behún
2023-09-19 13:50   ` Guenter Roeck
2023-09-22 11:46     ` Marek Behún
2023-09-19 10:38 ` [PATCH v2 6/7] ARM: dts: turris-omnia: Add MCU system-controller node Marek Behún
2023-09-19 10:38 ` [PATCH v2 7/7] ARM: dts: turris-omnia: Add GPIO key node for front button Marek Behún

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=20230920161953.6d952392@dellmb \
    --to=kabel@kernel.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy@kernel.org \
    --cc=arm@kernel.org \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=gregory.clement@bootlin.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=soc@kernel.org \
    --cc=wim@linux-watchdog.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox