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=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 05B45C3F2D2 for ; Fri, 28 Feb 2020 07:15:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BE0E0246A0 for ; Fri, 28 Feb 2020 07:15:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="XxdwK4hX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE0E0246A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 403C16B0005; Fri, 28 Feb 2020 02:15:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B3E46B0006; Fri, 28 Feb 2020 02:15:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A13E6B0007; Fri, 28 Feb 2020 02:15:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id 108006B0005 for ; Fri, 28 Feb 2020 02:15:25 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BF6A9180AD80F for ; Fri, 28 Feb 2020 07:15:24 +0000 (UTC) X-FDA: 76538674968.19.door08_121c1cbd8ec48 X-HE-Tag: door08_121c1cbd8ec48 X-Filterd-Recvd-Size: 3680 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Fri, 28 Feb 2020 07:15:24 +0000 (UTC) Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6D562469D; Fri, 28 Feb 2020 07:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582874123; bh=bzqcvY1+w7p+H0tBmGUux2b6d1gIUiq/keZNLNBznKc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XxdwK4hX9SZG6cAVJ0xxZYzqkemDxOmWY+1cEmTnG4oE4Is+PBG7kHaRUPLcqZa6I d6IGDzBLr4do0Wg1pJ5rCWIJV/BjZIkr2D3Cl0iJkW8GoyZG6jjyNX/oSPJsGpkcGC 3xXHY8ZcCXVl//QBuWTZ6yQC5BG057R15eUhlo4Q= Date: Fri, 28 Feb 2020 08:15:20 +0100 From: Greg Kroah-Hartman To: Andrew Donnellan Cc: Alastair D'Silva , alastair@d-silva.org, "Aneesh Kumar K . V" , Oliver O'Halloran , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Frederic Barrat , Arnd Bergmann , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Andrew Morton , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Anton Blanchard , Krzysztof Kozlowski , Mahesh Salgaonkar , Madhavan Srinivasan , =?iso-8859-1?Q?C=E9dric?= Le Goater , Anju T Sudhakar , Hari Bathini , Thomas Gleixner , Greg Kurz , Nicholas Piggin , Masahiro Yamada , Alexey Kardashevskiy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org Subject: Re: [PATCH v3 25/27] powerpc/powernv/pmem: Expose the serial number in sysfs Message-ID: <20200228071520.GA2897773@kroah.com> References: <20200221032720.33893-1-alastair@au1.ibm.com> <20200221032720.33893-26-alastair@au1.ibm.com> <96687fbf-38ab-13ff-ca19-ccb67bbc4405@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <96687fbf-38ab-13ff-ca19-ccb67bbc4405@linux.ibm.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Feb 28, 2020 at 05:25:31PM +1100, Andrew Donnellan wrote: > On 21/2/20 2:27 pm, Alastair D'Silva wrote: > > +int ocxlpmem_sysfs_add(struct ocxlpmem *ocxlpmem) > > +{ > > + int i, rc; > > + > > + for (i = 0; i < ARRAY_SIZE(attrs); i++) { > > + rc = device_create_file(&ocxlpmem->dev, &attrs[i]); > > + if (rc) { > > + for (; --i >= 0;) > > + device_remove_file(&ocxlpmem->dev, &attrs[i]); > > I'd rather avoid weird for loop constructs if possible. > > Is it actually dangerous to call device_remove_file() on an attr that hasn't > been added? If not then I'd rather define an err: label and loop over the > whole array there. None of this should be used at all, just use attribute groups properly and the driver core will handle this all for you. device_create/remove_file should never be called by anyone anymore if at all possible. thanks, greg k-h