Re: [PATCH RFC 3/5] Add KSZ8795 switch driver

From: Andrew Lunn
Date: Sat Sep 09 2017 - 11:45:49 EST


On Sat, Sep 09, 2017 at 01:44:37AM +0000, Tristram.Ha@xxxxxxxxxxxxx wrote:
> > -----Original Message-----
> > From: Pavel Machek [mailto:pavel@xxxxxx]
> > Sent: Friday, September 08, 2017 2:58 PM
> > To: Tristram Ha - C24268
> > Cc: andrew@xxxxxxx; muvarov@xxxxxxxxx; nathan.leigh.conrad@xxxxxxxxx;
> > vivien.didelot@xxxxxxxxxxxxxxxxxxxx; f.fainelli@xxxxxxxxx;
> > netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Woojung Huh -
> > C21699
> > Subject: Re: [PATCH RFC 3/5] Add KSZ8795 switch driver
> >
> > Hi!
> >
> > > > > + default:
> > > > > + processed = false;
> > > > > + break;
> > > > > + }
> > > > > + if (processed)
> > > > > + *val = data;
> > > > > +}
> > > >
> > > > Similar code will be needed by other drivers, right?
> > >
> > > Although KSZ8795 and KSZ8895 may use the same code, the other
> > > chips will have different code.
> >
> > Ok, please make sure code is shared between these two.
>
> The exact function probably cannot be shared between KSZ8795
> and KSZ8895 drivers because although the register constants look
> the same but their exact locations are different in the 2 chips.

You need to be careful with such functions. If they look identical,
somebody will try to consolidate them into one. So either you need to
do the consolidation yourself in order to get it right, or you need to
add a comment about how it differs.

Andrew