From: Ondrej Zary <linux@zary.sk>
To: Meng Tang <tangmeng@uniontech.com>
Cc: klassert@kernel.org, davem@davemloft.net, kuba@kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: 3com: 3c59x: Change the conditional processing for vortex_ioctl
Date: Thu, 17 Mar 2022 09:00:36 +0100 [thread overview]
Message-ID: <202203170900.36931.linux@zary.sk> (raw)
In-Reply-To: <20220317043344.15317-1-tangmeng@uniontech.com>
On Thursday 17 March 2022, Meng Tang wrote:
> In the vortex_ioctl, there are two places where there can be better
> and easier to understand:
> First, it should be better to reverse the check on 'VORTEX_PCI(vp)'
> and returned early in order to be easier to understand.
> Second, no need to make two 'if(state != 0)' judgments, we can
> simplify the execution process.
Congratulations, you've just added 3 lines of code and broke a driver.
Your "simplified" version does not work with EISA devices.
Why? Please stop "improving" drivers if you can't test them.
> Signed-off-by: Meng Tang <tangmeng@uniontech.com>
> ---
> drivers/net/ethernet/3com/3c59x.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
> index ccf07667aa5e..c22de3c8cd12 100644
> --- a/drivers/net/ethernet/3com/3c59x.c
> +++ b/drivers/net/ethernet/3com/3c59x.c
> @@ -3032,16 +3032,19 @@ static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
> struct vortex_private *vp = netdev_priv(dev);
> pci_power_t state = 0;
>
> - if(VORTEX_PCI(vp))
> - state = VORTEX_PCI(vp)->current_state;
> + if (!VORTEX_PCI(vp))
> + return -EOPNOTSUPP;
>
> - /* The kernel core really should have pci_get_power_state() */
> + state = VORTEX_PCI(vp)->current_state;
>
> - if(state != 0)
> + /* The kernel core really should have pci_get_power_state() */
> + if (!state) {
> + err = generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL);
> + } else {
> pci_set_power_state(VORTEX_PCI(vp), PCI_D0);
> - err = generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL);
> - if(state != 0)
> + err = generic_mii_ioctl(&vp->mii, if_mii(rq), cmd, NULL);
> pci_set_power_state(VORTEX_PCI(vp), state);
> + }
>
> return err;
> }
--
Ondrej Zary
prev parent reply other threads:[~2022-03-17 8:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 4:33 [PATCH] net: 3com: 3c59x: Change the conditional processing for vortex_ioctl Meng Tang
2022-03-17 8:00 ` Ondrej Zary [this message]
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=202203170900.36931.linux@zary.sk \
--to=linux@zary.sk \
--cc=davem@davemloft.net \
--cc=klassert@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tangmeng@uniontech.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 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).