From: Jes Sorensen <jes.sorensen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: "Stanislaw Gruszka"
<sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"David Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
"Helmut Schaa"
<helmut.schaa-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>,
"Kalle Valo" <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
"Daniel Golle" <daniel-g5gK2j5usbvCyp4qypjU+w@public.gmane.org>,
"Mathias Kresin" <dev-zg6vgJgm1sizQB+pC5nmwQ@public.gmane.org>,
"Johannes Berg"
<johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"Tomislav Požega"
<pozega.tomislav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"Serge Vasilugin"
<vasilugin-o+MxOtu4lMCHXe+LvDLADg@public.gmane.org>,
"Roman Yeryomin" <roman-9zmcapQ0v8Q@public.gmane.org>,
linux-wireless
<linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Networking <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Linux Kernel Mailing List"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] rt2x00: improve calling conventions for register accessors
Date: Tue, 16 May 2017 10:31:00 -0400 [thread overview]
Message-ID: <0080a870-2d15-9b60-b7fb-8847d3c8aa8a@gmail.com> (raw)
In-Reply-To: <CAK8P3a18opkvCyoNmYhR6M7XXEq8f__hMZH1A6w8UFP7qbmQWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 05/16/2017 10:19 AM, Arnd Bergmann wrote:
> On Tue, May 16, 2017 at 3:44 PM, Jes Sorensen <jes.sorensen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On 05/16/2017 07:55 AM, Stanislaw Gruszka wrote:
>>>
>>> On Mon, May 15, 2017 at 10:39:51AM -0400, David Miller wrote:
>>>>
>>>> Passing return values by reference is and always has been a really
>>>> poor way to achieve what these functions are doing.
>>>>
>>>> And frankly, whilst the tool could see what's going on here better, we
>>>> should be making code easier rather than more difficult to audit.
>>>>
>>>> I am therefore very much in favor of Arnd's change.
>>>>
>>>> This isn't even a situation where there are multiple return values,
>>>> such as needing to signal an error and return an unsigned value at the
>>>> same time.
>>>>
>>>> These functions return _one_ value, and therefore they should be
>>>> returned as a true return value.
>>>
>>>
>>> In rt2x00 driver we use poor convention in other kind of registers
>>> accessors like bbp, mac, eeprom. I dislike to changing only rfcsr
>>> accessors and leaving others in the old way. And changing all accessors
>>> would be massive and error prone change, which I'm not prefer either.
>>
>>
>> That's why you do it in multiple smaller patches rather than one ugly giant
>> patch.
>
> I did the first step using a search&replace in vim using
>
> s:\(rt2800_rfcsr_read(.*,.*\), &\(.*\));:\2 = \1);:
>
> but had to introduce a conversion function
>
> static void rt2800_rfcsr_readreg(struct rt2x00_dev *rt2x00dev,
> const unsigned int word, u8 *value)
> {
> *value = rt2800_rfcsr_read(rt2x00dev, word);
> }
>
> to keep the correct types in place for struct rt2x00debug. I now
> did all the other ones too, and removed that helper again. The
> result in much nicer, but I basically ended up having to do
> the same regex search for all of these at once:
>
> static void rt2400pci_bbp_read(struct rt2x00_dev *rt2x00dev,
> static void rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev,
> static void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
> static void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
> static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev,
> static void _rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
> static void rt2800_bbp_read(struct rt2x00_dev *rt2x00dev,
> static void rt2800_eeprom_read(struct rt2x00_dev *rt2x00dev,
> static void rt2800_rfcsr_readreg(struct rt2x00_dev *rt2x00dev,
> static void rt2800_bbp_dcoc_read(struct rt2x00_dev *rt2x00dev,
> void (*register_read)(struct rt2x00_dev *rt2x00dev,
> void (*register_read_lock)(struct rt2x00_dev *rt2x00dev,
> static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
> static inline void rt2800_register_read_lock(struct rt2x00_dev *rt2x00dev,
> static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev,
> static inline void rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev,
> void (*read)(struct rt2x00_dev *rt2x00dev, \
> static inline void rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev,
> static inline void _rt2x00_desc_read(__le32 *desc, const u8 word, __le32 *value)
> static inline void rt2x00_desc_read(__le32 *desc, const u8 word, u32 *value)
> static inline void rt2x00usb_register_read(struct rt2x00_dev *rt2x00dev,
> static inline void rt2x00usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
> static void rt61pci_bbp_read(struct rt2x00_dev *rt2x00dev,
> static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev,
>
> and that ended up as a 300KB patch [1]. Splitting it up is clearly possibly,
> but I fear that would be more error-prone as we then need to add
> those helpers for the other debug stuff as well, and remove it again
> afterwards.
True - if the automatic conversion works without automatic intervention,
I am less worried about it. Personally I would still focus on converting
one function at a time to reduce the impact of each patch.
Cheers,
Jes
next prev parent reply other threads:[~2017-05-16 14:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 13:46 [PATCH] rt2x00: improve calling conventions for register accessors Arnd Bergmann
2017-05-15 14:28 ` Stanislaw Gruszka
2017-05-15 14:36 ` Arnd Bergmann
2017-05-15 14:40 ` David Miller
[not found] ` <20170515.104052.1376354562934671974.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-05-15 19:02 ` Daniel Golle
2017-05-15 14:39 ` David Miller
2017-05-16 11:55 ` Stanislaw Gruszka
2017-05-16 11:58 ` Johannes Berg
2017-05-16 12:43 ` Stanislaw Gruszka
2017-05-16 15:37 ` David Miller
2017-05-16 13:44 ` Jes Sorensen
[not found] ` <0ce21c48-1d2c-3035-3c6e-52c7debf86d5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-16 14:19 ` Arnd Bergmann
[not found] ` <CAK8P3a18opkvCyoNmYhR6M7XXEq8f__hMZH1A6w8UFP7qbmQWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-16 14:31 ` Jes Sorensen [this message]
[not found] ` <CAKR_QVKYpcficnx5G5NdLKh7xa9S18udYQNXDQ=LmfG=Qeapbg@mail.gmail.com>
2017-05-17 14:48 ` Arnd Bergmann
2017-05-16 14:23 ` Stanislaw Gruszka
[not found] ` <20170516142342.GA6086-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-05-16 15:11 ` Arnd Bergmann
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=0080a870-2d15-9b60-b7fb-8847d3c8aa8a@gmail.com \
--to=jes.sorensen-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=daniel-g5gK2j5usbvCyp4qypjU+w@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=dev-zg6vgJgm1sizQB+pC5nmwQ@public.gmane.org \
--cc=helmut.schaa-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org \
--cc=johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pozega.tomislav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=roman-9zmcapQ0v8Q@public.gmane.org \
--cc=sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=vasilugin-o+MxOtu4lMCHXe+LvDLADg@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).