lkml.org 
[lkml]   [2020]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next v7 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices
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

\
 
 \ /
  Last update: 2020-09-09 18:08    [W:0.064 / U:28.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site