linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/1] PCI: Move no_pci_devices() to the only driver using it
Date: Thu, 10 Oct 2024 14:45:33 -0500	[thread overview]
Message-ID: <20241010194533.GA575181@bhelgaas> (raw)
In-Reply-To: <20241009105218.7798-1-ilpo.jarvinen@linux.intel.com>

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
> 

  reply	other threads:[~2024-10-10 19:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-10-22 20:45   ` Dmitry Torokhov

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=20241010194533.GA575181@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@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;
as well as URLs for NNTP newsgroup(s).