All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	Hayes Wang <hayeswang@realtek.com>
Subject: Re: [PATCH net-next 3/5] r8152: add MCU typed read/write functions
Date: Wed, 4 Nov 2020 12:10:53 +0100	[thread overview]
Message-ID: <20201104121053.44fae8c7@kernel.org> (raw)
In-Reply-To: <20201104110059.whkku3zlck6spnzj@skbuf>

On Wed, 4 Nov 2020 13:00:59 +0200
Vladimir Oltean <olteanv@gmail.com> wrote:

> On Wed, Nov 04, 2020 at 11:35:45AM +0100, Marek Behún wrote:
> > Or something like this?
> > 
> > #define DEF_R_FUNC(_t, _r, _r_i, _mcu)				\
> > static inline _t _r(struct r8152 *tp, u16 index)		\
> > {								\
> > 	return _r_i(tp, _mcu, index);				\
> > }
> > 
> > #define DEF_W_FUNC(_t, _w, _w_i, _mcu)				\
> > static inline void _w(struct r8152 *tp, u16 index, _t data)	\
> > {								\
> > 	_w_i(tp, _mcu, index, data);				\
> > }
> > 
> > DEF_R_FUNC(u8, pla_ocp_read_byte, ocp_read_byte, MCU_TYPE_PLA)
> > DEF_W_FUNC(u8, pla_ocp_write_byte, ocp_write_byte, MCU_TYPE_PLA)
> > DEF_R_FUNC(u16, pla_ocp_read_word, ocp_read_word, MCU_TYPE_PLA)
> > DEF_W_FUNC(u16, pla_ocp_write_word, ocp_write_word, MCU_TYPE_PLA)
> > DEF_R_FUNC(u32, pla_ocp_read_dword, ocp_read_dword, MCU_TYPE_PLA)
> > DEF_W_FUNC(u32, pla_ocp_write_dword, ocp_write_dword, MCU_TYPE_PLA)
> > 
> > DEF_R_FUNC(u8, usb_ocp_read_byte, ocp_read_byte, MCU_TYPE_USB)
> > DEF_W_FUNC(u8, usb_ocp_write_byte, ocp_write_byte, MCU_TYPE_USB)
> > DEF_R_FUNC(u16, usb_ocp_read_word, ocp_read_word, MCU_TYPE_USB)
> > DEF_W_FUNC(u16, usb_ocp_write_word, ocp_write_word, MCU_TYPE_USB)
> > DEF_R_FUNC(u32, usb_ocp_read_dword, ocp_read_dword, MCU_TYPE_USB)
> > DEF_W_FUNC(u32, usb_ocp_write_dword, ocp_write_dword, MCU_TYPE_USB)  
> 
> I'm not sure it's worth the change :(
> Let's put it another way, your diffstat has 338 insertions and 335
> deletions. Aka you're saving 3 lines overall.
> With this new approach that doesn't use token concatenation at all,
> you're probably not saving anything at all.
> Also, I'm not sure that you need to make the functions inline. The
> compiler should be smart enough to not generate functions for
> usb_ocp_read_byte etc. You can check with
> "make drivers/net/usb/r8152.lst".

Vladimir, the purpose of this patch isn't to save lines, but to save us
from always writing MCU_TYPE_USB / MCU_TYPE_PLA.
It just transforms forms of
  ocp_read_word(tp, MCU_TYPE_USB, idx);
  ocp_write_dword(tp, MCU_TYPE_PLA, idx, val);
into
  usb_ocp_read_word(tp, idx);
  pla_ocp_write_dword(tp, idx, val);

The fifth patch of this series saves lines by adding _modify functions,
to transform
  val = *_read(idx);
  val &= ~clr;
  val |= set;
  *_write(idx, val);
into
  *_modify(idx, clr, set);


  reply	other threads:[~2020-11-04 11:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 19:22 [PATCH net-next 0/5] r8152 changes Marek Behún
2020-11-03 19:22 ` [PATCH net-next 1/5] r8152: use generic USB macros to define product table Marek Behún
2020-11-04  1:57   ` Hayes Wang
2020-11-04  6:02     ` Marek Behún
2020-11-04  7:14       ` Hayes Wang
2020-11-04  8:53     ` Greg KH
2020-11-03 19:22 ` [PATCH net-next 2/5] r8152: cosmetic improvement of product table macro Marek Behún
2020-11-03 19:22 ` [PATCH net-next 3/5] r8152: add MCU typed read/write functions Marek Behún
2020-11-03 21:47   ` Vladimir Oltean
2020-11-04  5:55     ` Marek Behún
2020-11-04  8:47       ` Vladimir Oltean
2020-11-04 10:25         ` Marek Behún
2020-11-04 10:35           ` Marek Behún
2020-11-04 11:00             ` Vladimir Oltean
2020-11-04 11:10               ` Marek Behún [this message]
2020-11-04 12:14                 ` Vladimir Oltean
2020-11-04 21:07                   ` Jakub Kicinski
2020-11-05  9:54                   ` Marek Behún
2020-11-05 10:56                     ` Vladimir Oltean
2020-11-05 11:30                       ` Marek Behún
2020-11-05 12:06                         ` Vladimir Oltean
2020-11-06  3:01                       ` Hayes Wang
2020-11-06  6:39                         ` Marek Behún
2020-11-06  7:39                           ` Hayes Wang
2020-11-03 19:22 ` [PATCH net-next 4/5] r8152: rename r8153_phy_status to r8153_phy_status_wait Marek Behún
2020-11-03 19:22 ` [PATCH net-next 5/5] r8152: use *_modify helpers instead of read/write combos 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=20201104121053.44fae8c7@kernel.org \
    --to=kabel@kernel.org \
    --cc=hayeswang@realtek.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.