* [PATCH 1/1] PCI: Move no_pci_devices() to the only driver using it
@ 2024-10-09 10:52 Ilpo Järvinen
2024-10-10 19:45 ` Bjorn Helgaas
0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2024-10-09 10:52 UTC (permalink / raw)
To: Dmitry Torokhov, Bjorn Helgaas, linux-input, linux-kernel,
linux-pci
Cc: Ilpo Järvinen
Core PCI code provides no_pci_devices() that is only used in the
pc110pad driver during init to detect cases when PC110 definitely cannot
be present. Move this legacy detection trickery/hack into the pc110pad
driver.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/input/mouse/pc110pad.c | 19 +++++++++++++++++++
drivers/pci/probe.c | 17 -----------------
include/linux/pci.h | 3 ---
3 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index efa58049f746..f4167a7e71c8 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -87,6 +87,25 @@ static int pc110pad_open(struct input_dev *dev)
* that the PC110 is not a PCI system. So if we find any
* PCI devices in the machine, we don't have a PC110.
*/
+#ifdef CONFIG_PCI
+static int __init no_pci_devices(void)
+{
+ struct device *dev;
+ int no_devices;
+
+ dev = bus_find_next_device(&pci_bus_type, NULL);
+ no_devices = (dev == NULL);
+ put_device(dev);
+ return no_devices;
+}
+#else
+static int __init no_pci_devices(void)
+{
+ return 1;
+}
+#endif
+
+
static int __init pc110pad_init(void)
{
int err;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4f68414c3086..2704503fa8fb 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -65,23 +65,6 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
return &r->res;
}
-/*
- * Some device drivers need know if PCI is initiated.
- * Basically, we think PCI is not initiated when there
- * is no device to be found on the pci_bus_type.
- */
-int no_pci_devices(void)
-{
- struct device *dev;
- int no_devices;
-
- dev = bus_find_next_device(&pci_bus_type, NULL);
- no_devices = (dev == NULL);
- put_device(dev);
- return no_devices;
-}
-EXPORT_SYMBOL(no_pci_devices);
-
/*
* PCI Bus Class
*/
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 573b4c4c2be6..4757ce7ccd53 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1107,8 +1107,6 @@ extern const struct bus_type pci_bus_type;
/* Do NOT directly access these two variables, unless you are arch-specific PCI
* code, or PCI core code. */
extern struct list_head pci_root_buses; /* List of all known PCI buses */
-/* Some device drivers need know if PCI is initiated */
-int no_pci_devices(void);
void pcibios_resource_survey_bus(struct pci_bus *bus);
void pcibios_bus_add_device(struct pci_dev *pdev);
@@ -1969,7 +1967,6 @@ static inline struct pci_dev *pci_get_base_class(unsigned int class,
static inline int pci_dev_present(const struct pci_device_id *ids)
{ return 0; }
-#define no_pci_devices() (1)
#define pci_dev_put(dev) do { } while (0)
static inline void pci_set_master(struct pci_dev *dev) { }
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] PCI: Move no_pci_devices() to the only driver using it
2024-10-09 10:52 [PATCH 1/1] PCI: Move no_pci_devices() to the only driver using it Ilpo Järvinen
@ 2024-10-10 19:45 ` Bjorn Helgaas
2024-10-22 20:45 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2024-10-10 19:45 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Dmitry Torokhov, Bjorn Helgaas, linux-input, linux-kernel,
linux-pci
On Wed, Oct 09, 2024 at 01:52:18PM +0300, Ilpo Järvinen wrote:
> Core PCI code provides no_pci_devices() that is only used in the
> pc110pad driver during init to detect cases when PC110 definitely cannot
> be present. Move this legacy detection trickery/hack into the pc110pad
> driver.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Thanks, this is indeed a gross hack, and I'd be glad to eradicate it
from PCI.
> ---
> drivers/input/mouse/pc110pad.c | 19 +++++++++++++++++++
> drivers/pci/probe.c | 17 -----------------
> include/linux/pci.h | 3 ---
> 3 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
> index efa58049f746..f4167a7e71c8 100644
> --- a/drivers/input/mouse/pc110pad.c
> +++ b/drivers/input/mouse/pc110pad.c
> @@ -87,6 +87,25 @@ static int pc110pad_open(struct input_dev *dev)
> * that the PC110 is not a PCI system. So if we find any
> * PCI devices in the machine, we don't have a PC110.
> */
> +#ifdef CONFIG_PCI
> +static int __init no_pci_devices(void)
> +{
> + struct device *dev;
> + int no_devices;
> +
> + dev = bus_find_next_device(&pci_bus_type, NULL);
> + no_devices = (dev == NULL);
> + put_device(dev);
> + return no_devices;
> +}
> +#else
> +static int __init no_pci_devices(void)
> +{
> + return 1;
> +}
> +#endif
> +
> +
> static int __init pc110pad_init(void)
> {
> int err;
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 4f68414c3086..2704503fa8fb 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -65,23 +65,6 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
> return &r->res;
> }
>
> -/*
> - * Some device drivers need know if PCI is initiated.
> - * Basically, we think PCI is not initiated when there
> - * is no device to be found on the pci_bus_type.
> - */
> -int no_pci_devices(void)
> -{
> - struct device *dev;
> - int no_devices;
> -
> - dev = bus_find_next_device(&pci_bus_type, NULL);
> - no_devices = (dev == NULL);
> - put_device(dev);
> - return no_devices;
> -}
> -EXPORT_SYMBOL(no_pci_devices);
> -
> /*
> * PCI Bus Class
> */
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 573b4c4c2be6..4757ce7ccd53 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1107,8 +1107,6 @@ extern const struct bus_type pci_bus_type;
> /* Do NOT directly access these two variables, unless you are arch-specific PCI
> * code, or PCI core code. */
> extern struct list_head pci_root_buses; /* List of all known PCI buses */
> -/* Some device drivers need know if PCI is initiated */
> -int no_pci_devices(void);
>
> void pcibios_resource_survey_bus(struct pci_bus *bus);
> void pcibios_bus_add_device(struct pci_dev *pdev);
> @@ -1969,7 +1967,6 @@ static inline struct pci_dev *pci_get_base_class(unsigned int class,
> static inline int pci_dev_present(const struct pci_device_id *ids)
> { return 0; }
>
> -#define no_pci_devices() (1)
> #define pci_dev_put(dev) do { } while (0)
>
> static inline void pci_set_master(struct pci_dev *dev) { }
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] PCI: Move no_pci_devices() to the only driver using it
2024-10-10 19:45 ` Bjorn Helgaas
@ 2024-10-22 20:45 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2024-10-22 20:45 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Ilpo Järvinen, Bjorn Helgaas, linux-input, linux-kernel,
linux-pci
Hi Bjorn, Ilpo,
On Thu, Oct 10, 2024 at 02:45:33PM -0500, Bjorn Helgaas wrote:
> On Wed, Oct 09, 2024 at 01:52:18PM +0300, Ilpo Järvinen wrote:
> > Core PCI code provides no_pci_devices() that is only used in the
> > pc110pad driver during init to detect cases when PC110 definitely cannot
> > be present. Move this legacy detection trickery/hack into the pc110pad
> > driver.
> >
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>
> Thanks, this is indeed a gross hack, and I'd be glad to eradicate it
> from PCI.
I would much rather remove pc110_pad altogether. If I can get a
"Reviewed-by" on [1] that would be great.
[1] https://lore.kernel.org/all/20240808172733.1194442-4-dmitry.torokhov@gmail.com/
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-22 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 10:52 [PATCH 1/1] PCI: Move no_pci_devices() to the only driver using it Ilpo Järvinen
2024-10-10 19:45 ` Bjorn Helgaas
2024-10-22 20:45 ` Dmitry Torokhov
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).