From nobody Wed Dec 17 13:51:27 2025 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86217144313 for ; Tue, 9 Jul 2024 20:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557483; cv=none; b=DaK83/hzyBent70J7EMPwfwio3j/nqoN9Oz95yoXANRq14dSHDR/ohwfu10PhOBzKnB/P+80S+nWmf4YlDee1T9aOSyoFv14qQgjdFtP7NpFdej8sbBUc9vIQ9XqnsN5QK9nY+QUlKxLGnnvGfKUIKC2Om8Jpu98QV6ZCdEfWRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557483; c=relaxed/simple; bh=i1N+Z/2ISYoU2xkqMv8KVqdJajIRRXpo+2JbHMcYGJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sn1F6jTaJi7Ot9RXC0MPLnXlweCaWRCpj5yXyZyavhRgl2Narz1a+gPyODHy6i5Q6kLBEA4rkbM4e2VOflnpAEhF1GOndvY6s1+SPZVioefp6MkIB8PoxhRVnDitjFL/Hyaq4P0PE6Gr9SDJkDFGytT6QynXi/2/9xVVAxft0LQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=rOiW0UEG; arc=none smtp.client-ip=80.12.242.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="rOiW0UEG" Received: from fedora.. ([77.130.249.53]) by smtp.orange.fr with ESMTPA id RHavsh9C6phyvRHaysZbWF; Tue, 09 Jul 2024 22:37:52 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1720557472; bh=dMg7mTXfpctFZkkNyoWDAtldXD4ACEocdjQPCli4wGs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=rOiW0UEGBfbia/zNC+vi7VqxdJ0RlXu5LhpKjSDa2lYBWLrqlvYasIQeieiUlw5EE vAEB/swjiNqLWgppLzT6a861T5FfbgeX7Jb/ho/sqk2o5Z+NIQ5Z3p9zgBfvdIuuta oKDaKHN10p1eVHboI8+Q4fUGwAj+DSoFS3u+WOi3f+XJF3aHH8+9U8Wz6pO67lHz1H 4MDRkBmZh3pDSeLF0AA+PAEN7ZUIlGbArEOU7tffqcCjVI1c7TgkRBCaSd+Qe6ac99 wqiTShfm8wjxqoyzs7nvH2UoEw6EvDpsG6mrGsGbrx7roJ4cOPifntRsSfd7gI8toA m0ej8Y30Ojv5g== X-ME-Helo: fedora.. X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 09 Jul 2024 22:37:52 +0200 X-ME-IP: 77.130.249.53 From: Christophe JAILLET To: linus.walleij@linaro.org, lokeshvutla@ti.com, nm@ti.com, robh@kernel.org, tony@atomide.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/3] pinctrl: ti: ti-iodelay: Fix some error handling paths Date: Tue, 9 Jul 2024 22:37:43 +0200 Message-ID: <0220fa5b925bd08e361be8206a5438f6229deaac.1720556038.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the probe, if an error occurs after the ti_iodelay_pinconf_init_dev() call, it is likely that ti_iodelay_pinconf_deinit_dev() should be called, as already done in the remove function. Also in ti_iodelay_pinconf_init_dev(), if an error occurs after the first regmap_update_bits() call, it is also likely that the deinit() function should be called. The easier way to fix it is to add a devm_add_action_or_reset() at the rigtht place to have ti_iodelay_pinconf_deinit_dev() called when needed. Doing so, the .remove() function can be removed, and the associated platform_set_drvdata() call in the probe as well. Fixes: 003910ebc83b ("pinctrl: Introduce TI IOdelay configuration driver") Signed-off-by: Christophe JAILLET --- Compile tested-only. This patch is speculative, review with care! --- drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 52 ++++++++++--------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/p= inctrl-ti-iodelay.c index f5e5a23d2226..451801acdc40 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -273,6 +273,22 @@ static int ti_iodelay_pinconf_set(struct ti_iodelay_de= vice *iod, return r; } =20 +/** + * ti_iodelay_pinconf_deinit_dev() - deinit the iodelay device + * @data: IODelay device + * + * Deinitialize the IODelay device (basically just lock the region back up. + */ +static void ti_iodelay_pinconf_deinit_dev(void *data) +{ + struct ti_iodelay_device *iod =3D data; + const struct ti_iodelay_reg_data *reg =3D iod->reg_data; + + /* lock the iodelay region back again */ + regmap_update_bits(iod->regmap, reg->reg_global_lock_offset, + reg->global_lock_mask, reg->global_lock_val); +} + /** * ti_iodelay_pinconf_init_dev() - Initialize IODelay device * @iod: iodelay device @@ -295,6 +311,11 @@ static int ti_iodelay_pinconf_init_dev(struct ti_iodel= ay_device *iod) if (r) return r; =20 + r =3D devm_add_action_or_reset(iod->dev, ti_iodelay_pinconf_deinit_dev, + iod); + if (r) + return r; + /* Read up Recalibration sequence done by bootloader */ r =3D regmap_read(iod->regmap, reg->reg_refclk_offset, &val); if (r) @@ -353,21 +374,6 @@ static int ti_iodelay_pinconf_init_dev(struct ti_iodel= ay_device *iod) return 0; } =20 -/** - * ti_iodelay_pinconf_deinit_dev() - deinit the iodelay device - * @iod: IODelay device - * - * Deinitialize the IODelay device (basically just lock the region back up. - */ -static void ti_iodelay_pinconf_deinit_dev(struct ti_iodelay_device *iod) -{ - const struct ti_iodelay_reg_data *reg =3D iod->reg_data; - - /* lock the iodelay region back again */ - regmap_update_bits(iod->regmap, reg->reg_global_lock_offset, - reg->global_lock_mask, reg->global_lock_val); -} - /** * ti_iodelay_get_pingroup() - Find the group mapped by a group selector * @iod: iodelay device @@ -877,27 +883,11 @@ static int ti_iodelay_probe(struct platform_device *p= dev) return ret; } =20 - platform_set_drvdata(pdev, iod); - return pinctrl_enable(iod->pctl); } =20 -/** - * ti_iodelay_remove() - standard remove - * @pdev: platform device - */ -static void ti_iodelay_remove(struct platform_device *pdev) -{ - struct ti_iodelay_device *iod =3D platform_get_drvdata(pdev); - - ti_iodelay_pinconf_deinit_dev(iod); - - /* Expect other allocations to be freed by devm */ -} - static struct platform_driver ti_iodelay_driver =3D { .probe =3D ti_iodelay_probe, - .remove_new =3D ti_iodelay_remove, .driver =3D { .name =3D DRIVER_NAME, .of_match_table =3D ti_iodelay_of_match, --=20 2.45.2 From nobody Wed Dec 17 13:51:27 2025 Received: from smtp.smtpout.orange.fr (smtp-15.smtpout.orange.fr [80.12.242.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B713A152515 for ; Tue, 9 Jul 2024 20:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557483; cv=none; b=FE3w4ZaJdvz3PHTBql2Vy+ybUF/CPDCs4kkWZkyKU97mw0IiFNuVLmqWScc5PvbG8XnEnofyNtPtCKW/uU82Iq7cNwLyZ/mctbBtZk00ZeKh+/U5XtddWSJLmG8iDyCGZ0DhYJ130whlu/drl4tKWhko9Zo/HnMB7db+I2UlHQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557483; c=relaxed/simple; bh=llFZ5aPJDx2WrJXH1NObb7neLFOzkO7dYUOOKAZtZ0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7PwU1PHFhuZnG6Ea0TyEsgPRVt24fAbibVOOi2Qrf8BL0Or8InNkn9BzwMAwsrEI9exo3qwlLzGEIFsXIaRp7LYda7bqexkdpRaO9XyX2jf0ZC3K5BUyTkLRQQviImLB24Qo1VzmTV+LpA9O9iuR/GOKFWRCIaYtOGqm7fDAlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=AbY2fAmZ; arc=none smtp.client-ip=80.12.242.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="AbY2fAmZ" Received: from fedora.. ([77.130.249.53]) by smtp.orange.fr with ESMTPA id RHavsh9C6phyvRHazsZbXS; Tue, 09 Jul 2024 22:37:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1720557473; bh=+me7JYfSesC2CWqSWLCbwjuqC3c9WAmwPVCVuqT+erw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AbY2fAmZ6eUgGUwipFLztgOcs6AFrYXSfOah4P30/5H6N4YZU83PTd3gmNVMuXs9x KEzYhrhxb8m2TfNUZeAuhD+LzM5t0bmOj9ZRJlE4KTz7UK8HxHZOsHSAQUMEdpwVDA Xame6nsUg851+J87XF9amVcXLb+/CCasTdxZKvyJZrBWF+eHP+SnOf5HZYLjxlLF+G SOjkkv5aXHlOBu32vanOoGo7ydg/qr3qXHjWbnrN+oVrhzm4flUmNJhSqymX3uYCSY T4J3Ny5tiPs8nA1dlZnFlG+TJH3gG2sL/BV7sj7j6MEpp/OzhskrjDO7DcTaNFcIh4 2Como0q/yAY0g== X-ME-Helo: fedora.. X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 09 Jul 2024 22:37:53 +0200 X-ME-IP: 77.130.249.53 From: Christophe JAILLET To: linus.walleij@linaro.org, lokeshvutla@ti.com, nm@ti.com, robh@kernel.org, tony@atomide.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/3] pinctrl: ti: ti-iodelay: Constify struct ti_iodelay_reg_data Date: Tue, 9 Jul 2024 22:37:44 +0200 Message-ID: <40d6e67ab4e73d2cbe7ca0060ac27afc894fc415.1720556038.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'struct ti_iodelay_reg_data' is not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security. On a x86_64, with allmodconfig: Before: =3D=3D=3D=3D=3D=3D text data bss dec hex filename 17259 1788 16 19063 4a77 drivers/pinctrl/ti/pinctrl-ti-iodel= ay.o After: =3D=3D=3D=3D=3D text data bss dec hex filename 17355 1692 16 19063 4a77 drivers/pinctrl/ti/pinctrl-ti-iodel= ay.o Signed-off-by: Christophe JAILLET --- Compile tested-only. --- drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/p= inctrl-ti-iodelay.c index 451801acdc40..65f9439d0d5b 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -783,7 +783,7 @@ static struct regmap_config dra7_iodelay_regmap_config = =3D { .max_register =3D 0xd1c, }; =20 -static struct ti_iodelay_reg_data dra7_iodelay_data =3D { +static const struct ti_iodelay_reg_data dra7_iodelay_data =3D { .signature_mask =3D 0x0003f000, .signature_value =3D 0x29, .lock_mask =3D 0x00000400, --=20 2.45.2 From nobody Wed Dec 17 13:51:27 2025 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96AF4182A63 for ; Tue, 9 Jul 2024 20:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557485; cv=none; b=utZGILV8Sz7U0Z1RYlpKEBUP+l5JM9VzZk4m5XfFdez1zhWU4foDMwDFr9om2S+fpkG2y3iRBnGgWi0jHtlTvEHaz9XP5SRu3ck4ieWgNC6G8UpqgQSkNhmtG8RaJ5PEt876UMmqqDCTGme4DRkurE3HrDg3aUyejkhofEo9Frc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557485; c=relaxed/simple; bh=gmf3aasC6nYbLpzKP+9gJGJLL0Mreue7d/koV0x/jsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n7v/1NZ4K0kkwkztPhaGsw8wQ3HJ6w80k8x0BJjplPwfc3YY/EFNRhIA9bqwXTpVUGfQ6Ym2JKk0/q/hlguj5SpEuKZwxAvYljjZ8zk+KLZMvEfyAxIy33MrLYyCFZjVxyTbgkafq0V2FNZSbLGpkOZZhnAsQSsAfREmIS7fYqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=JjMfMUtM; arc=none smtp.client-ip=80.12.242.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="JjMfMUtM" Received: from fedora.. ([77.130.249.53]) by smtp.orange.fr with ESMTPA id RHavsh9C6phyvRHb0sZbYg; Tue, 09 Jul 2024 22:37:55 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1720557475; bh=EgfXHxdLYyi1/TpBSR1xI3tIrUBzJ3KcvfA6MU/OQKo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=JjMfMUtMkRVCbGRXLRdYqkVuZXSnMREEJGWg++G2nMYcQf4OBmfp6sGGu/AK7mZSW 6uUIax8VnEYELmwmXxYFe8WTe3wcR0zQEjWEE69gW9NuW20DQIfnG87ixKkzIU8Rp6 QH/c7IWtZq9VktUVo09HCoXGUTijwehgn/3ivm0nAtBdOBbXpf+I7mstmnXZCrlUB5 Z0IBpeCNGgiCJn04p18Ilh9FT9es6ZX9iz8FGix+KMRRrTzFFqlrtHvau1UJC5hYB7 iMJSzjbdOTQyX9vIf/yizuvmNJRDjPTnrJqjxdXi6fbSisG8iEAa9z4+3ViOZaEFi+ Yd2X7WCdqz85w== X-ME-Helo: fedora.. X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 09 Jul 2024 22:37:55 +0200 X-ME-IP: 77.130.249.53 From: Christophe JAILLET To: linus.walleij@linaro.org, lokeshvutla@ti.com, nm@ti.com, robh@kernel.org, tony@atomide.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 3/3] pinctrl: ti: ti-iodelay: Constify struct regmap_config Date: Tue, 9 Jul 2024 22:37:45 +0200 Message-ID: <4eefa8530a55ecde82b3ec9a445f93c01bda7ded.1720556038.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'struct regmap_config' is not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security. On a x86_64, with allmodconfig: Before: =3D=3D=3D=3D=3D=3D text data bss dec hex filename 17355 1692 16 19063 4a77 drivers/pinctrl/ti/pinctrl-ti-iodel= ay.o After: =3D=3D=3D=3D=3D text data bss dec hex filename 17729 1372 16 19117 4aad drivers/pinctrl/ti/pinctrl-ti-iodel= ay.o Signed-off-by: Christophe JAILLET --- Compile tested-only. --- drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/p= inctrl-ti-iodelay.c index 65f9439d0d5b..019b302db2b0 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -82,7 +82,7 @@ struct ti_iodelay_reg_data { u32 reg_start_offset; u32 reg_nr_per_pin; =20 - struct regmap_config *regmap_config; + const struct regmap_config *regmap_config; }; =20 /** @@ -776,7 +776,7 @@ static int ti_iodelay_alloc_pins(struct device *dev, return 0; } =20 -static struct regmap_config dra7_iodelay_regmap_config =3D { +static const struct regmap_config dra7_iodelay_regmap_config =3D { .reg_bits =3D 32, .reg_stride =3D 4, .val_bits =3D 32, --=20 2.45.2