All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: tps65911-comparator: fix sysfs file creation rollback
Date: Wed, 1 Jul 2026 23:04:18 +0100	[thread overview]
Message-ID: <20260701220418.GF2108533@google.com> (raw)
In-Reply-To: <20260615065051.73111-1-pengpeng@iscas.ac.cn>

On Mon, 15 Jun 2026, Pengpeng Hou wrote:

> tps65911_comparator_probe() creates comp1_threshold and then
> comp2_threshold sysfs files.
> 
> If creating comp1_threshold fails, the probe still tries to create
> comp2_threshold and can return success if the second creation succeeds.
> If creating comp2_threshold fails, the already-created comp1_threshold
> file is left behind even though probe returns an error.
> 
> Return immediately on comp1_threshold creation failure and remove
> comp1_threshold when comp2_threshold creation fails.

This code is 15 years old.

It'll be challenging to figure out the author's original intentions.
Perhaps these calls are optional?  Did you include the original author
in the discussion?

> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>  drivers/mfd/tps65911-comparator.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/tps65911-comparator.c b/drivers/mfd/tps65911-comparator.c
> index 7098712ea008..2e5211374aaf 100644
> --- a/drivers/mfd/tps65911-comparator.c
> +++ b/drivers/mfd/tps65911-comparator.c
> @@ -130,12 +130,16 @@ static int tps65911_comparator_probe(struct platform_device *pdev)
>  
>  	/* Create sysfs entry */
>  	ret = device_create_file(&pdev->dev, &dev_attr_comp1_threshold);
> -	if (ret < 0)
> +	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed to add COMP1 sysfs file\n");
> +		return ret;
> +	}
>  
>  	ret = device_create_file(&pdev->dev, &dev_attr_comp2_threshold);
> -	if (ret < 0)
> +	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed to add COMP2 sysfs file\n");
> +		device_remove_file(&pdev->dev, &dev_attr_comp1_threshold);
> +	}
>  
>  	return ret;
>  }
> -- 
> 2.50.1 (Apple Git-155)
> 

-- 
Lee Jones

      reply	other threads:[~2026-07-01 22:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15  6:50 [PATCH] mfd: tps65911-comparator: fix sysfs file creation rollback Pengpeng Hou
2026-07-01 22:04 ` Lee Jones [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=20260701220418.GF2108533@google.com \
    --to=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pengpeng@iscas.ac.cn \
    /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.