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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 D18FAC3F2D0 for ; Fri, 28 Feb 2020 07:16:56 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 370CD2469F for ; Fri, 28 Feb 2020 07:16:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="XxdwK4hX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 370CD2469F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48TLSk0H3hzDrLj for ; Fri, 28 Feb 2020 18:16:54 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=gregkh@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=XxdwK4hX; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48TLR210HjzDrCG for ; Fri, 28 Feb 2020 18:15:25 +1100 (AEDT) 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 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhavan Srinivasan , Alexey Kardashevskiy , Mahesh Salgaonkar , Masahiro Yamada , Oliver O'Halloran , Mauro Carvalho Chehab , Ira Weiny , Thomas Gleixner , Rob Herring , Dave Jiang , linux-nvdimm@lists.01.org, "Aneesh Kumar K . V" , Krzysztof Kozlowski , Anju T Sudhakar , alastair@d-silva.org, Arnd Bergmann , Greg Kurz , Nicholas Piggin , =?iso-8859-1?Q?C=E9dric?= Le Goater , Dan Williams , Hari Bathini , Alastair D'Silva , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vishal Verma , Frederic Barrat , Paul Mackerras , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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