Received: by 10.223.176.5 with SMTP id f5csp605383wra; Tue, 30 Jan 2018 16:31:54 -0800 (PST) X-Google-Smtp-Source: AH8x226Yh3U/3P7Nh9eQPbnWfv+UNbOBY+DTZkc9HWqqPKpLq7Ptg2GsLVH1aXmcnXojLY/Hkf5U X-Received: by 10.98.254.21 with SMTP id z21mr31947703pfh.48.1517358714661; Tue, 30 Jan 2018 16:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517358714; cv=none; d=google.com; s=arc-20160816; b=Lig2YNoIdtpW9S8etekM5Ozra0NbXYlgXrrFEXydzVYXSZdogVzrPd5jemnJBfu5/U O5wdyItLvhW3Itzrl5+8eQNzX6sRqAFkxHkYg7/X6HrV9Nv1DUXsKDr3OtaQU6WAnYuf gZkLA46EgwtvPWh8DaM9juhIyTMPlGaWXAPEs44ITHtFLlmufjLNzmFY+NOZ55pNELEc lJfMpFII/hiTncZEossa0k2gPC1b4ZUrH3K+urlPzUVP9vcgjOYcWG3yJRCp2w+EJrhA luL8g1q78biNx4berJboPGppzntcqLjvrRFm6TwIKS2ymnkFSWHvLWSOjT9G90p4j0Yw qP2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=jRsXKN4MTtLXgX9LqNOa3mHqzehlpzl84CPoqorVBtE=; b=PeZHtot0MoCAUJTlqn6gHk3DGBDglw5QsRSaAlplw8RmlGbv7yDTWM8elDl5bD4e5f PNeZEKh2AMYpGtThnhBfOWTrk5XCMvMNnBpqc9vAx+dtNc82DXSe2mvA7bb8X4eIigC+ L5+ghR6Vdill32YeHOyaDiPIQ8uV+WBtJcIYjK3WsDRUnU3ykJP9Qs9nVTZE26NmInWV xvxb48IqtDlG3iwLra6AuV974jg3BDSHIx8g15870R/N0A+6UvxN0O/lNSKfdmdH57/s 7WGjaVGz1yoD83y+P3w+moj0Vunq5l8mK2zX/wSoo4EwAdcO7Yy/5jsMTgSE3GQ3yOh8 iysg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e0WFDm/+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 42-v6si596336ple.151.2018.01.30.16.31.39; Tue, 30 Jan 2018 16:31:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e0WFDm/+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753881AbeA3XZ0 (ORCPT + 99 others); Tue, 30 Jan 2018 18:25:26 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40511 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753815AbeA3XZY (ORCPT ); Tue, 30 Jan 2018 18:25:24 -0500 Received: by mail-pg0-f67.google.com with SMTP id g16so8503231pgn.7; Tue, 30 Jan 2018 15:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=jRsXKN4MTtLXgX9LqNOa3mHqzehlpzl84CPoqorVBtE=; b=e0WFDm/+uDnmIOFbp9KNSLJ89bQFVOOg+BLO8P1YuInhQp6UtIAGb6tzkKp/C1k13g eyNPMwXqil4sXWwBnExc5fVOZ8Td6JUNsn41v2bCN6PkGsHWhUNfSXM+ZdLr9seydtJU iJhJ1HAfU7dQJOkeZtqi9p3NH2fnWfkGQ1d177Hre4rtsHM8wV6d40fyNmNsWKBtIqh4 l7vSxSFvi+lPdL54vdOIE5IQRfIL7+DnygotuqEoMihMLkWOJ5mkthbMDXmVlQop6avx wJVlCcZAsLHMOZvpnVNVy72OZoh5diwmgMyxbqyBdGE5YJjxgr8HncqTTu2b0zavLPTS cB0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=jRsXKN4MTtLXgX9LqNOa3mHqzehlpzl84CPoqorVBtE=; b=kS4fk20m4S5jP41LkU1O9zu0e4S+jegp61nqSyU8xq2WOYw2IT145aEibL6f5d4iw8 +V9/4BmLjlJzmp/jD9hL43GaqVISYnnJur/Ny+UaK68C0Os4v7AGnbPSR5/8X6Yqf6X0 zH+W2T1ackR6ny0rAAwCqNo3xGZ5OusZ2U6bJ2cyyO5Xwcbrra4+LolintR2YR3hwYJ5 UgCVsfVA40wVsvDup9ewqY01UHw5C/W3ZZANuql++3rkUrNNJQZf3pzcZ3RvJUsmn7zW 5QVO4In+yPXpk2sjsNxhBWRQx2UNeTaugXuRdXYuS/TzAP0FqDuQyhSdymwtNglxdTUx xj8w== X-Gm-Message-State: AKwxytemTN4ZRajlRW2t4Zvz+9pSo8fETUR1VESCXMbXK2B8igYg4KYk EwLX2YHQFCU5bSudngV6afY= X-Received: by 10.98.13.14 with SMTP id v14mr31493233pfi.184.1517354723600; Tue, 30 Jan 2018 15:25:23 -0800 (PST) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id c184sm35583361pfc.60.2018.01.30.15.25.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2018 15:25:22 -0800 (PST) Date: Tue, 30 Jan 2018 15:25:21 -0800 From: Guenter Roeck To: =?utf-8?B?c2h1ZmFuX2xlZSjmnY7mm7jluIYp?= Cc: Heikki Krogerus , 'Jun Li' , ShuFanLee , =?utf-8?B?Y3lfaHVhbmco6buD5ZWf5Y6fKQ==?= , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Subject: Re: [PATCH] USB TYPEC: RT1711H Type-C Chip Driver Message-ID: <20180130232521.GA19569@roeck-us.net> References: <20180119082218.GA22976@kuha.fi.intel.com> <25ced79e8ea84908bf6110a613ed81a2@ex1.rt.l> <20180119092413.GB22976@kuha.fi.intel.com> <20180119160235.GA21066@roeck-us.net> <20180122185034.GA26058@roeck-us.net> <20180129195752.GA24352@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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