From: Vadym Kochan <vadym.kochan@plvision.eu>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@mellanox.com>,
Ido Schimmel <idosch@mellanox.com>, Andrew Lunn <andrew@lunn.ch>,
Oleksandr Mazur <oleksandr.mazur@plvision.eu>,
Serhiy Boiko <serhiy.boiko@plvision.eu>,
Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
Taras Chornyi <taras.chornyi@plvision.eu>,
Andrii Savka <andrii.savka@plvision.eu>,
netdev <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Mickey Rachamim <mickeyr@marvell.com>
Subject: Re: [PATCH net-next v7 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices
Date: Wed, 9 Sep 2020 17:17:11 +0300 [thread overview]
Message-ID: <20200909141711.GC20411@plvision.eu> (raw)
In-Reply-To: <CAHp75Ve_YJneS7qOY-CXtjB0QJKUBPMUi6nMkp93YMXkuYOfkw@mail.gmail.com>
On Mon, Sep 07, 2020 at 10:55:49AM +0300, Andy Shevchenko wrote:
> On Mon, Sep 7, 2020 at 10:30 AM Vadym Kochan <vadym.kochan@plvision.eu> wrote:
> > On Fri, Sep 04, 2020 at 10:12:07PM +0300, Andy Shevchenko wrote:
> > > On Fri, Sep 4, 2020 at 7:52 PM Vadym Kochan <vadym.kochan@plvision.eu> wrote:
>
> I'm assuming that you agree on all non-commented.
>
> ...
>
> > > > +#define prestera_dev(sw) ((sw)->dev->dev)
> > >
> > > The point of this is...? (What I see it's 2 characters longer)
> > >
> > > ...
> > It is not about the length but rather about easier semantics, so
> > the prestera_dev() is more easier to remember than sw->dev->dev.
>
> It actually makes it opposite, now I have to go somewhere in the file,
> quite far from the place where it is used, and check what it is. Then
> I return to the code I'm reading and after a few more lines of code I
> will forget what that macro means.
>
> ...
Here are my points why I'd like to keep this macro:
1) It hides accessing of the 'struct device * dev' which may help in
the future if the 'dev' will move to other place or if there will
some additional logic to get this.
This is the main point.
2) I think that even by reading sw->dev->dev the developer will jump to the
place where it is defined.
This is not strong point and really by seen just sw->dev->dev at
it is more understandable to see where 'dev' sits.
3) From the code-writing perspective it was easier for developer
prestera_dev() instead of sw->dev->dev.
This is how I felt during the writing the code.
>
> > > > + /* firmware requires that port's mac address consist of the first
> > > > + * 5 bytes of base mac address
> > > > + */
> > >
> > >
> > > > + memcpy(dev->dev_addr, sw->base_mac, dev->addr_len - 1);
> > >
> > > Can't you call above helper for that?
> >
> > Not sure if I got this right, but I assume that may be just use
> > ether_addr_copy() and then just perform the below assignment on the
> > last byte ?
>
> No, I mean the function where you have the same comment and something
> else. I'm wondering if you may call it from here. Or refactor code to
> make it possible to call from here.
>
> --
> With Best Regards,
> Andy Shevchenko
next prev parent reply other threads:[~2020-09-09 16:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 16:52 [PATCH net-next v7 0/6] net: marvell: prestera: Add Switchdev driver for Prestera family ASIC device 98DX3255 (AC3x) Vadym Kochan
2020-09-04 16:52 ` [PATCH net-next v7 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices Vadym Kochan
2020-09-04 19:12 ` Andy Shevchenko
2020-09-07 7:30 ` Vadym Kochan
2020-09-07 7:55 ` Andy Shevchenko
2020-09-09 14:17 ` Vadym Kochan [this message]
2020-09-08 8:35 ` Vadym Kochan
2020-09-08 9:38 ` Andy Shevchenko
2020-09-09 14:00 ` Vadym Kochan
2020-09-09 14:09 ` Andy Shevchenko
2020-09-10 8:25 ` Vadym Kochan
2020-09-10 11:28 ` Andy Shevchenko
2020-09-04 16:52 ` [PATCH net-next v7 2/6] net: marvell: prestera: Add PCI interface support Vadym Kochan
2020-09-04 19:25 ` Andy Shevchenko
2020-09-04 16:52 ` [PATCH net-next v7 3/6] net: marvell: prestera: Add basic devlink support Vadym Kochan
2020-09-04 16:52 ` [PATCH net-next v7 4/6] net: marvell: prestera: Add ethtool interface support Vadym Kochan
2020-09-04 19:38 ` Andy Shevchenko
2020-09-04 16:52 ` [PATCH net-next v7 5/6] net: marvell: prestera: Add Switchdev driver implementation Vadym Kochan
2020-09-04 19:41 ` Andy Shevchenko
2020-09-10 7:03 ` Vadym Kochan
2020-09-04 16:52 ` [PATCH net-next v7 6/6] dt-bindings: marvell,prestera: Add description for device-tree bindings Vadym Kochan
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=20200909141711.GC20411@plvision.eu \
--to=vadym.kochan@plvision.eu \
--cc=andrew@lunn.ch \
--cc=andrii.savka@plvision.eu \
--cc=andy.shevchenko@gmail.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mickeyr@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=oleksandr.mazur@plvision.eu \
--cc=serhiy.boiko@plvision.eu \
--cc=serhiy.pshyk@plvision.eu \
--cc=taras.chornyi@plvision.eu \
--cc=volodymyr.mytnyk@plvision.eu \
/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).