public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 2/2] pinctrl: pinconf-generic: remove the special handling for no config case
Date: Tue, 21 Nov 2023 07:28:32 +0900	[thread overview]
Message-ID: <20231120222832.4063882-3-masahiroy@kernel.org> (raw)
In-Reply-To: <20231120222832.4063882-1-masahiroy@kernel.org>

To further simplify pinconf_generic_parse_dt_config(), eliminate the
handling of the case where no configuration is found.

When ncfg is zero, krealloc_array() will set ZERO_SIZE_PTR to *configs,
which is a natural approach for managing a zero-size buffer.

This should have no impact because none of the callers accesses 'configs'
when ncfg is zero. Also, it is safe to pass ZERO_SIZE_PTR to kfree().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 drivers/pinctrl/pinconf-generic.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index ba4fe2466e78..252d69ee2b68 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -265,14 +265,6 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
 		parse_dt_cfg(np, pctldev->desc->custom_params,
 			     pctldev->desc->num_custom_params, cfg, &ncfg);
 
-	/* no configs found at all */
-	if (ncfg == 0) {
-		kfree(cfg);
-		*configs = NULL;
-		*nconfigs = 0;
-		return 0;
-	}
-
 	/* Now resize the array to store the real number of found properties. */
 	*configs = krealloc_array(cfg, ncfg, sizeof(unsigned long), GFP_KERNEL);
 	if (!*configs)
-- 
2.40.1


      parent reply	other threads:[~2023-11-20 22:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 22:28 [PATCH 0/2] pinctrl: pinconf-generic: clean up pinconf_parse_dt_config() Masahiro Yamada
2023-11-20 22:28 ` [PATCH 1/2] pinctrl: pinconf-generic: resize the pin config array directly Masahiro Yamada
2023-11-21 10:21   ` Masahiro Yamada
2023-11-24 10:06     ` Linus Walleij
2023-11-24 11:24       ` Andy Shevchenko
2023-11-25 18:03         ` Masahiro Yamada
2023-11-20 22:28 ` Masahiro Yamada [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=20231120222832.4063882-3-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox