All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Pearson <markpearson@lenovo.com>
To: Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <markgross@kernel.org>,
	Andy Shevchenko <andy@infradead.org>
Cc: <platform-driver-x86@vger.kernel.org>
Subject: Re: [External] [PATCH 2/2] platform/x86: think-lmi: Simplify tlmi_analyze() error handling a bit
Date: Thu, 18 Nov 2021 10:46:13 -0500	[thread overview]
Message-ID: <edcabc67-c1b4-6931-5e40-f64660a5280a@lenovo.com> (raw)
In-Reply-To: <20211118114150.271274-2-hdegoede@redhat.com>

Thanks Hans,

On 2021-11-18 06:41, Hans de Goede wrote:
> Creating the tlmi_pwd_setting structs can only fail with -ENOMEM, set
> ret to this once and simplify the error handling a bit.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/think-lmi.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
> index 6eba69334fa6..27ab8e4e5b83 100644
> --- a/drivers/platform/x86/think-lmi.c
> +++ b/drivers/platform/x86/think-lmi.c
> @@ -1141,42 +1141,38 @@ static int tlmi_analyze(void)
>  	if (ret)
>  		goto fail_clear_attr;
>  
> +	/* All failures below boil down to kmalloc failures */
> +	ret = -ENOMEM;
> +
>  	tlmi_priv.pwd_admin = tlmi_create_auth("pap", "bios-admin");
> -	if (!tlmi_priv.pwd_admin) {
> -		ret = -ENOMEM;
> +	if (!tlmi_priv.pwd_admin)
>  		goto fail_clear_attr;
> -	}
> +
>  	if (tlmi_priv.pwdcfg.core.password_state & TLMI_PAP_PWD)
>  		tlmi_priv.pwd_admin->valid = true;
>  
>  	tlmi_priv.pwd_power = tlmi_create_auth("pop", "power-on");
> -	if (!tlmi_priv.pwd_power) {
> -		ret = -ENOMEM;
> +	if (!tlmi_priv.pwd_power)
>  		goto fail_clear_attr;
> -	}
> +
>  	if (tlmi_priv.pwdcfg.core.password_state & TLMI_POP_PWD)
>  		tlmi_priv.pwd_power->valid = true;
>  
>  	if (tlmi_priv.opcode_support) {
>  		tlmi_priv.pwd_system = tlmi_create_auth("sys", "system");
> -		if (!tlmi_priv.pwd_system) {
> -			ret = -ENOMEM;
> +		if (!tlmi_priv.pwd_system)
>  			goto fail_clear_attr;
> -		}
> +
>  		if (tlmi_priv.pwdcfg.core.password_state & TLMI_SYS_PWD)
>  			tlmi_priv.pwd_system->valid = true;
>  
>  		tlmi_priv.pwd_hdd = tlmi_create_auth("hdd", "hdd");
> -		if (!tlmi_priv.pwd_hdd) {
> -			ret = -ENOMEM;
> +		if (!tlmi_priv.pwd_hdd)
>  			goto fail_clear_attr;
> -		}
>  
>  		tlmi_priv.pwd_nvme = tlmi_create_auth("nvm", "nvme");
> -		if (!tlmi_priv.pwd_nvme) {
> -			ret = -ENOMEM;
> +		if (!tlmi_priv.pwd_nvme)
>  			goto fail_clear_attr;
> -		}
>  
>  		if (tlmi_priv.pwdcfg.core.password_state & TLMI_HDD_PWD) {
>  			/* Check if PWD is configured and set index to first drive found */
> 
Looks good, and works well. Verified with modifying NVMe and Admin
password on M90n

Tested-by: Mark Pearson <markpearson@lenovo.com>

  reply	other threads:[~2021-11-18 15:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 11:41 [PATCH 1/2] platform/x86: think-lmi: Move kobject_init() call into tlmi_create_auth() Hans de Goede
2021-11-18 11:41 ` [PATCH 2/2] platform/x86: think-lmi: Simplify tlmi_analyze() error handling a bit Hans de Goede
2021-11-18 15:46   ` Mark Pearson [this message]
2021-11-22 12:53     ` [External] " Hans de Goede
2021-11-18 15:45 ` [External] [PATCH 1/2] platform/x86: think-lmi: Move kobject_init() call into tlmi_create_auth() Mark Pearson

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=edcabc67-c1b4-6931-5e40-f64660a5280a@lenovo.com \
    --to=markpearson@lenovo.com \
    --cc=andy@infradead.org \
    --cc=hdegoede@redhat.com \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.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 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.