Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2714737pxb; Tue, 21 Sep 2021 06:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoyxe5QrlBqmNA3ZXic5TRcT0SmIhEghLtQ0kRdDQtGiso1QBhnuIvq5p0s0hqEH6elAKt X-Received: by 2002:a17:906:1b42:: with SMTP id p2mr36517529ejg.210.1632229957259; Tue, 21 Sep 2021 06:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632229957; cv=none; d=google.com; s=arc-20160816; b=A4hHL+NhO+8L98toj9INsOoEBTQKRmpKs570vb1BAru9usAnqm+yYkTomrGdKdUmij ZdWV1bhb3TPbXWbW8md2Agr58Yy/qBvqz/+rl9aGOZ32K6wPk9wleSrBeqk1i1vSQbGf m0JRETtGz+3x5pEq8lpXyFKI043NVGo0S/1qHfnZii8uRaC8suIYkvUUlD0qbcWgqKeB cXaQKYaY4i6yLBcdnOyK/JCN4ZmL04NVB8QcsgW/5QkR4+sJmFWYdf4GYuUHpoo2ES8R BgN2G1E5WmcQ//pxxZrbKiFytOaBF6YnRSKSDq+Uc/6EmikvfdrE0zjwU2r1KMaKKDyx 4lPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=vC1B78jTR9liBMuJFPtZng99OE6Wyi3e/W1QTBLkIs8=; b=lF2dBLo48Re9r4bEEo4mVSFL2s6g/zGcV2A+0kxgyumibbCxZCbqv5hdx28KKvP6cE zm+1yiTNHv1Ptyv87jw3rHEstUhXiPGSsHOUSiJ0lckGb/YUCLnp8CHn8C9nCi3E45ej OaGgj/S/XSUF6KxtGQPxZBA2byMQDkfHUMBGCEQlNE3B4XsvQvuvO65Y/OTaC7N8UKL/ kKSvKp/qNnYGzsI4luF92Ckd9rhdhZb9/L7IEAW1YVsaHYeggEvNrLlMILth08P202NH ZcA0QnFq91G74j2bFsJD1GH+IhI558IzpMUOFXeUDOXP8ZWA4UDQLggSNGLRLTBhbaf/ QsXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si19774957edq.224.2021.09.21.06.12.09; Tue, 21 Sep 2021 06:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbhIUNLu (ORCPT + 99 others); Tue, 21 Sep 2021 09:11:50 -0400 Received: from mga04.intel.com ([192.55.52.120]:42555 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232344AbhIUNLt (ORCPT ); Tue, 21 Sep 2021 09:11:49 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10113"; a="221463249" X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="221463249" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2021 06:10:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="613000879" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 21 Sep 2021 06:10:17 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 21 Sep 2021 16:10:16 +0300 Date: Tue, 21 Sep 2021 16:10:16 +0300 From: Heikki Krogerus To: Sven Peter Cc: Greg Kroah-Hartman , Guido =?iso-8859-1?Q?G=FCnther?= , Bryan O'Donoghue , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: Re: [RFT PATCH 2/9] usb: typec: tipd: Prepare supporting different variants Message-ID: References: <20210918120934.28252-1-sven@svenpeter.dev> <20210918120934.28252-3-sven@svenpeter.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210918120934.28252-3-sven@svenpeter.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sat, Sep 18, 2021 at 02:09:27PM +0200, Sven Peter wrote: > Apple M1 machines come with a variant of the TI TPS6598x and will need > some changes to the current logic. Let's prepare for that by setting up > the infrastructure required to support different variants of this chip > identified by the DT compatible. I think in this case it would make sense to just squash this into the next patch. > Signed-off-by: Sven Peter > --- > drivers/usb/typec/tipd/core.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 21b3ae25c76d..656020e7f533 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -76,6 +77,10 @@ static const char *const modes[] = { > /* Unrecognized commands will be replaced with "!CMD" */ > #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) > > +struct tps6598x_hw { > +}; Black line here. > +static const struct tps6598x_hw ti_tps6598x_data; > + > struct tps6598x { > struct device *dev; > struct regmap *regmap; > @@ -91,6 +96,8 @@ struct tps6598x { > struct power_supply *psy; > struct power_supply_desc psy_desc; > enum power_supply_usb_type usb_type; > + > + const struct tps6598x_hw *hw; > }; > > static enum power_supply_property tps6598x_psy_props[] = { > @@ -590,6 +597,13 @@ static int tps6598x_probe(struct i2c_client *client) > if (!tps) > return -ENOMEM; > > + if (client->dev.of_node) > + tps->hw = of_device_get_match_data(&client->dev); > + else > + tps->hw = &ti_tps6598x_data; > + if (!tps->hw) > + return -EINVAL; tps->hw = of_device_get_match_data(&client->dev); if (!tps->hw) tps->hw = &ti_tps6598x_data; > mutex_init(&tps->lock); > tps->dev = &client->dev; > > @@ -729,8 +743,11 @@ static int tps6598x_remove(struct i2c_client *client) > return 0; > } > > +static const struct tps6598x_hw ti_tps6598x_data = { > +}; You could also move that above tps6598x_probe() and get rid of the forward declaration. > static const struct of_device_id tps6598x_of_match[] = { > - { .compatible = "ti,tps6598x", }, > + { .compatible = "ti,tps6598x", .data = &ti_tps6598x_data }, > {} > }; > MODULE_DEVICE_TABLE(of, tps6598x_of_match); thanks, -- heikki