All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Danny Kaehn <kaehndan@gmail.com>
Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	jikos@kernel.org, benjamin.tissoires@redhat.com,
	bartosz.golaszewski@linaro.org, dmitry.torokhov@gmail.com,
	devicetree@vger.kernel.org, linux-input@vger.kernel.org,
	ethan.twardy@plexus.com
Subject: Re: [PATCH v9 3/3] HID: cp2112: Fwnode Support
Date: Mon, 20 Mar 2023 15:00:20 +0200	[thread overview]
Message-ID: <ZBhY5Gp88gVK7q/g@smile.fi.intel.com> (raw)
In-Reply-To: <ZBhYXwjPeRiZwxMT@smile.fi.intel.com>

On Mon, Mar 20, 2023 at 02:58:07PM +0200, Andy Shevchenko wrote:
> On Sun, Mar 19, 2023 at 03:48:02PM -0500, Danny Kaehn wrote:

...

> > +	device_for_each_child_node(&hdev->dev, child) {
> > +		name = fwnode_get_name(child);
> > +		ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> > +
> > +		if ((name && strcmp("i2c", name) == 0) || (!ret && addr == 0))
> > +			device_set_node(&dev->adap.dev, child);
> > +		else if ((name && strcmp("gpio", name)) == 0 ||
> > +					(!ret && addr == 1))
> > +			dev->gc.fwnode = child;
> > +	}
> 
> Please, make addresses defined explicitly. You may also do it with node naming
> schema:
> 
> #define CP2112_I2C_ADR		0
> #define CP2112_GPIO_ADR		1
> 
> static const char * const cp2112_cell_names[] = {
> 	[CP2112_I2C_ADR]	= "i2c",
> 	[CP2112_GPIO_ADR]	= "gpio",
> };
> 
> 	device_for_each_child_node(&hdev->dev, child) {
> 		name = fwnode_get_name(child);
> 		if (name) {
> 			ret = match_string(cp2112_cell_names, ARRAY_SIZE(cp2112_cell_names), name);
> 			if (ret >= 0)
> 				addr = ret;
> 		} else
> 			ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
> 		if (ret < 0)
> 			...error handling if needed...
> 
> 		switch (addr) {
> 		case CP2112_I2C_ADR:
> 			device_set_node(&dev->adap.dev, child);
> 			break;
> 		case CP2112_GPIO_ADR:
> 			dev->gc.fwnode = child;
> 			break;
> 		default:
> 			...error handling...
> 		}
> 	}

Btw, don't you use "reg" property for the child nodes? It would be better from
de facto used patterns (we have a couple of mode drivers that have a common
code to read "reg" or _ADR() and that code can be split into a helper and used
here).

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-03-20 13:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19 20:47 [PATCH v9 0/3] Firmware Support for USB-HID Devices and CP2112 Danny Kaehn
2023-03-19 20:48 ` [PATCH v9 1/3] dt-bindings: i2c: Add CP2112 HID USB to SMBus Bridge Danny Kaehn
2023-03-20  6:44   ` Krzysztof Kozlowski
2023-03-20 12:25     ` Daniel Kaehn
2023-03-19 20:48 ` [PATCH v9 2/3] HID: usbhid: Share USB device firmware node with child HID device Danny Kaehn
2023-03-19 20:48 ` [PATCH v9 3/3] HID: cp2112: Fwnode Support Danny Kaehn
2023-03-20 12:58   ` Andy Shevchenko
2023-03-20 13:00     ` Andy Shevchenko [this message]
2023-03-20 13:40       ` Daniel Kaehn
2023-03-20 14:05         ` Andy Shevchenko
2023-05-01 23:35           ` Daniel Kaehn
2023-07-03 10:57             ` Andy Shevchenko
2024-01-17 18:48               ` Danny Kaehn
2024-01-18  8:58                 ` Benjamin Tissoires

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=ZBhY5Gp88gVK7q/g@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ethan.twardy@plexus.com \
    --cc=jikos@kernel.org \
    --cc=kaehndan@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.