Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3058556ybt; Mon, 29 Jun 2020 14:10:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylkkg3ZVchDVu1cGTRYguFdAGEvNLSE+xNRlWXO1YuH1uc7F5KzPUrPVfHB3CIVjUnPw0u X-Received: by 2002:a17:906:4c42:: with SMTP id d2mr14872927ejw.345.1593465054934; Mon, 29 Jun 2020 14:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465054; cv=none; d=google.com; s=arc-20160816; b=DnjktJfx25WV900N2BtgepkIm0SJ3kYgpvjHH0soZlWYpEcqpbFOzQLSO61zgVSdl1 IojHD/suDyuqWY5XrkBh1wWtlPAvJbZSm+TX8UJieV3v2UGnrc6UK3JheDQiMKTyuxAj eZKzTd1aaISFSiSENvHH4kwMGIUjLO+V+28C5Rzp1SCXNfOH5XWc/3YtNjLCSq4r/iR5 PwscR1CjZL8xpKLpV4N/1iWGVDkSHNEUXetCEUYTBtxDBq7D5NwiO/NBPOKIF2yoXe77 1/FCydch3khrlH9/tPXy+8X7JCcGBsm42gZlxP5+02J1Xqczm+6gQNK1XCkPDjObWyCp 76aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PbUqdK1otFEuJAwkKU1CGhmnKqFJa2aBCYhP9X9TuK8=; b=G+Koy/+nu+V2zfzKDAPcXca/mOLwOadwcVayMpZGujlcVvv4+ardLGmvGzaYCGRzsN lI/fbprmZGZa1Ew8vZ8ii6Kcs4nKTtTG1Cbb05I2SAKajtV8HKQ5qiBXp0/uqswdm9AS oQ8l4W3S+091MzXdTtaUSqmu+zZkH2UGnLBMc1cw/VM98BLfOs0SCm9/5yYmLf6B/CQj SzcYWlhiMrYAY9TLEAIr00fNkuKJo3SE2uokdKyFjdFscSYegIjuNZKHM4wVTUzlSC4Q StW+XuH7eRqJZrihXuLge3fZNRE3bbvzlY81iyva7uW+/Plf19qsYPES8RLzQ/tz06ko GZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Prw+e3qT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t24si444761ejr.733.2020.06.29.14.10.19; Mon, 29 Jun 2020 14:10:54 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Prw+e3qT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390455AbgF2VIv (ORCPT + 99 others); Mon, 29 Jun 2020 17:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390439AbgF2VIo (ORCPT ); Mon, 29 Jun 2020 17:08:44 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 475D5C03E979 for ; Mon, 29 Jun 2020 14:08:44 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id g13so14009474qtv.8 for ; Mon, 29 Jun 2020 14:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PbUqdK1otFEuJAwkKU1CGhmnKqFJa2aBCYhP9X9TuK8=; b=Prw+e3qTN9JwuIoiIug0Niirg1ym+zVjLsyNSzSMsWW/rrTwPpz6oR3SZgBTuZZKyr qqHnF0cFCgyKjCq1GNdB0P5a9qFBHfo1z3qfvmHCMugOFPVjpffw4PF3nYMsh8FMzacd QOo3cKUkDXvrUmL0ueE6l7YrQH23TQwpl3bSw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PbUqdK1otFEuJAwkKU1CGhmnKqFJa2aBCYhP9X9TuK8=; b=hDUN51wpcr8CBVcRqeHE7gUIXzpxjOrxrR8iC9/TGmTxy5edfY4rbA2EPjzm0l037v tYj+UHiKdADZvs7nxjdpzGi5yV/hWzBXEGqQKRxKC3gV4ANZJROlibWYTxUoPFH/LVz6 m5MiT9r45M57snHLkOSUXoiXmUdiqAWBBLCWDRRK1YXfl8DjFhLGJi6+XbYnsJJvq+Q6 e6ZHtyzUnE4n4DEqfEMut/1JmeU2tp610qC5sn9XfAiC2WU9bpL3uVeMPYEBHY4+cqtq s+SYOvqlN/K14unBk6fRucsHR7otzgeDjNteXNILQ77i36GM5YjkSwi916wF3b6+6MFY kwbQ== X-Gm-Message-State: AOAM532jTcShKY361FwM4KTrOw2o1nb3bIiV7p4AiRxhSyuXFdQOOfmP aAuk8H5qG1ajztGjWbsvsj6Vaxw6PiZWHFH0ZV9QTQ== X-Received: by 2002:ac8:2a3d:: with SMTP id k58mr2187470qtk.265.1593464923410; Mon, 29 Jun 2020 14:08:43 -0700 (PDT) MIME-Version: 1.0 References: <20200629163851.2130450-1-pmalani@chromium.org> In-Reply-To: From: Prashant Malani Date: Mon, 29 Jun 2020 14:08:31 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update To: Guenter Roeck Cc: linux-kernel , Heikki Krogerus , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, Thanks for the comments. On Mon, Jun 29, 2020 at 2:05 PM Guenter Roeck wrote: > > On Mon, Jun 29, 2020 at 9:38 AM Prashant Malani wrote: > > > > Use a work queue to call the port update routines, instead of doing it > > directly in the PD notifier callback. This will prevent other drivers > > with PD notifier callbacks from being blocked on the port update routine > > completing. > > > > Signed-off-by: Prashant Malani > > --- > > > > Changes in v3: > > - Use new 100 character line length limit. > > > > Changes in v2: > > - No changes. > > > > drivers/platform/chrome/cros_ec_typec.c | 25 ++++++++++++++++++++----- > > 1 file changed, 20 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > > index 0c041b79cbba..0beb62bf5adf 100644 > > --- a/drivers/platform/chrome/cros_ec_typec.c > > +++ b/drivers/platform/chrome/cros_ec_typec.c > > @@ -58,6 +58,7 @@ struct cros_typec_data { > > /* Array of ports, indexed by port number. */ > > struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; > > struct notifier_block nb; > > + struct work_struct port_work; > > }; > > > > static int cros_typec_parse_port_props(struct typec_capability *cap, > > @@ -619,18 +620,26 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) > > return 0; > > } > > > > -static int cros_ec_typec_event(struct notifier_block *nb, > > - unsigned long host_event, void *_notify) > > +static void cros_typec_port_work(struct work_struct *work) > > { > > - struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, > > - nb); > > - int ret, i; > > + struct cros_typec_data *typec = container_of(work, struct cros_typec_data, port_work); > > + int ret; > > + int i; > > > > I know I am getting picky here, but this seems like a personal > preference change. There is no "one variable declaration per line" > coding style rule. Done. > > > for (i = 0; i < typec->num_ports; i++) { > > ret = cros_typec_port_update(typec, i); > > if (ret < 0) > > dev_warn(typec->dev, "Update failed for port: %d\n", i); > > } > > +} > > + > > + > > ... but anyway, there should be no double empty lines. > Done. > > +static int cros_ec_typec_event(struct notifier_block *nb, > > + unsigned long host_event, void *_notify) > > +{ > > + struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, nb); > > + > > + schedule_work(&typec->port_work); > > > > return NOTIFY_OK; > > } > > @@ -689,6 +698,12 @@ static int cros_typec_probe(struct platform_device *pdev) > > if (ret < 0) > > return ret; > > > > + INIT_WORK(&typec->port_work, cros_typec_port_work); > > + > > + /* > > + * Safe to call port update here, since we haven't registered the > > + * PD notifier yet. > > + */ > > for (i = 0; i < typec->num_ports; i++) { > > ret = cros_typec_port_update(typec, i); > > if (ret < 0) > > -- > > 2.27.0.212.ge8ba1cc988-goog > >