lkml.org 
[lkml]   [2021]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] net: dsa: rtl8366rb: standardize init jam tables
On Wed, Jan 27, 2021 at 12:28:05AM +0200, Vladimir Oltean wrote:
> > So, allow me to explain. The kernel jams every "i + 1" value in the array
> > tables into the registers at " i", and then increments "i" by 2.
> > These can be seen as [n][2] matrixes, just like the ethernet one.
> > Having the arrays converted to matrixes can help visualize which
> > value is jammed where, or at least that's how I feel like it is.
> > I know it's not a big change...
>
> Got it, thanks. It is better, in fact, once you get over that whole
> 0xBE00 thing...

If you really want beautiful code, I guess you could create a structure
with two fields:

struct rtl8366rb_jam_table_entry {
u16 addr;
u16 val;
};

and then convert those ugly looking matrix definitions:
u16 (*jam_table)[2]
with:
struct rtl8366rb_jam_table_entry *jam_table

and this:
ret = regmap_write(smi->map,
jam_table[i][0],
jam_table[i][1]);
with this:
ret = regmap_write(smi->map,
jam_table[i].addr,
jam_table[i].val);

The memory footprint would be exactly the same, and the struct
initializers would look exactly the same as your current array
declarations.

\
 
 \ /
  Last update: 2021-01-27 14:24    [W:0.194 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site