From nobody Sat Nov 30 16:48:54 2024 Received: from msa.smtpout.orange.fr (smtp-81.smtpout.orange.fr [80.12.242.81]) (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 36865156F46 for ; Sun, 8 Sep 2024 11:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725795670; cv=none; b=qOdH2k5i3j3/HjjXiBOjVbYDJX7fgh79pMHDO4MRDFJ28OLazTZgvR97rnuSw4jDLIgT6s1jVX+cLyz1fl70XE26L1zPL7ACldMmNjhVL3X27ViCfqhbct8PraVfifEKAHSv8YYpnZih+VXOoAVt4QUsPfI0OGtoU671vzL4Qks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725795670; c=relaxed/simple; bh=1Qhx0AQRK9ttQdmzZmSAGaRrUT0Salp94PcJRhj61wM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BaqyrhlNEhXxJEfpZBeqIsvzA1vkdHH1rcSlrO11eKgnMiGSIrAXfUqT+YMsnHB8UU10BEAn+EjvXbifwH7QazxQoG3GF4nYk6bccInA8A+dJaEQGq7NnHWJxky5JaOHWBskEEQh0naasiYZCj9TVKFI3T4mgzuAUbtLDnSjNBY= 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=AqGNOmWK; arc=none smtp.client-ip=80.12.242.81 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="AqGNOmWK" Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id nGHgsexU2GrBenGHrswgtK; Sun, 08 Sep 2024 13:40:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1725795659; bh=rkF1WqCp0VrtzogJvR0Aay0dOwijVk8Eg1QDROv0aUE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AqGNOmWKnq45uCle5syYWekhyf5/Be1v40Tr67NyUwzh4pZ33RmrpsW4Im67j9fI0 qg2UWYq2MRXMFTgPNLgSIHorXLkVia3kiIXTmhHAZ+tLEsIUxhFZSmHFcs+FTFUKta e2UWEOIWvt9yrED5SFGSJpkAOqRGFmQRcXWtByl5CC570yIsbIzSsQO4GChZpTqKwX Q97D3FLBrzlPRV9oRJjWyTf22C7HjA4bewV32+jNfqS9z1QUPg566NqdoyXZ7YogGk uzHGrcpSmq/+s68PC8h1hI6dwqLd5h8yTDo2J1iaDUc7I/g2a7KEqF7CwpmFlM6R9M ilPgjiNjMhOsQ== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 08 Sep 2024 13:40:59 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: lgirdwood@gmail.com, iskren.chernev@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/2] regulator: max77826: Constify struct regulator_desc Date: Sun, 8 Sep 2024 13:40:44 +0200 Message-ID: <1aaff0efb601832cd11949653d5872e7e39fbd7f.1725791361.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.46.0 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 regulator_desc' is not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security, especially when the structure holds some function pointers. On a x86_64, with allmodconfig: Before: =3D=3D=3D=3D=3D=3D text data bss dec hex filename 3906 5808 16 9730 2602 drivers/regulator/max77826-regulato= r.o After: =3D=3D=3D=3D=3D text data bss dec hex filename 9218 496 16 9730 2602 drivers/regulator/max77826-regulato= r.o Signed-off-by: Christophe JAILLET -- Compile tested only Reviewed-by: Iskren Chernev --- drivers/regulator/max77826-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/max77826-regulator.c b/drivers/regulator/max= 77826-regulator.c index 5590cdf615b7..376e3110c695 100644 --- a/drivers/regulator/max77826-regulator.c +++ b/drivers/regulator/max77826-regulator.c @@ -153,7 +153,7 @@ enum max77826_regulators { =20 struct max77826_regulator_info { struct regmap *regmap; - struct regulator_desc *rdesc; + const struct regulator_desc *rdesc; }; =20 static const struct regmap_config max77826_regmap_config =3D { @@ -187,7 +187,7 @@ static const struct regulator_ops max77826_buck_ops =3D= { .set_voltage_time_sel =3D max77826_set_voltage_time_sel, }; =20 -static struct regulator_desc max77826_regulators_desc[] =3D { +static const struct regulator_desc max77826_regulators_desc[] =3D { MAX77826_LDO(1, NMOS), MAX77826_LDO(2, NMOS), MAX77826_LDO(3, NMOS), --=20 2.46.0 From nobody Sat Nov 30 16:48:54 2024 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) (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 3D39938F9C for ; Sun, 8 Sep 2024 11:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725795668; cv=none; b=d2D2MYSCFgt3mz+rCEepg36+Hn+B7iPTFd7KWt3tzO+dpnz4qIfkT1SgUBjsGu0THvbHOHkZAL1b3NvKEY4CyW28vt8mcvuINJFBia/AO0nhsmnYgUtcloapDQwQKAwwaiuq2YxyOJyULyQLdN2wWdNqkFQkubGWNK0+kc9HN6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725795668; c=relaxed/simple; bh=ltZOXOEbg7XQE/584SV9e7dnc4lbUDxScr6IpzLIAQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6yOCHLOjwkVnpyvnYRsij5+gzwh4//61IN20h5j1UozveeWvSxq9Q9NBhVf9Bkn44Xahp8xU/I1qc+e+Ibdp/HGnb1AN7tJRhKIiqOSdk9JEAGur/C0Y23kD0lLqY1QiY5pOOlEyefo/0oyrzEIngTTI8gRJGnInCQQykbCYpk= 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=VA6oGiuR; arc=none smtp.client-ip=80.12.242.27 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="VA6oGiuR" Received: from fedora.home ([90.11.132.44]) by smtp.orange.fr with ESMTPA id nGHgsexU2GrBenGHxswgxl; Sun, 08 Sep 2024 13:41:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1725795666; bh=5e0Qm15ALIQxn7vbSh4VAly854bRiZwGfw2gToWMa2U=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=VA6oGiuROfQ+8eZe7YNRCPyi3xSK0Z5UyvoIYIrInT2NY5rKSQbBI7OA91eDKMEgD HVDB4dxFBqOiVQ6drvPnY75PaeTNKvs+Sst8eFpGjpb7ak5r692PwhJXIjr4Gz0X8k ePHR+soRJsRaYIk9roBC1UQ4eHM4xTZZfHS294ZXA6W0xpCXEsXxfttPu/mioIoBRr /uBzfoYX8FPBn9rVF0W51oNoop0OhkuDA9O/XXRpj8RayFyzIGWd/QtD4FlNguppts dY8ZlsjbtsDovUJmTv2PuMPyWingZ03g7fZ76PVkt13CdvuV0ICTE5kCbYGYAy7an6 rYvTffOUAsSww== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 08 Sep 2024 13:41:06 +0200 X-ME-IP: 90.11.132.44 From: Christophe JAILLET To: lgirdwood@gmail.com, iskren.chernev@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/2] regulator: max77826: Simplify max77826_i2c_probe() Date: Sun, 8 Sep 2024 13:40:45 +0200 Message-ID: <583fa0bebbe18f8cb6e215a895f57b2eb944218e.1725791361.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.46.0 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 max77826_regulator_info' is unused and can be removed. There is no i2c_get_clientdata(). Resources are managed, so there is no need to keep references unless explicitly needed. Signed-off-by: Christophe JAILLET -- Compile tested only. This patch IS SPECULATIVE, review with care! Reviewed-by: Iskren Chernev --- drivers/regulator/max77826-regulator.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/regulator/max77826-regulator.c b/drivers/regulator/max= 77826-regulator.c index 376e3110c695..3b12ad361222 100644 --- a/drivers/regulator/max77826-regulator.c +++ b/drivers/regulator/max77826-regulator.c @@ -149,13 +149,6 @@ enum max77826_regulators { .owner =3D THIS_MODULE, \ } =20 - - -struct max77826_regulator_info { - struct regmap *regmap; - const struct regulator_desc *rdesc; -}; - static const struct regmap_config max77826_regmap_config =3D { .reg_bits =3D 8, .val_bits =3D 8, @@ -235,30 +228,19 @@ static int max77826_read_device_id(struct regmap *reg= map, struct device *dev) static int max77826_i2c_probe(struct i2c_client *client) { struct device *dev =3D &client->dev; - struct max77826_regulator_info *info; struct regulator_config config =3D {}; struct regulator_dev *rdev; struct regmap *regmap; int i; =20 - info =3D devm_kzalloc(dev, sizeof(struct max77826_regulator_info), - GFP_KERNEL); - if (!info) - return -ENOMEM; - - info->rdesc =3D max77826_regulators_desc; regmap =3D devm_regmap_init_i2c(client, &max77826_regmap_config); if (IS_ERR(regmap)) { dev_err(dev, "Failed to allocate regmap!\n"); return PTR_ERR(regmap); } =20 - info->regmap =3D regmap; - i2c_set_clientdata(client, info); - config.dev =3D dev; config.regmap =3D regmap; - config.driver_data =3D info; =20 for (i =3D 0; i < MAX77826_MAX_REGULATORS; i++) { rdev =3D devm_regulator_register(dev, --=20 2.46.0