Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2978380pxb; Sat, 23 Oct 2021 12:39:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEfy7GA6YsTzMJ2ICJ52GpsBpwPwIWVp6MrWvisgEK6nz1gOFzYAMYscznyR+8b8q2UAzo X-Received: by 2002:a17:907:1c97:: with SMTP id nb23mr9370963ejc.488.1635017967462; Sat, 23 Oct 2021 12:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635017967; cv=none; d=google.com; s=arc-20160816; b=klymBeY9St5cbGowwzqyQYW47kAlS97k1y53DZ7l+2011FooBu7IO/UhL2vC1FmGhT Awn91UomGRCWbWNXr6yJJf+ZXE+/kisbZC8rn2JsSy4JdAe6uhjH9AlCnql+8LuIhZ3J d0xvLdP0Bc8bO29PiMJpIG2edGnL8D2UIWidP0MmnpyhH2UyOrDL1g7QLgLXu7pi6+xH PDtmuCZmSMetlpEie23Lyh0yL1rOPlluhw1y1490oelHs/YCFeS8+R+t/N6eEB2gC1KJ CBl5lJBAfxjQiwIHsnknaA2iRcHCeDDr181I61H2iQP8HNVf3/WbfvWCNS+awimdmf9O YjAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=sv+P4t4HOtzS0s5BRJEDSfrnmdivy+UovtYMEj8jPBU=; b=h+eNP+7H1udi3hrUNTGRts3KmR2KMUvCQuTGJ6bF6r+IKnLCqFccBIX4hHBXt8N48e VKoH4+AoMyl/V0toMZMHTegGJOmu26xKrgVisrJh0HL+mDbD473NY1pkrQh/sCJ1/lZ6 hL6c/2jJQlNpBPGotdbRWwU5eZEYkjsdTlil2RvcWJwyByXqPiruRd0OEkijzeQUk7bt CfOL5I50qEgQYut7t0xh0hZNvSMmWmZzyfO5bdFL+cLA49XyH9Tj+58ywiV7kECw6UYe QajHlGUKRfpBMffXRq/Nl6Bu3RT3oLAfy1uqxL6BKxJD/2yAcmYV1js1wB1b4c5y42Z8 surQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg13si26760324ejc.220.2021.10.23.12.39.04; Sat, 23 Oct 2021 12:39:27 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231165AbhJWTjG (ORCPT + 99 others); Sat, 23 Oct 2021 15:39:06 -0400 Received: from smtprelay0057.hostedemail.com ([216.40.44.57]:51284 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230230AbhJWTjG (ORCPT ); Sat, 23 Oct 2021 15:39:06 -0400 Received: from omf12.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id D9BBB181C43D8; Sat, 23 Oct 2021 19:36:44 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA id B196D240234; Sat, 23 Oct 2021 19:36:42 +0000 (UTC) Message-ID: <663d3820f118c37a81529b3362b95e09c8e75e9f.camel@perches.com> Subject: Re: [PATCH] coresight: Use devm_bitmap_zalloc when applicable From: Joe Perches To: Christophe JAILLET , mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, alexander.shishkin@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Sat, 23 Oct 2021 12:36:41 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.54 X-Stat-Signature: cn5t8cb9epzithy65nu1xystn5p8usud X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: B196D240234 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18iFmpi7RwWrxrwqT0wAZ7yhteFsFr3AGo= X-HE-Tag: 1635017802-700607 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-10-23 at 21:24 +0200, Christophe JAILLET wrote: > 'drvdata->chs.guaranteed' is a bitmap. So use 'devm_bitmap_kzalloc()' to > simplify code, improve the semantic and avoid some open-coded arithmetic > in allocator arguments. [] > diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c [] > @@ -862,7 +862,6 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) > struct stm_drvdata *drvdata; > struct resource *res = &adev->res; > struct resource ch_res; > - size_t bitmap_size; > struct coresight_desc desc = { 0 }; > > desc.name = coresight_alloc_device_name(&stm_devs, dev); > @@ -904,9 +903,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) > else > drvdata->numsp = stm_num_stimulus_port(drvdata); > > - bitmap_size = BITS_TO_LONGS(drvdata->numsp) * sizeof(long); > - > - guaranteed = devm_kzalloc(dev, bitmap_size, GFP_KERNEL); > + guaranteed = devm_bitmap_zalloc(dev, drvdata->numsp, GFP_KERNEL); > if (!guaranteed) > return -ENOMEM; > drvdata->chs.guaranteed = guaranteed; guaranteed is also pretty useless