From: Joe Perches <joe@perches.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
"Andrew F. Davis" <afd@ti.com>, "Bjørn Mork" <bjorn@mork.no>,
"David S. Miller" <davem@davemloft.net>,
"Philippe Reynes" <tremyfr@gmail.com>,
"Yuval Shaia" <yuval.shaia@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/2] net/usb/ax88179_178a: Use common code in ax88179_chk_eee()
Date: Sat, 10 Mar 2018 18:41:57 +0000 [thread overview]
Message-ID: <1520707317.5345.15.camel@perches.com> (raw)
In-Reply-To: <a7fff45f-4426-ec33-8b8d-caf1e3a9f0be@users.sourceforge.net>
On Sat, 2018-03-10 at 19:24 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 10 Mar 2018 18:22:43 +0100
>
> Adjust a jump target so that a bit of common code can be better reused
> at the end of this function.
Please stop mindlessly sending patching Markus.
How about looking at the code being modified and
thinking about what it does?
Try unindenting the block by reversing the first test
and using the same goto set_inactive.
Look at the last & tests
+ if (!(lp & adv & supported))
and see if it should use && or be more simple to read
by using
if (!condition || !
> ---
> drivers/net/usb/ax88179_178a.c | 34 +++++++++++-----------------------
> 1 file changed, 11 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index f32261ecd215..e4b0baa98e9a 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -689,49 +689,37 @@ static int ax88179_chk_eee(struct usbnet *dev)
> eee_cap = ax88179_phy_read_mmd_indirect(dev,
> MDIO_PCS_EEE_ABLE,
> MDIO_MMD_PCS);
> - if (eee_cap < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_cap < 0)
> + goto set_inactive;
>
> cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
> - if (!cap) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!cap)
> + goto set_inactive;
>
> eee_lp = ax88179_phy_read_mmd_indirect(dev,
> MDIO_AN_EEE_LPABLE,
> MDIO_MMD_AN);
> - if (eee_lp < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_lp < 0)
> + goto set_inactive;
>
> eee_adv = ax88179_phy_read_mmd_indirect(dev,
> MDIO_AN_EEE_ADV,
> MDIO_MMD_AN);
> -
> - if (eee_adv < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_adv < 0)
> + goto set_inactive;
>
> adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
> lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
> supported = (ecmd.speed = SPEED_1000) ?
> SUPPORTED_1000baseT_Full :
> SUPPORTED_100baseT_Full;
> -
> - if (!(lp & adv & supported)) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!(lp & adv & supported))
> + goto set_inactive;
>
> priv->eee_active = 1;
> return true;
> }
> -
> +set_inactive:
> priv->eee_active = 0;
> return false;
> }
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
"Andrew F. Davis" <afd@ti.com>, "Bjørn Mork" <bjorn@mork.no>,
"David S. Miller" <davem@davemloft.net>,
"Philippe Reynes" <tremyfr@gmail.com>,
"Yuval Shaia" <yuval.shaia@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [1/2] net/usb/ax88179_178a: Use common code in ax88179_chk_eee()
Date: Sat, 10 Mar 2018 10:41:57 -0800 [thread overview]
Message-ID: <1520707317.5345.15.camel@perches.com> (raw)
On Sat, 2018-03-10 at 19:24 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 10 Mar 2018 18:22:43 +0100
>
> Adjust a jump target so that a bit of common code can be better reused
> at the end of this function.
Please stop mindlessly sending patching Markus.
How about looking at the code being modified and
thinking about what it does?
Try unindenting the block by reversing the first test
and using the same goto set_inactive.
Look at the last & tests
+ if (!(lp & adv & supported))
and see if it should use && or be more simple to read
by using
if (!condition || !
> ---
> drivers/net/usb/ax88179_178a.c | 34 +++++++++++-----------------------
> 1 file changed, 11 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index f32261ecd215..e4b0baa98e9a 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -689,49 +689,37 @@ static int ax88179_chk_eee(struct usbnet *dev)
> eee_cap = ax88179_phy_read_mmd_indirect(dev,
> MDIO_PCS_EEE_ABLE,
> MDIO_MMD_PCS);
> - if (eee_cap < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_cap < 0)
> + goto set_inactive;
>
> cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
> - if (!cap) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!cap)
> + goto set_inactive;
>
> eee_lp = ax88179_phy_read_mmd_indirect(dev,
> MDIO_AN_EEE_LPABLE,
> MDIO_MMD_AN);
> - if (eee_lp < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_lp < 0)
> + goto set_inactive;
>
> eee_adv = ax88179_phy_read_mmd_indirect(dev,
> MDIO_AN_EEE_ADV,
> MDIO_MMD_AN);
> -
> - if (eee_adv < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_adv < 0)
> + goto set_inactive;
>
> adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
> lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
> supported = (ecmd.speed == SPEED_1000) ?
> SUPPORTED_1000baseT_Full :
> SUPPORTED_100baseT_Full;
> -
> - if (!(lp & adv & supported)) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!(lp & adv & supported))
> + goto set_inactive;
>
> priv->eee_active = 1;
> return true;
> }
> -
> +set_inactive:
> priv->eee_active = 0;
> return false;
> }
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
"Andrew F. Davis" <afd@ti.com>, "Bjørn Mork" <bjorn@mork.no>,
"David S. Miller" <davem@davemloft.net>,
"Philippe Reynes" <tremyfr@gmail.com>,
"Yuval Shaia" <yuval.shaia@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/2] net/usb/ax88179_178a: Use common code in ax88179_chk_eee()
Date: Sat, 10 Mar 2018 10:41:57 -0800 [thread overview]
Message-ID: <1520707317.5345.15.camel@perches.com> (raw)
In-Reply-To: <a7fff45f-4426-ec33-8b8d-caf1e3a9f0be@users.sourceforge.net>
On Sat, 2018-03-10 at 19:24 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 10 Mar 2018 18:22:43 +0100
>
> Adjust a jump target so that a bit of common code can be better reused
> at the end of this function.
Please stop mindlessly sending patching Markus.
How about looking at the code being modified and
thinking about what it does?
Try unindenting the block by reversing the first test
and using the same goto set_inactive.
Look at the last & tests
+ if (!(lp & adv & supported))
and see if it should use && or be more simple to read
by using
if (!condition || !
> ---
> drivers/net/usb/ax88179_178a.c | 34 +++++++++++-----------------------
> 1 file changed, 11 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index f32261ecd215..e4b0baa98e9a 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -689,49 +689,37 @@ static int ax88179_chk_eee(struct usbnet *dev)
> eee_cap = ax88179_phy_read_mmd_indirect(dev,
> MDIO_PCS_EEE_ABLE,
> MDIO_MMD_PCS);
> - if (eee_cap < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_cap < 0)
> + goto set_inactive;
>
> cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
> - if (!cap) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!cap)
> + goto set_inactive;
>
> eee_lp = ax88179_phy_read_mmd_indirect(dev,
> MDIO_AN_EEE_LPABLE,
> MDIO_MMD_AN);
> - if (eee_lp < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_lp < 0)
> + goto set_inactive;
>
> eee_adv = ax88179_phy_read_mmd_indirect(dev,
> MDIO_AN_EEE_ADV,
> MDIO_MMD_AN);
> -
> - if (eee_adv < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_adv < 0)
> + goto set_inactive;
>
> adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
> lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
> supported = (ecmd.speed == SPEED_1000) ?
> SUPPORTED_1000baseT_Full :
> SUPPORTED_100baseT_Full;
> -
> - if (!(lp & adv & supported)) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!(lp & adv & supported))
> + goto set_inactive;
>
> priv->eee_active = 1;
> return true;
> }
> -
> +set_inactive:
> priv->eee_active = 0;
> return false;
> }
next prev parent reply other threads:[~2018-03-10 18:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-10 18:24 [PATCH 1/2] net/usb/ax88179_178a: Use common code in ax88179_chk_eee() SF Markus Elfring
2018-03-10 18:24 ` SF Markus Elfring
2018-03-10 18:24 ` [1/2] " SF Markus Elfring
2018-03-10 18:41 ` Joe Perches [this message]
2018-03-10 18:41 ` [PATCH 1/2] " Joe Perches
2018-03-10 18:41 ` [1/2] " Joe Perches
2018-03-10 18:48 ` [PATCH 1/2] " Andy Shevchenko
2018-03-10 18:48 ` Andy Shevchenko
2018-03-10 18:48 ` [1/2] " Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2018-03-13 7:24 [2/2] net/usb/ax88179_178a: Delete three unnecessary variables " SF Markus Elfring
2018-03-13 7:24 ` SF Markus Elfring
2018-03-13 7:24 ` SF Markus Elfring
2018-03-13 10:26 ` Oliver Neukum
2018-03-13 10:26 ` Oliver Neukum
2018-03-13 10:26 ` Oliver Neukum
2018-03-10 18:26 [PATCH 2/2] " SF Markus Elfring
2018-03-10 18:26 ` SF Markus Elfring
2018-03-10 18:26 ` [2/2] " SF Markus Elfring
2018-03-12 10:03 ` [PATCH 2/2] " Oliver Neukum
2018-03-12 10:03 ` Oliver Neukum
2018-03-12 10:03 ` [2/2] " Oliver Neukum
2018-03-10 18:22 [PATCH 0/2] net/usb/ax88179_178a: Adjustments for ax88179_chk_eee() SF Markus Elfring
2018-03-10 18:22 ` SF Markus Elfring
2018-03-10 19:17 ` Andrew Lunn
2018-03-10 19:17 ` Andrew Lunn
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=1520707317.5345.15.camel@perches.com \
--to=joe@perches.com \
--cc=afd@ti.com \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=elfring@users.sourceforge.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tremyfr@gmail.com \
--cc=yuval.shaia@oracle.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.