linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] driver-core: Implement device_match_always()
@ 2016-06-06  7:32 Thierry Reding
  2016-06-06  7:32 ` [PATCH 2/3] PCI: Use device_match_always() Thierry Reding
  2016-06-06  7:32 ` [PATCH 3/3] scsi: " Thierry Reding
  0 siblings, 2 replies; 5+ messages in thread
From: Thierry Reding @ 2016-06-06  7:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Bjorn Helgaas, James E . J . Bottomley, Martin K . Petersen,
	linux-pci, linux-scsi, linux-kernel

From: Thierry Reding <treding@nvidia.com>

This is a helper function that can be used in iterators, such as
bus_find_device(), and will always match. This is useful to implement a
custom iterator interface on top of bus_find_device() or to check if any
devices have been registered at all.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 include/linux/device.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 38f02814d53a..bea9566cea96 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1031,6 +1031,11 @@ extern int device_online(struct device *dev);
 extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 
+static inline int device_match_always(struct device *device, void *data)
+{
+	return 1;
+}
+
 /*
  * Root device objects for grouping under /sys/devices
  */
-- 
2.8.3

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

* [PATCH 2/3] PCI: Use device_match_always()
  2016-06-06  7:32 [PATCH 1/3] driver-core: Implement device_match_always() Thierry Reding
@ 2016-06-06  7:32 ` Thierry Reding
  2016-06-10 16:13   ` Bjorn Helgaas
  2016-06-06  7:32 ` [PATCH 3/3] scsi: " Thierry Reding
  1 sibling, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2016-06-06  7:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Bjorn Helgaas, James E . J . Bottomley, Martin K . Petersen,
	linux-pci, linux-scsi, linux-kernel

From: Thierry Reding <treding@nvidia.com>

There is now a common implementation for a match function that will
always match, so the PCI-specific implementation can be removed.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/pci/probe.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8e3ef720997d..3db06d8d6497 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -62,11 +62,6 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
 	return &r->res;
 }
 
-static int find_anything(struct device *dev, void *data)
-{
-	return 1;
-}
-
 /*
  * Some device drivers need know if pci is initiated.
  * Basically, we think pci is not initiated when there
@@ -77,7 +72,7 @@ int no_pci_devices(void)
 	struct device *dev;
 	int no_devices;
 
-	dev = bus_find_device(&pci_bus_type, NULL, NULL, find_anything);
+	dev = bus_find_device(&pci_bus_type, NULL, NULL, device_match_always);
 	no_devices = (dev == NULL);
 	put_device(dev);
 	return no_devices;
-- 
2.8.3

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

* [PATCH 3/3] scsi: Use device_match_always()
  2016-06-06  7:32 [PATCH 1/3] driver-core: Implement device_match_always() Thierry Reding
  2016-06-06  7:32 ` [PATCH 2/3] PCI: Use device_match_always() Thierry Reding
@ 2016-06-06  7:32 ` Thierry Reding
  1 sibling, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2016-06-06  7:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Bjorn Helgaas, James E . J . Bottomley, Martin K . Petersen,
	linux-pci, linux-scsi, linux-kernel

From: Thierry Reding <treding@nvidia.com>

There is now a common implementation for a match function that will
always match, so the SCSI-specific implementation can be removed.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/scsi/scsi_proc.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index 7a74b82e8973..4adcdc2caf27 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -371,15 +371,10 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
 	return err;
 }
 
-static int always_match(struct device *dev, void *data)
-{
-	return 1;
-}
-
 static inline struct device *next_scsi_device(struct device *start)
 {
 	struct device *next = bus_find_device(&scsi_bus_type, start, NULL,
-					      always_match);
+					      device_match_always);
 	put_device(start);
 	return next;
 }
-- 
2.8.3

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

* Re: [PATCH 2/3] PCI: Use device_match_always()
  2016-06-06  7:32 ` [PATCH 2/3] PCI: Use device_match_always() Thierry Reding
@ 2016-06-10 16:13   ` Bjorn Helgaas
  2016-06-10 16:33     ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2016-06-10 16:13 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Greg Kroah-Hartman, Bjorn Helgaas, James E . J . Bottomley,
	Martin K . Petersen, linux-pci, linux-scsi, linux-kernel

On Mon, Jun 06, 2016 at 09:32:37AM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> There is now a common implementation for a match function that will
> always match, so the PCI-specific implementation can be removed.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

I'm sort of OK with this.  It's clearly not going to break anything.

But I would far rather figure out a way to remove no_pci_devices()
completely.  There's only one in-tree caller, and it's sort of
dubious, although the idea was added by Linus (2bff5e94f1bf).

I suppose nowadays we would use ACPI or DMI to do this.  But I guess
this is OK as-is.  It'd be pretty hard to find a PC110 to test any
real driver changes.

I assume all three of these patches would get merged together by
somebody else.

> ---
>  drivers/pci/probe.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8e3ef720997d..3db06d8d6497 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -62,11 +62,6 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
>  	return &r->res;
>  }
>  
> -static int find_anything(struct device *dev, void *data)
> -{
> -	return 1;
> -}
> -
>  /*
>   * Some device drivers need know if pci is initiated.
>   * Basically, we think pci is not initiated when there
> @@ -77,7 +72,7 @@ int no_pci_devices(void)
>  	struct device *dev;
>  	int no_devices;
>  
> -	dev = bus_find_device(&pci_bus_type, NULL, NULL, find_anything);
> +	dev = bus_find_device(&pci_bus_type, NULL, NULL, device_match_always);
>  	no_devices = (dev == NULL);
>  	put_device(dev);
>  	return no_devices;
> -- 
> 2.8.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/3] PCI: Use device_match_always()
  2016-06-10 16:13   ` Bjorn Helgaas
@ 2016-06-10 16:33     ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2016-06-10 16:33 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Greg Kroah-Hartman, Bjorn Helgaas, James E . J . Bottomley,
	Martin K . Petersen, linux-pci, linux-scsi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

On Fri, Jun 10, 2016 at 11:13:43AM -0500, Bjorn Helgaas wrote:
> On Mon, Jun 06, 2016 at 09:32:37AM +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > There is now a common implementation for a match function that will
> > always match, so the PCI-specific implementation can be removed.
> > 
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> I'm sort of OK with this.  It's clearly not going to break anything.
> 
> But I would far rather figure out a way to remove no_pci_devices()
> completely.  There's only one in-tree caller, and it's sort of
> dubious, although the idea was added by Linus (2bff5e94f1bf).

This is sort of a spin-off from another series that I sent out, which
introduced a common function that was used in far more places and has
a more clearly legitimate use. While working on that other series the
duplication here occurred to me, so I thought I'd remove it while at
it, even if there are only two occurrences.

> I suppose nowadays we would use ACPI or DMI to do this.  But I guess
> this is OK as-is.  It'd be pretty hard to find a PC110 to test any
> real driver changes.
> 
> I assume all three of these patches would get merged together by
> somebody else.

I was thinking Greg could take them through the driver core tree.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2016-06-10 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-06  7:32 [PATCH 1/3] driver-core: Implement device_match_always() Thierry Reding
2016-06-06  7:32 ` [PATCH 2/3] PCI: Use device_match_always() Thierry Reding
2016-06-10 16:13   ` Bjorn Helgaas
2016-06-10 16:33     ` Thierry Reding
2016-06-06  7:32 ` [PATCH 3/3] scsi: " Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).