Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3441111pxb; Mon, 4 Apr 2022 17:06:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfZflPUeMZomFW0p3NZEBuG4NQ0BZCZqokW5zvR10oIFihzD1X62JJf93c5TQKONlVySZS X-Received: by 2002:a63:cd4f:0:b0:382:26ba:8858 with SMTP id a15-20020a63cd4f000000b0038226ba8858mr554622pgj.521.1649117184034; Mon, 04 Apr 2022 17:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649117184; cv=none; d=google.com; s=arc-20160816; b=1DTNgB0RVy9r0PSsAEmVBltY+U5SVe5EC4aoTVRsYlLfk2OudRjUmXiqdJBvYSYpDG b+FyoIy4DRTi28uUNCARi3X5d8axr12ERBWaIC9C44hpwRbi5nkoxldQa3HvOAmLG7+J MIt3yqaacZlIbyiRi8rU7QtJFM5qra7liCDuwxUoPJc8s4AtX3aCAytwC83MCj+lBRrF 0bk9h7dT0fULoYuYnuXwxsWt6XwmeP6hwdssjv/Ank9P1HgEJByFDkgFOhG6In9jUyZQ BFN+EHxWSLTDPMPUxe9Gm3VJ+NXq2XHSv+KLsQfPZSdNlyJg+QMx+mcbx88g1mP+igS+ ELcA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JckRu8uAXEaQ9M8sevF6RzeqsyPdwGYLTaUt6TxTM64=; b=Iw8v3wOtLwjQiOa7eau0s4oK9oyAHLZptypXi2FOiNo9bUeTkYiD9VvSU41vI4HhsM zULu5PCyUKZ3czuiXmZCNlnVrEmj1IhNOcrWDbbv0OyoTxR594uOUmkUr0kSTnU5I2d6 Aj5sVDNnpmHsGWeycEA6MvlbHUMf28RSJBU9ZFNPtte8TM8Pa/2Zxozhv3ttEVqJLsf7 iMXD3Z7Yv8ibkGSUJIE0nofvZRedUdxPrwSBmZF1y3LTaUhXvgshHEgLaDUzKty6lHVu TYlkB9E11GqQhjxlx19TFODtGZi8+zU/YRo4zi+eZJe9vW5wIGF2es5XA9Q8t3Jr5n99 shBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M7MszzmE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k17-20020aa788d1000000b004fb2ca5f6fcsi11676290pff.26.2022.04.04.17.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 17:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M7MszzmE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3DC44532F6; Mon, 4 Apr 2022 16:40:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349617AbiDDOGP (ORCPT + 99 others); Mon, 4 Apr 2022 10:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244291AbiDDOGN (ORCPT ); Mon, 4 Apr 2022 10:06:13 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 386F914020; Mon, 4 Apr 2022 07:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649081056; x=1680617056; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=IaLjVCjn5OCwpTld4VqPhcL+KM4VHWB3lKaf3AttWrs=; b=M7MszzmEz+o3j8imtTXSYsClGfxDw/3rnolH1ZxA/IwnWx8LDKiVHpFT atawTdbIazPCvlSiF8329OVbFcNlak9An8CMTnBbU1wOtuYYArmjClujd DcDqDbJE5ZKAVdhJ0GuZOu0sGJixZIiv66ArcVwRIFsqX6reVzHFdfOBB GQD+qT4QV1zxYSQZL6rodEdlUTsciHxgMcLHyyhLdy5GjL9fBWxuyh72Q IgTCycnXF9ckNR/mFt95WhzBE28KMVPvyo6eg9yHlBgWkbJMC6tPwl0nK sYcd36iNJmKYEa+nFeINQiT4kBv7M4dsvL1UBRzGycIxGNTlQj75zDVaJ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10306"; a="285469767" X-IronPort-AV: E=Sophos;i="5.90,234,1643702400"; d="scan'208";a="285469767" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2022 07:03:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,234,1643702400"; d="scan'208";a="696577924" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 04 Apr 2022 07:03:51 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 04 Apr 2022 17:03:51 +0300 Date: Mon, 4 Apr 2022 17:03:51 +0300 From: Heikki Krogerus To: Sebastian Krzyszkowiak Cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , Sven Peter , Guido =?iso-8859-1?Q?G=FCnther?= , Angus Ainslie , Hector Martin , Bryan O'Donoghue , linux-kernel@vger.kernel.org, kernel@puri.sm Subject: Re: [PATCH 6/7] usb: typec: tipd: Add debugfs entries for customer use word Message-ID: References: <20220317154518.4082046-1-sebastian.krzyszkowiak@puri.sm> <20220317154518.4082046-7-sebastian.krzyszkowiak@puri.sm> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220317154518.4082046-7-sebastian.krzyszkowiak@puri.sm> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2022 at 04:45:17PM +0100, Sebastian Krzyszkowiak wrote: > From: Guido G?nther > > This allows to verify that a sane firmware is on the device. > > Signed-off-by: Guido G?nther > Signed-off-by: Sebastian Krzyszkowiak Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/tipd/core.c | 65 +++++++++++++++++++++++++++++++++++ > 1 file changed, 65 insertions(+) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 874528b02a99..d3c70aaf1a0c 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -6,6 +6,7 @@ > * Author: Heikki Krogerus > */ > > +#include > #include > #include > #include > @@ -22,6 +23,7 @@ > /* Register offsets */ > #define TPS_REG_VID 0x00 > #define TPS_REG_MODE 0x03 > +#define TPS_REG_CUSTOMER_USE 0x06 > #define TPS_REG_CMD1 0x08 > #define TPS_REG_DATA1 0x09 > #define TPS_REG_INT_EVENT1 0x14 > @@ -99,10 +101,15 @@ struct tps6598x { > struct power_supply *psy; > struct power_supply_desc psy_desc; > enum power_supply_usb_type usb_type; > + > struct tps6598x_pdo terms; > > u32 data_status; > u16 pwr_status; > +#ifdef CONFIG_DEBUG_FS > + struct dentry *dev_dentry; > + struct dentry *customer_user_dentry; > +#endif > }; > > static enum power_supply_property tps6598x_psy_props[] = { > @@ -239,6 +246,62 @@ static void tps6598x_set_data_role(struct tps6598x *tps, > typec_set_data_role(tps->port, role); > } > > +#ifdef CONFIG_DEBUG_FS > +static struct dentry *rootdir; > + > +static int tps6598x_debug_customer_use_show(struct seq_file *s, void *v) > +{ > + struct tps6598x *tps = (struct tps6598x *)s->private; > + u64 mode64; > + int ret; > + > + mutex_lock(&tps->lock); > + > + ret = tps6598x_block_read(tps, TPS_REG_CUSTOMER_USE, &mode64, sizeof(mode64)); > + if (!ret) > + seq_printf(s, "0x%016llx\n", mode64); > + > + mutex_unlock(&tps->lock); > + > + return 0; > +} > +DEFINE_SHOW_ATTRIBUTE(tps6598x_debug_customer_use); > + > +static void tps6598x_debugfs_init(struct tps6598x *tps) > +{ > + struct dentry *dentry; > + > + if (!rootdir) > + rootdir = debugfs_create_dir("tps6598x", NULL); > + > + dentry = debugfs_create_dir(dev_name(tps->dev), rootdir); > + if (IS_ERR(dentry)) > + return; > + tps->dev_dentry = dentry; > + > + dentry = debugfs_create_file("customer_use", > + S_IFREG | 0444, tps->dev_dentry, > + tps, &tps6598x_debug_customer_use_fops); > + if (IS_ERR(dentry)) > + return; > + tps->customer_user_dentry = dentry; > +} > + > +static void tps6598x_debugfs_exit(struct tps6598x *tps) > +{ > + debugfs_remove(tps->customer_user_dentry); > + debugfs_remove(tps->dev_dentry); > + debugfs_remove(rootdir); > + rootdir = NULL; > +} > + > +#else > + > +static void tps6598x_debugfs_init(const struct tps6598x *tps) { } > +static void tps6598x_debugfs_exit(const struct tps6598x *tps) { } > + > +#endif > + > static int tps6598x_connect(struct tps6598x *tps, u32 status) > { > struct typec_partner_desc desc; > @@ -995,6 +1058,7 @@ static int tps6598x_probe(struct i2c_client *client) > } > > i2c_set_clientdata(client, tps); > + tps6598x_debugfs_init(tps); > > return 0; > > @@ -1011,6 +1075,7 @@ static int tps6598x_remove(struct i2c_client *client) > { > struct tps6598x *tps = i2c_get_clientdata(client); > > + tps6598x_debugfs_exit(tps); > tps6598x_disconnect(tps, 0); > typec_unregister_port(tps->port); > usb_role_switch_put(tps->role_sw); > -- > 2.35.1 -- heikki