public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: "Nelson, Shannon" <shannon.nelson@amd.com>,
	Jiri Pirko <jiri@resnulli.us>, <netdev@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Michael Chan <michael.chan@broadcom.com>,
	Cai Huoqing <cai.huoqing@linux.dev>, Luo bin <luobin9@huawei.com>,
	George Cherian <george.cherian@marvell.com>,
	Danielle Ratson <danieller@nvidia.com>,
	"Moshe Shemesh" <moshe@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Cc: Brett Creeley <brett.creeley@amd.com>,
	Vasundhara Volam <vasundhara-v.volam@broadcom.com>,
	Sunil Goutham <sgoutham@marvell.com>,
	"Linu Cherian" <lcherian@marvell.com>,
	Geetha sowjanya <gakula@marvell.com>,
	"Jerin Jacob" <jerinj@marvell.com>,
	hariprasad <hkelam@marvell.com>,
	"Subbaraya Sundeep" <sbhatta@marvell.com>,
	Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>,
	Eran Ben Elisha <eranbe@nvidia.com>,
	Aya Levin <ayal@mellanox.com>, Leon Romanovsky <leon@kernel.org>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>
Subject: Re: [PATCH net-next v1 3/8] pds_core: devlink health: use retained error fmsg API
Date: Thu, 12 Oct 2023 13:30:42 +0200	[thread overview]
Message-ID: <6f0474f7-343d-9601-d4e2-526f144dec56@intel.com> (raw)
In-Reply-To: <0bd5eb16-6670-4f3c-b193-f83807a25bd5@amd.com>

On 10/10/23 18:53, Nelson, Shannon wrote:
> On 10/10/2023 3:43 AM, Przemek Kitszel wrote:
>>
>> Drop unneeded error checking.
>>
>> devlink_fmsg_*() family of functions is now retaining errors,
>> so there is no need to check for them after each call.
>>
>> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
>> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
>> ---
>> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-57 (-57)
>> ---
>>   drivers/net/ethernet/amd/pds_core/devlink.c | 27 ++++++---------------
>>   1 file changed, 7 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c 
>> b/drivers/net/ethernet/amd/pds_core/devlink.c
>> index d9607033bbf2..fcb407bdb25e 100644
>> --- a/drivers/net/ethernet/amd/pds_core/devlink.c
>> +++ b/drivers/net/ethernet/amd/pds_core/devlink.c
>> @@ -154,33 +154,20 @@ int pdsc_fw_reporter_diagnose(struct 
>> devlink_health_reporter *reporter,
>>                                struct netlink_ext_ack *extack)
>>   {
>>          struct pdsc *pdsc = devlink_health_reporter_priv(reporter);
>> -       int err;
>>
>>          mutex_lock(&pdsc->config_lock);
>> -
>>          if (test_bit(PDSC_S_FW_DEAD, &pdsc->state))
>> -               err = devlink_fmsg_string_pair_put(fmsg, "Status", 
>> "dead");
>> +               devlink_fmsg_string_pair_put(fmsg, "Status", "dead");
>>          else if (!pdsc_is_fw_good(pdsc))
>> -               err = devlink_fmsg_string_pair_put(fmsg, "Status", 
>> "unhealthy");
>> +               devlink_fmsg_string_pair_put(fmsg, "Status", 
>> "unhealthy");
>>          else
>> -               err = devlink_fmsg_string_pair_put(fmsg, "Status", 
>> "healthy");
>> -
>> +               devlink_fmsg_string_pair_put(fmsg, "Status", "healthy");
>>          mutex_unlock(&pdsc->config_lock);
>>
>> -       if (err)
>> -               return err;
>> -
>> -       err = devlink_fmsg_u32_pair_put(fmsg, "State",
>> -                                       pdsc->fw_status &
>> -                                               
>> ~PDS_CORE_FW_STS_F_GENERATION);
>> -       if (err)
>> -               return err;
>> -
>> -       err = devlink_fmsg_u32_pair_put(fmsg, "Generation",
>> -                                       pdsc->fw_generation >> 4);
>> -       if (err)
>> -               return err;
>> -
>> +       devlink_fmsg_u32_pair_put(fmsg, "State",
>> +                                 pdsc->fw_status & 
>> ~PDS_CORE_FW_STS_F_GENERATION);
>> +       devlink_fmsg_u32_pair_put(fmsg, "Generation", 
>> pdsc->fw_generation >> 4);
>>          return devlink_fmsg_u32_pair_put(fmsg, "Recoveries",
>>                                           pdsc->fw_recoveries);
>> +
> 
> Please don't add an extra blank line here.

sure, thanks!

> 
>>   }
> 
> Generally, I like this cleanup.  I did have a similar question about 
> return values as Jiri's comment - how would this do with some code 
> checkers that might complain about ignoring all those return values?

yeah, going full void makes things easier at the end

> 
> Going to full void functions would fix that.  You can add some temporary 
> "scaffolding" code, an intermediate layer to help in the driver 
> conversion, which would then get removed at the end once all the drivers 
> are converted.
> 
> This do_something/check_error/do_something/check_err pattern happens in 
> other APIs in the kernel - see the devlink_info_* APIs, for example: do 
> you foresee changing other interfaces in a similar way?

in principle, it's a good idea; personally, I will be fixing those that
I somehow encounter (like here, I plan to add some devlink health report
for intel ice driver)

> 
> sln
> 
>> -- 
>> 2.40.1
>>
> 


  reply	other threads:[~2023-10-12 11:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 10:43 [PATCH net-next v1 0/8] devlink: retain error in struct devlink_fmsg Przemek Kitszel
2023-10-10 10:43 ` [PATCH net-next v1 1/8] " Przemek Kitszel
2023-10-10 11:34   ` Jiri Pirko
2023-10-10 13:36     ` Przemek Kitszel
2023-10-10 14:03       ` Jiri Pirko
2023-10-10 10:43 ` [PATCH net-next v1 2/8] netdevsim: devlink health: use retained error fmsg API Przemek Kitszel
2023-10-10 10:43 ` [PATCH net-next v1 3/8] pds_core: " Przemek Kitszel
2023-10-10 16:53   ` Nelson, Shannon
2023-10-12 11:30     ` Przemek Kitszel [this message]
2023-10-10 10:43 ` [PATCH net-next v1 4/8] bnxt_en: " Przemek Kitszel
2023-10-12 11:34   ` Przemek Kitszel
2023-10-10 10:43 ` [PATCH net-next v1 5/8] hinic: " Przemek Kitszel
2023-10-10 10:43 ` [PATCH net-next v1 6/8] octeontx2-af: " Przemek Kitszel
2023-10-10 10:43 ` [PATCH net-next v1 7/8] mlxsw: core: " Przemek Kitszel
2023-10-10 10:43 ` [PATCH net-next v1 8/8] net/mlx5: " Przemek Kitszel

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=6f0474f7-343d-9601-d4e2-526f144dec56@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=ayal@mellanox.com \
    --cc=brett.creeley@amd.com \
    --cc=cai.huoqing@linux.dev \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eranbe@nvidia.com \
    --cc=gakula@marvell.com \
    --cc=george.cherian@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=idosch@nvidia.com \
    --cc=jerinj@marvell.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=lcherian@marvell.com \
    --cc=leon@kernel.org \
    --cc=luobin9@huawei.com \
    --cc=michael.chan@broadcom.com \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=shannon.nelson@amd.com \
    --cc=vasundhara-v.volam@broadcom.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