mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/base/faux: Remove unnecessary match callback
@ 2025-07-24 10:37 Liya Huang
  2025-07-24 11:37 ` Greg Kroah-Hartman
  2025-07-24 11:37 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Liya Huang @ 2025-07-24 10:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
  Cc: linux-kernel, Liya Huang

The faux_match() function always returns 1, indicating a successful match.
The driver core function driver_match_device() already handles this case
by defaulting to 1 if the bus->match callback is NULL.

The implementation in driver_match_device() is:
  return drv->bus->match ? drv->bus->match(dev, drv) : 1;

Therefore, the faux_match() callback is redundant and can be removed to
simplify the code, with no change in functionality.

---
drivers/base/faux: Remove unnecessary match callback

The faux_match() function always returns 1, indicating a successful match.
The driver core function driver_match_device() already handles this case
by defaulting to 1 if the bus->match callback is NULL.

The implementation in driver_match_device() is:
  return drv->bus->match ? drv->bus->match(dev, drv) : 1;

Therefore, the faux_match() callback is redundant and can be removed to
simplify the code, with no change in functionality.

Signed-off-by: Liya Huang <1425075683@qq.com>
---
 drivers/base/faux.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/base/faux.c b/drivers/base/faux.c
index f5fbda0a9a44bd8e4831ee0ef9fc87841146d2da..005e4ecac05aebccb6fcf770f7e62848d9963c88 100644
--- a/drivers/base/faux.c
+++ b/drivers/base/faux.c
@@ -33,12 +33,6 @@ static struct device faux_bus_root = {
 	.init_name	= "faux",
 };
 
-static int faux_match(struct device *dev, const struct device_driver *drv)
-{
-	/* Match always succeeds, we only have one driver */
-	return 1;
-}
-
 static int faux_probe(struct device *dev)
 {
 	struct faux_object *faux_obj = to_faux_object(dev);
@@ -77,7 +71,6 @@ static void faux_remove(struct device *dev)
 
 static const struct bus_type faux_bus_type = {
 	.name		= "faux",
-	.match		= faux_match,
 	.probe		= faux_probe,
 	.remove		= faux_remove,
 };

---
base-commit: 89be9a83ccf1f88522317ce02f854f30d6115c41
change-id: 20250723-faux_match-f76a6456976e

Best regards,
-- 
Liya Huang <1425075683@qq.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/base/faux: Remove unnecessary match callback
  2025-07-24 10:37 [PATCH] drivers/base/faux: Remove unnecessary match callback Liya Huang
@ 2025-07-24 11:37 ` Greg Kroah-Hartman
  2025-07-24 11:37 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-24 11:37 UTC (permalink / raw)
  To: Liya Huang; +Cc: Rafael J. Wysocki, Danilo Krummrich, linux-kernel

On Thu, Jul 24, 2025 at 06:37:23PM +0800, Liya Huang wrote:
> The faux_match() function always returns 1, indicating a successful match.
> The driver core function driver_match_device() already handles this case
> by defaulting to 1 if the bus->match callback is NULL.
> 
> The implementation in driver_match_device() is:
>   return drv->bus->match ? drv->bus->match(dev, drv) : 1;
> 
> Therefore, the faux_match() callback is redundant and can be removed to
> simplify the code, with no change in functionality.
> 
> ---
> drivers/base/faux: Remove unnecessary match callback
> 
> The faux_match() function always returns 1, indicating a successful match.
> The driver core function driver_match_device() already handles this case
> by defaulting to 1 if the bus->match callback is NULL.
> 
> The implementation in driver_match_device() is:
>   return drv->bus->match ? drv->bus->match(dev, drv) : 1;
> 
> Therefore, the faux_match() callback is redundant and can be removed to
> simplify the code, with no change in functionality.

Why is the changelog text here twice?  How did git send-email get this
wrong?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/base/faux: Remove unnecessary match callback
  2025-07-24 10:37 [PATCH] drivers/base/faux: Remove unnecessary match callback Liya Huang
  2025-07-24 11:37 ` Greg Kroah-Hartman
@ 2025-07-24 11:37 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-24 11:37 UTC (permalink / raw)
  To: Liya Huang; +Cc: Rafael J. Wysocki, Danilo Krummrich, linux-kernel

On Thu, Jul 24, 2025 at 06:37:23PM +0800, Liya Huang wrote:
> The faux_match() function always returns 1, indicating a successful match.
> The driver core function driver_match_device() already handles this case
> by defaulting to 1 if the bus->match callback is NULL.
> 
> The implementation in driver_match_device() is:
>   return drv->bus->match ? drv->bus->match(dev, drv) : 1;
> 
> Therefore, the faux_match() callback is redundant and can be removed to
> simplify the code, with no change in functionality.
> 
> ---
> drivers/base/faux: Remove unnecessary match callback
> 
> The faux_match() function always returns 1, indicating a successful match.
> The driver core function driver_match_device() already handles this case
> by defaulting to 1 if the bus->match callback is NULL.
> 
> The implementation in driver_match_device() is:
>   return drv->bus->match ? drv->bus->match(dev, drv) : 1;
> 
> Therefore, the faux_match() callback is redundant and can be removed to
> simplify the code, with no change in functionality.
> 
> Signed-off-by: Liya Huang <1425075683@qq.com>
> ---
>  drivers/base/faux.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/base/faux.c b/drivers/base/faux.c
> index f5fbda0a9a44bd8e4831ee0ef9fc87841146d2da..005e4ecac05aebccb6fcf770f7e62848d9963c88 100644
> --- a/drivers/base/faux.c
> +++ b/drivers/base/faux.c
> @@ -33,12 +33,6 @@ static struct device faux_bus_root = {
>  	.init_name	= "faux",
>  };
>  
> -static int faux_match(struct device *dev, const struct device_driver *drv)
> -{
> -	/* Match always succeeds, we only have one driver */
> -	return 1;
> -}
> -
>  static int faux_probe(struct device *dev)
>  {
>  	struct faux_object *faux_obj = to_faux_object(dev);
> @@ -77,7 +71,6 @@ static void faux_remove(struct device *dev)
>  
>  static const struct bus_type faux_bus_type = {
>  	.name		= "faux",
> -	.match		= faux_match,

Let's leave this please, it makes things more "obvious" as to what is
going on and isn't hurting anything.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-24 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-24 10:37 [PATCH] drivers/base/faux: Remove unnecessary match callback Liya Huang
2025-07-24 11:37 ` Greg Kroah-Hartman
2025-07-24 11:37 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®