Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757362AbbFQRkv (ORCPT ); Wed, 17 Jun 2015 13:40:51 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:36122 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755487AbbFQRkn (ORCPT ); Wed, 17 Jun 2015 13:40:43 -0400 Date: Wed, 17 Jun 2015 18:40:09 +0100 From: Mark Brown To: Tomeu Vizoso Cc: linux-arm-kernel@lists.infradead.org, Alexander Holler , Alexandre Courbot , Andrzej Hajda , Arnd Bergmann , Dmitry Torokhov , Grant Likely , Greg Kroah-Hartman , Ian Campbell , Javier Martinez Canillas , Krzysztof Kozlowski , Kumar Gala , Len Brown , Linus Walleij , linux-kernel@vger.kernel.org, Lv Zheng , Mark Rutland , Pawel Moll , "Rafael J. Wysocki" , Robert Moore , Rob Herring , Russell King , Stephen Warren , Terje =?iso-8859-1?Q?Bergstr=F6m?= , Thierry Reding Message-ID: <20150617174009.GZ14071@sirena.org.uk> References: <1434548543-22949-1-git-send-email-tomeu.vizoso@collabora.com> <1434548543-22949-9-git-send-email-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lBgcuyUB+qD0f9A9" Content-Disposition: inline In-Reply-To: <1434548543-22949-9-git-send-email-tomeu.vizoso@collabora.com> X-Cookie: The end of labor is to gain leisure. User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Re: [PATCH 08/13] gpio: sysfs: implement class.get_dependencies() X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2271 Lines: 76 --lBgcuyUB+qD0f9A9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jun 17, 2015 at 03:42:18PM +0200, Tomeu Vizoso wrote: > +static bool strends(const char *str, const char *postfix) > +{ > + if (strlen(str) < strlen(postfix)) > + return false; > + > + return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; > +} This is named like (and looks like) a generic fuction, shouldn't it be in string.h or something? > +static void add_dependency(struct fwnode_handle *fwnode, > + struct list_head *list) > +{ > + struct fwnode_dependency *dep; > + > + dep = kzalloc(sizeof(*dep), GFP_KERNEL); > + if (!dep) > + return; > + > + INIT_LIST_HEAD(&dep->dependency); > + dep->fwnode = fwnode; > + > + list_add_tail(&dep->dependency, list); > +} Might be worth putting this in generic code, it looks pretty generic? I have to say I'm unclear what frees the returned list. > + if (!is_of_node(fwnode)) > + return NULL; > + > + np = of_node(fwnode); > + if (!np) > + return NULL; Presumably the first check could be dropped? > + list = kzalloc(sizeof(*list), GFP_KERNEL); > + if (!list) > + return NULL; Might it make sense for the core to allocate the head of the list and just ask the classes to add to the list? We're going to want to merge the dependencies from multiple subsystems and that saves allocating heads that may never get anything added to them. --lBgcuyUB+qD0f9A9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJVgbD4AAoJECTWi3JdVIfQzssH/3tLWnzGf1xL5GAewwP5wm0i Ty16kaWakB0UXW7fq6Dlx/lPN1aJsOT6VarRHrKPR86ZdajpW42iBm/0faD04EdT S6GcHYPNs0llr3wphKuAPZZQD1qyXKHnv0eLmmtKBoht8P63EGcz6JQpDv8MwwJC cRoKpxL6N37GBPelxN8ZxAVKbV+veTaNfDlJPes9y5ombZhAolxlVtjM99cgoVZI KJsV4CtTFkw8d7Xlpdrn8VwI5XL5/4OtdlfgQvC3Uv6hGPNIAdKuaNWxAvVM7MsN ChjlA7udpFko35Qr2oSfUuyZtmzXCPvn1I1dF7h+2c9zXxpcyOYebA12pzTGORQ= =KFIY -----END PGP SIGNATURE----- --lBgcuyUB+qD0f9A9-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/