Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3056197ybt; Mon, 29 Jun 2020 14:07:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtsgjCApo/lL40RiuSOI9ptJjpuiEosvoVH89TRUbdYmi4vmDQdNZLYq5Ofo9OtwaXwGff X-Received: by 2002:a05:6402:1494:: with SMTP id e20mr8065731edv.2.1593464833578; Mon, 29 Jun 2020 14:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593464833; cv=none; d=google.com; s=arc-20160816; b=r3S/bo2AypPlOV+rNQIvTFjVLRZAFF1XQ2gSOqYJhvbAcYbz6+TY4UUk0R5UdewGsX tt0vjbSqC/9hnOeOrO8VN3b3xqFignTB+YsbC8HqmXcBNOZYfmOK5LbPnr8lr2A3/j/v T8Prt4Y0+uhn2APWgjtYO/0PhbmzytPrguMjPFJwOz8Rsr1wo4em0NUDN+GDdVkQSKqB NjOdrBn/hykNQjilWBXn4ut4gwAkCOJjCQcAEoY/hGlPlnvHLaEniLQcOOtmhE3gxVtA Djobd3+0lqaIpy+wQ7wwh5nrdPy1JMCv074WvXAOiZ5dvCaFnqLeSyl1pPFbr5P6E4Cy ZyHw== 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=N5+uXhdVLL1JQ/BpOyWY0ygfez6SfYmoRUf/dprU/yU=; b=PRj+yLqjxiOx3+VAzCWhgTbp850h19TwiENMS39haQxUcqbpA9LKHjHjj2vcXzFhFs wCQ092TrHaJVtstGboHboD6dEFaWGFe5wbI1uOQi9+c4wgzCVEvGZq5I55qFIZqQrMk9 AvkVN+YpGeJk0MXwIhWZPLhZcUBoIVk8J/nxLkj08s+AuStwYRkpM17w7uzU4xbtn7Wz PdLneOHcLwvaV37GDEUSpl3j0g7StcJMBzFVpuy8vVybwL+sSJyLHtGWCKq2OGPRewI2 SqGQfiZUgRroPsKhKLy05XoIi6VSPIdlxw6+Wy+upUPGGEFlT+bQyKPzcfLYORNXu/8H ebIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DAjeBl1F; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gy14si387433ejb.313.2020.06.29.14.06.50; Mon, 29 Jun 2020 14:07:13 -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=@google.com header.s=20161025 header.b=DAjeBl1F; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731606AbgF2VFb (ORCPT + 99 others); Mon, 29 Jun 2020 17:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390154AbgF2VFQ (ORCPT ); Mon, 29 Jun 2020 17:05:16 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F68CC061755 for ; Mon, 29 Jun 2020 14:05:15 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id i14so18254637ejr.9 for ; Mon, 29 Jun 2020 14:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N5+uXhdVLL1JQ/BpOyWY0ygfez6SfYmoRUf/dprU/yU=; b=DAjeBl1FR1/DsgxRPaw2h7sQ6NmKmhZOtQFKgN7YjvWQhxictsYYSeYGazOoUUQyVX alqgM2kNHwP4fyBEJbljNuPX4+oLFlR2Kg2TWkD56BYOjT6EOB8jJLvp2Hdv+ufX1/nV mmR4Vqn9Fw1p6ceCJxEKRz7RTmN7e+1f3A8vIkd6+JR64a8eHe4mZgHVXYmWhrkpCWMX wBIybOQwCJa3YXNY71dAYltEmU1ivZPlvNAjUR6HNAK0i74Wp0jhtOIrxrhLRhBgNoAl rXr7U7XMJJbc3tml365yyXerE1Qx0L2CcPue0xQ4AUqvS1l5pBgl+U9Y27beRtN3x621 UbIA== 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=N5+uXhdVLL1JQ/BpOyWY0ygfez6SfYmoRUf/dprU/yU=; b=i3s3vRA8ZAglJ/oA1f2r6hKDTttIdEQ3yFNTAeh2eGO8bTFeSX7WXWWvXwLcch3QSj VB+x5otjuCJDRcbkIJfN64Vsvb2FD4ZHdGQXXIlfcTYgaDnxFBiLRk0hQdt6O9lpFfEA JhYad+hCcGdXLqrG69EGV5Qk0cy/XKWD94jVErQeQJwmYm5XQz2GWxgNg1dHtLvvYVC6 MAK8wFbaAe3ooEMr2h2CrHPAOlLNEKcDQk/PNNX65hW6m+oLA+KFogVCxnH31gwXRQAf hKj6dkmwx9eV65UY/eQpXEPmdBV0RDuYWQvO6LIMy+RV6tq1+ixMMuT8F53RQ3oMoX4a Lx2A== X-Gm-Message-State: AOAM531tevBtox3+0L7+J+Ig08gu2lm6WYMbmu1w4aPzMolYGelRWdwI iOg0Q40LGt0Ar6UNdhm1mxcvWDlARbFOgJO80Ty3Ww== X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr15149889eji.547.1593464713805; Mon, 29 Jun 2020 14:05:13 -0700 (PDT) MIME-Version: 1.0 References: <20200629163851.2130450-1-pmalani@chromium.org> In-Reply-To: <20200629163851.2130450-1-pmalani@chromium.org> From: Guenter Roeck Date: Mon, 29 Jun 2020 14:05:02 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update To: Prashant Malani 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 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. > 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. > +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 >