From: Guenter Roeck <linux@roeck-us.net>
To: "shufan_lee(李書帆)" <shufan_lee@richtek.com>
Cc: "Heikki Krogerus" <heikki.krogerus@linux.intel.com>,
"'Jun Li'" <jun.li@nxp.com>, ShuFanLee <leechu729@gmail.com>,
"cy_huang(黃啟原)" <cy_huang@richtek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: USB TYPEC: RT1711H Type-C Chip Driver
Date: Tue, 30 Jan 2018 15:25:21 -0800 [thread overview]
Message-ID: <20180130232521.GA19569@roeck-us.net> (raw)
On Tue, Jan 30, 2018 at 01:21:01PM +0000, shufan_lee(李書帆) wrote:
> Hi Guenter,
>
> For now, it looks like there are two ways to implement vendor data. It would be nice to hear your suggestion.
>
> 1. Set vendor data in the data field of of_device_id.
> If I understand correctly, this would be the one more like you mentioned before.
> In this case, tcpci_rt1711h_data needs to be defined inside tcpci.c or defined by other file(tcpci_rt1711h.c) but extern in tcpci.c.
>
> For example:
> static struct tcpci_vendor_data tcpci_rt1711h_data = {
> .init = rt1711h_init;
> .irq_handler = rt1711h_irq_handler
> };
> OR
> extern struct tcpci_vendor_data tcpci_rt1711h_data;
>
> Then, put this structure here
> static const struct of_device_id tcpci_of_match[] = {
> { .compatible = "usb,tcpci", },
> { .compatible = "richtek,rt1711h", .data = (void *)&tcpci_rt1711h_data },
> {},
> };
>
> For other vendors who want to handle vendor data also need to add these code inside tcpci.c.
> We are not sure that's what you expect or not.
>
I would not say expect, but it is one possibility. Sure,
it requires rt1711h_init and rt1711h_irq_handler to be public,
and a bit of ifdefery, but it is simpler than option #2.
Another option would be to instantiate tcpci from vendor drivers.
In this case, there would be an exported registration function which
would be called from tcpci_rt1711h.c:rt1711h_init(), similar to
tcpm_register_port(). In that case, tcpci_rt1711h.c would have its
own init function and compatible property.
To do that, you would effectively split tcpci_probe() into two functions,
tcpci_probe() and tcpci_register_port(), and call tcpci_register_port()
from the probe function.
int tcpci_register_port(struct i2c_client *client,
const struct tcpci_vendor_data *data)
{
/* pretty much verything currently done in the probe function */
}
EXPORT_SYMBOL(tcpci_register_port);
static int tcpci_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id)
{
return tcpci_register_port(client, NULL);
}
Maybe you can experiment with this and see if it makes sense.
If not, you can still fall back to option #1.
Thanks,
Guenter
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2018-01-30 23:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-30 23:25 Guenter Roeck [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-01-30 13:21 USB TYPEC: RT1711H Type-C Chip Driver shufan_lee(李書帆)
2018-01-29 19:57 Guenter Roeck
2018-01-29 7:19 shufan_lee(李書帆)
2018-01-22 18:50 Guenter Roeck
2018-01-22 2:01 shufan_lee(李書帆)
2018-01-19 16:02 Guenter Roeck
2018-01-19 9:24 Heikki Krogerus
2018-01-19 9:01 shufan_lee(李書帆)
2018-01-19 8:22 Heikki Krogerus
2018-01-19 8:03 Greg KH
2018-01-19 5:48 shufan_lee(李書帆)
2018-01-19 3:09 Jun Li
2018-01-18 13:13 shufan_lee(李書帆)
2018-01-17 13:42 Greg KH
2018-01-17 13:33 Greg KH
2018-01-17 13:33 Greg KH
2018-01-17 13:31 Greg Kroah-Hartman
2018-01-17 12:00 Heikki Krogerus
2018-01-17 11:14 Greg Kroah-Hartman
2018-01-17 11:08 Heikki Krogerus
2018-01-17 9:30 shufan_lee(李書帆)
2018-01-10 6:59 ShuFanLee
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=20180130232521.GA19569@roeck-us.net \
--to=linux@roeck-us.net \
--cc=cy_huang@richtek.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=jun.li@nxp.com \
--cc=leechu729@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shufan_lee@richtek.com \
/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).