Linux Media Controller development
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Daniel Scally <djrscally@gmail.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Kate Hsuan <hpa@redhat.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	libcamera-devel@lists.libcamera.org
Subject: Re: Fwd: Surface Go VCM type (was: Need to pass acpi_enforce_resources=lax on the Surface Go (version1))
Date: Tue, 16 Nov 2021 10:54:36 +0100	[thread overview]
Message-ID: <66f4b901-830c-aab7-23c2-21158ce1d158@redhat.com> (raw)
In-Reply-To: <YYkwaY1C77BRmJat@smile.fi.intel.com>

Hi,

On 11/8/21 15:12, Andy Shevchenko wrote:
> On Mon, Nov 08, 2021 at 02:12:38PM +0100, Hans de Goede wrote:
>> On 11/2/21 00:43, Daniel Scally wrote:
> 
>> Does this sound reasonable / like I'm heading in the right direction?
> 
> It is up to you folks, since I have no time to participate in this with
> a full dive right now. Below just some comments on the patches in case
> they will go.
> 
> ...
> 
>> -	struct acpi_device *adev = ACPI_COMPANION(dev);
>> +	struct acpi_device *adev = to_acpi_device_node(fwnode);
>>  	struct i2c_acpi_lookup lookup;
>>  	struct i2c_adapter *adapter;
>>  	LIST_HEAD(resource_list);
>>  	int ret;
> 
> Make sense to move assignment here.

Ack, will fix.

> 
> 	adev = to_acpi_device_node(fwnode);
> 
>> +	if (!adev)
>> +		return ERR_PTR(-ENODEV);
> 
> ...
> 
>> +static inline struct i2c_client *i2c_acpi_new_device(struct device *dev,
>> +						     int index,
>> +						     struct i2c_board_info *info)
>> +{
>> +	return i2c_acpi_new_device_by_fwnode(dev->fwnode, index, info);
> 
> dev_fwnode(dev)

Ack, will fix.

> 
>> +}
> 
> ...
> 
>> +int cio2_bridge_sensors_are_ready(void)
>> +{
>> +	struct acpi_device *adev;
> 
>> +	bool ready = true;
> 
> Redundant. See below.
> 
>> +	unsigned int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) {
>> +		const struct cio2_sensor_config *cfg =
>> +			&cio2_supported_sensors[i];
>> +
>> +		for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
>> +			if (!adev->status.enabled)
>> +				continue;
> 
>> +			if (!acpi_dev_ready_for_enumeration(adev))
>> +				ready = false;
> 
> You may put the adev here and return false.
> 
>> +		}
>> +	}
> 
>> +	return ready;
> 
> So return true.

I actually did it this way deliberately making use of
for_each_acpi_dev_match() not "leaking" a ref when you let
it run to the end.

I find this clearer because this way all the ref handling
is abstracted away in for_each_acpi_dev_match(), where as with
a put in the middle of the loop a causal reader of the code
is going to wonder there the put ref is coming from.


> 
>> +}
> 
> ...
> 
>> +	if (sensor->ssdb.vcmtype)
>> +		nodes[SWNODE_VCM] = NODE_VCM(
>> +					cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
> 
> Wouldn't be better
> 
> 		nodes[SWNODE_VCM] =
> 			NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
> 
> ?
> 
> ...
> 
>> +	sensor->vcm_i2c_client = i2c_acpi_new_device_by_fwnode(
>> +					acpi_fwnode_handle(sensor->adev),
>> +					1, &board_info);
> 
> Ditto.

Ack, will fix both for the next version.

Regards,

Hans



  reply	other threads:[~2021-11-16  9:54 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e2312277-f967-7d3f-5ce9-fbb197d35fd6@gmail.com>
2021-10-29 11:50 ` Fwd: Surface Go VCM type (was: Need to pass acpi_enforce_resources=lax on the Surface Go (version1)) Daniel Scally
2021-11-01 15:55   ` Andy Shevchenko
2021-11-01 15:59     ` Andy Shevchenko
2021-11-01 23:26     ` Daniel Scally
2021-11-01 16:02   ` Hans de Goede
2021-11-01 19:18     ` Andy Shevchenko
2021-11-01 19:51       ` Hans de Goede
2021-11-01 23:43     ` Daniel Scally
2021-11-04 14:49       ` Hans de Goede
2021-11-04 18:14         ` Andy Shevchenko
2021-11-06 14:12           ` Hans de Goede
2021-11-06 18:39             ` Andy Shevchenko
2021-11-04 23:20         ` Daniel Scally
2021-11-08 13:12       ` Hans de Goede
2021-11-08 14:12         ` Andy Shevchenko
2021-11-16  9:54           ` Hans de Goede [this message]
2021-11-16 12:26             ` Andy Shevchenko
2021-11-09  0:43         ` Daniel Scally
2021-11-09 12:09           ` Daniel Scally
2021-11-09 16:02             ` Hans de Goede
2021-11-09 16:35               ` Daniel Scally
2021-11-10  0:01                 ` Daniel Scally
2021-11-10  8:15                   ` Andy Shevchenko
2021-11-11 10:35                   ` Hans de Goede
2021-11-11 11:18                     ` Daniel Scally
2021-11-11 15:23                       ` Hans de Goede
2021-11-11 15:51                         ` Dave Stevenson
2021-11-11 16:50                           ` Hans de Goede
2021-11-11 19:30                             ` Dave Stevenson
2021-11-11 22:04                               ` Laurent Pinchart
2021-11-12 10:32                                 ` Dave Stevenson
2021-11-12 10:46                                   ` Laurent Pinchart
2021-11-12 11:37                                     ` Andy Shevchenko
2021-11-15 13:33                                       ` Laurent Pinchart
2021-11-15 15:03                                         ` Andy Shevchenko
2021-11-12 11:43                                     ` Dave Stevenson
2021-11-15 13:21                                       ` Laurent Pinchart
2021-11-12 12:23                                     ` Sakari Ailus
2021-11-15 12:00                                       ` Laurent Pinchart
2021-11-12 17:51                                     ` [libcamera-devel] " Kieran Bingham
2021-11-15 13:08                                       ` Laurent Pinchart
2021-11-11 15:51                         ` Laurent Pinchart
2021-11-23 12:10                         ` Daniel Scally
2021-11-23 19:02                           ` Hans de Goede
2021-11-11 15:59                 ` Hans de Goede
2021-11-15 23:43                   ` Daniel Scally

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=66f4b901-830c-aab7-23c2-21158ce1d158@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=djrscally@gmail.com \
    --cc=hpa@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=libcamera-devel@lists.libcamera.org \
    --cc=linux-media@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