From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38B47C47095 for ; Wed, 9 Jun 2021 09:02:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A23D61185 for ; Wed, 9 Jun 2021 09:02:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A23D61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DheZXEcmzTiMZMi87GDfP8BTocdjhF7qOO5CG6V12Iw=; b=AH/PI6MAnwN+YL FkyQLf6658rtYzOpP7FjXe3lrkKCQ1Q/5WbuefHlafqC94uM0Cds/oLJD6b3loD4MSWEoXbnvyYEn WAetSbk3KIrGZ/9hGriMa1nXFBDZX1oNza4I4OtlkhkHHMkTOed9hvZ03y2G/abSDMAxDZTvGb4Jb pWuCvwuKaJ3M12ARMyAIxunR/ojD6QS3UIn/Of/OPdAQEmCB8j/FxVrKC8Qe9iCGmlKVfOb8mrk1y ZQBJN0vA5Ro0SSMtj8wzdybzoPTfmw1Jvpz+TPyIopo8iM0N4KDTxXDVtOEJd1M1O+o7SWxBMxU+p tZDOJCtwwpn3e86BUCvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqu3j-00CWmi-6A; Wed, 09 Jun 2021 08:59:37 +0000 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqtG5-00CI35-Q7 for linux-arm-kernel@lists.infradead.org; Wed, 09 Jun 2021 08:08:19 +0000 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 159816I3028665; Wed, 9 Jun 2021 08:07:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=NnLFLy6WiVANq4ptGMm8XdcANXjvh36YpOOiuo1dOgQ=; b=mAMgVxXKyBWt5WCOYIyPcZWO01FH2Jwe6e7G+c2ONOURttrX/UnoaeVTCJ2TvIfOsoGi EX6wUJFa8SzMbEDf5H6frysLFa+6wAEwft68o1we4l/7r/B39khQ+Eqwhig5hs24kaja V3axR98mIbLH5HgeYAz6vxZFrXsvgte09rch22M/Q7I/PyKNjB/d2jYazHlkHx0yfh2d udfJF2tzP8F0zdRGt7vkhMVCO98xjReUMF8nYtUy1cm1mcwh5FY9i8nPhx/kdPFjg6Zy 4WhXz2k33qB3WnOjLGidhIHEc1lkzsiUODKXRDet1qmtff0E8L/ph2CwQw8m775d4hw0 Bg== Received: from oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 392ptc82c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 08:07:24 +0000 Received: from userp3030.oracle.com (userp3030.oracle.com [127.0.0.1]) by pps.podrdrct (8.16.0.36/8.16.0.36) with SMTP id 15987NwI008371; Wed, 9 Jun 2021 08:07:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3030.oracle.com with ESMTP id 38yxcvf8dx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 08:07:23 +0000 Received: from userp3030.oracle.com (userp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 15987MPF008350; Wed, 9 Jun 2021 08:07:22 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 38yxcvf8ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 08:07:22 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 15987I9a021286; Wed, 9 Jun 2021 08:07:19 GMT Received: from kadam (/41.212.42.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Jun 2021 01:07:18 -0700 Date: Wed, 9 Jun 2021 11:07:08 +0300 From: Dan Carpenter To: William Breathitt Gray Cc: jic23@kernel.org, linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com Subject: Re: [PATCH v11 26/33] counter: Add character device interface Message-ID: <20210609080708.GL10983@kadam> References: <2b9526ab7f2de91bb867cbd3b12552c77c00b655.1623201082.git.vilhelm.gray@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2b9526ab7f2de91bb867cbd3b12552c77c00b655.1623201082.git.vilhelm.gray@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-ORIG-GUID: iI8kgw7SjTD5aVufBK71XYzTdzproYAH X-Proofpoint-GUID: iI8kgw7SjTD5aVufBK71XYzTdzproYAH X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210609_010817_907848_B9BF097D X-CRM114-Status: GOOD ( 22.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 09, 2021 at 10:31:29AM +0900, William Breathitt Gray wrote: > +static int counter_set_event_node(struct counter_device *const counter, > + struct counter_watch *const watch, > + const struct counter_comp_node *const cfg) > +{ > + struct counter_event_node *event_node; > + struct counter_comp_node *comp_node; > + The caller should be holding the counter->events_list_lock lock but it's not. > + /* Search for event in the list */ > + list_for_each_entry(event_node, &counter->next_events_list, l) > + if (event_node->event == watch->event && > + event_node->channel == watch->channel) > + break; > + > + /* If event is not already in the list */ > + if (&event_node->l == &counter->next_events_list) { > + /* Allocate new event node */ > + event_node = kmalloc(sizeof(*event_node), GFP_ATOMIC); > + if (!event_node) > + return -ENOMEM; > + > + /* Configure event node and add to the list */ > + event_node->event = watch->event; > + event_node->channel = watch->channel; > + INIT_LIST_HEAD(&event_node->comp_list); > + list_add(&event_node->l, &counter->next_events_list); > + } > + > + /* Check if component watch has already been set before */ > + list_for_each_entry(comp_node, &event_node->comp_list, l) > + if (comp_node->parent == cfg->parent && > + comp_node->comp.count_u8_read == cfg->comp.count_u8_read) > + return -EINVAL; > + > + /* Allocate component node */ > + comp_node = kmalloc(sizeof(*comp_node), GFP_ATOMIC); > + if (!comp_node) { > + /* Free event node if no one else is watching */ > + if (list_empty(&event_node->comp_list)) { > + list_del(&event_node->l); > + kfree(event_node); > + } > + return -ENOMEM; > + } > + *comp_node = *cfg; > + > + /* Add component node to event node */ > + list_add_tail(&comp_node->l, &event_node->comp_list); > + > + return 0; > +} > + > +static int counter_disable_events(struct counter_device *const counter) > +{ > + unsigned long flags; > + int err = 0; > + > + spin_lock_irqsave(&counter->events_list_lock, flags); > + > + counter_events_list_free(&counter->events_list); > + > + if (counter->ops->events_configure) > + err = counter->ops->events_configure(counter); > + > + spin_unlock_irqrestore(&counter->events_list_lock, flags); > + > + counter_events_list_free(&counter->next_events_list); > + > + return err; > +} > + > +static int counter_add_watch(struct counter_device *const counter, > + const unsigned long arg) > +{ > + void __user *const uwatch = (void __user *)arg; > + struct counter_watch watch; > + struct counter_comp_node comp_node = {0}; Always use = {};. It's the new hotness, and it avoids a Sparse warning for using 0 instead of NULL. #IDidNotTest #CouldBeWrongAboutSparse > + size_t parent, id; > + struct counter_comp *ext; > + size_t num_ext; > + int err; > + regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel