From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756576AbcJGNI1 (ORCPT ); Fri, 7 Oct 2016 09:08:27 -0400 Received: from down.free-electrons.com ([37.187.137.238]:59865 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756540AbcJGNIO (ORCPT ); Fri, 7 Oct 2016 09:08:14 -0400 Date: Fri, 7 Oct 2016 11:02:53 +0200 From: Maxime Ripard To: Chen-Yu Tsai Cc: Linus Walleij , "linux-gpio@vger.kernel.org" , devicetree , linux-arm-kernel , linux-kernel Subject: Re: [PATCH 4/9] pinctrl: sunxi: Deal with configless pins Message-ID: <20161007090253.GL4684@lukather> References: <8b72a134d957afdee6de48ec2c1891d8bba1b9e3.1475489558.git-series.maxime.ripard@free-electrons.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="w2xx78T4DcG3O+DJ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --w2xx78T4DcG3O+DJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Oct 04, 2016 at 10:28:18AM +0800, Chen-Yu Tsai wrote: > > if (sunxi_pctrl_has_drive_prop(node)) { > > int drive =3D sunxi_pctrl_parse_drive_prop(node); > > - if (drive < 0) > > + if (drive < 0) { > > + ret =3D -EINVAL; >=20 > Why not just pass the error code returned from the parse function? Yep, I'll change that. > > - (*map)[i].type =3D PIN_MAP_TYPE_CONFIGS_GROUP; > > - (*map)[i].data.configs.group_or_pin =3D group; > > - (*map)[i].data.configs.configs =3D pinconfig; > > - (*map)[i].data.configs.num_configs =3D configlen; > > - > > - i++; > > + if (pinconfig) { > > + (*map)[i].type =3D PIN_MAP_TYPE_CONFIGS_GROUP; > > + (*map)[i].data.configs.group_or_pin =3D group; > > + (*map)[i].data.configs.configs =3D pinconfig; > > + (*map)[i].data.configs.num_configs =3D configle= n; > > + i++; > > + } > > } > > > > - *num_maps =3D nmaps; > > + *num_maps =3D i; >=20 > Thought: should we do a krealloc to shrink the array? Yep, I'll make an additional patch to fix that. >=20 > > > > return 0; > > > > @@ -342,8 +357,13 @@ static void sunxi_pctrl_dt_free_map(struct pinctrl= _dev *pctldev, > > struct pinctrl_map *map, > > unsigned num_maps) > > { > > + unsigned long *pinconfig; > > + > > /* All the maps have the same pin config, free only the first o= ne */ > > - kfree(map[0].data.configs.configs); > > + pinconfig =3D map[0].data.configs.configs; > > + if (pinconfig) > > + kfree(pinconfig); >=20 > Passing NULL to kfree is allowed. (It becomes a no-op.) > So you could leave this function alone. And I'll change that as well. Thanks! Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --w2xx78T4DcG3O+DJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJX92S9AAoJEBx+YmzsjxAgdaoQAId8+y/Xj6v9urtPhjuvPF9L Ax7no0ypLj3ZjZ9zJG3oCBYfOQr/cc36ndtM+upVZgfeDihPC/5ZnTREwkQTvQp/ 4T6pC1ZROuzTRcHaeM/98X7/NQBfiRyfJ2fnsQ1F+RqBgmVVQChixgZa1t7lZg23 dww39cg+DwSItPF+gWgoE95JKc1OLj4fF1Gvlc4dYyZ3iadPbz30+lQ7Rfnbtswg sXCPPo/WCwHKmeVOOX3Xh4equ9RASEnu4cCjCe2DrLC2HpC5OLHC+bqBzcqavmSz k6Z/tw+KiPMl9QGCPWgDP0CUAVH2kxamuud8LucwVDQTVYsevjM2UYJxsc4k29aQ IfWfDPFfZU0QktUrUnt7VkzcDvfwaDz6jCiFqNw7qs4+88Mn/yQZj6D0HKltJoQg IFladk5WyULzhE7Ak5lLRJqIqNBzx+LZkETRyg0RUW/62yJp/D4xtwjnhdCYtHKs KgiYWq7XNhfsQ7x8PbQq2EuCTIos3iCWJ+70SFJik630gTRvURuuYax6pm0SO1hG xb1htpEGukByY23E71H9tlQvfFkop4Of/0/1OwxmHNm1K7+OFymb6D3lgQ4xa5EC kD1PHadqqIYteBapu9OVXfeIpdCU0//MTxQMyv9zU+CHTpkgmTS00M3JO6cnvmgC fooBESwo9DmIKrFNPNz9 =INML -----END PGP SIGNATURE----- --w2xx78T4DcG3O+DJ--