X86 platform drivers
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 1/2] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname()
Date: Fri, 25 Oct 2024 18:32:13 +0300	[thread overview]
Message-ID: <Zxu5_VAe2NLeR-2s@smile.fi.intel.com> (raw)
In-Reply-To: <20241025094435.71718-1-hdegoede@redhat.com>

On Fri, Oct 25, 2024 at 11:44:34AM +0200, Hans de Goede wrote:
> On the Vexia EDU ATLA 10 tablet, which ships with Android + a custom Linux
> (guadalinex) using the custom Android kernel the I2C controllers are not
> enumerated as ACPI devices as they typically are.
> 
> Instead they are enumerated as PCI devices which do not have ACPI firmware
> nodes associated with them, so getting the i2c_adapter by the ACPI path of
> its firmware node does not work.
> 
> Add support for getting the i2c_adapter by the devname() of its PCI parent
> instead.

...

>  #include <linux/acpi.h>
> +#include <linux/device.h>

> +#include <linux/device/bus.h>

The above is enough. but if you want go with this, I would swap them:

#include <linux/device/bus.h>
#include <linux/device.h>

>  #include <linux/dmi.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/gpio/machine.h>
>  #include <linux/irq.h>
>  #include <linux/module.h>
> +#include <linux/pci.h>
>  #include <linux/platform_device.h>
>  #include <linux/serdev.h>
>  #include <linux/string.h>

...

> +static __init int match_parent(struct device *dev, const void *data)
> +{
> +	return dev->parent == data;
> +}

To me it sounds like a candidate to be in drivers/base/core.c and bus.h.

...

> -	status = acpi_get_handle(NULL, client_info->adapter_path, &handle);
> -	if (ACPI_FAILURE(status)) {
> -		pr_err("Error could not get %s handle\n", client_info->adapter_path);
> -		return -ENODEV;
> +	if (dev_info->use_pci_devname) {
> +		struct device *pdev, *adap_dev;
> +
> +		pdev = bus_find_device_by_name(&pci_bus_type, NULL, client_info->adapter_path);
> +		if (!pdev) {
> +			pr_err("Error could not find %s PCI device\n", client_info->adapter_path);
> +			return -ENODEV;
> +		}
> +
> +		adap_dev = bus_find_device(&i2c_bus_type, NULL, pdev, match_parent);
> +		if (adap_dev) {
> +			adap = i2c_verify_adapter(adap_dev);
> +			if (!adap)
> +				put_device(adap_dev);
> +		}
> +
> +		put_device(pdev);
> +	} else {
> +		acpi_handle handle;
> +		acpi_status status;
> +
> +		status = acpi_get_handle(NULL, client_info->adapter_path, &handle);
> +		if (ACPI_FAILURE(status)) {
> +			pr_err("Error could not get %s handle\n", client_info->adapter_path);
> +			return -ENODEV;
> +		}
> +
> +		adap = i2c_acpi_find_adapter_by_handle(handle);

Can we rather have two patches:
1) create a helper out of the existing code;
2) added the new approach also using a separate helper?

>  	}

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2024-10-25 15:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25  9:44 [PATCH 1/2] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname() Hans de Goede
2024-10-25  9:44 ` [PATCH 2/2] platform/x86: x86-android-tablets: Add support for Vexia EDU ATLA 10 tablet Hans de Goede
2024-10-25 17:47   ` Andy Shevchenko
2024-11-04 15:54     ` Hans de Goede
2024-10-25 15:32 ` Andy Shevchenko [this message]
2024-11-04 15:54   ` [PATCH 1/2] platform/x86: x86-android-tablets: Add support for getting i2c_adapter by PCI parent devname() Hans de Goede

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=Zxu5_VAe2NLeR-2s@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=platform-driver-x86@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