Re: [PATCH net-next 3/5] r8152: add MCU typed read/write functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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".



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux