mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rikard Falkeborn <rikard.falkeborn@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Rikard Falkeborn <rikard.falkeborn@gmail.com>,
	Evgeniy Polyakov <zbr@ioremap.net>,
	Angelo Dureghello <angelo.dureghello@timesys.com>,
	Akira Shimahara <akira215corp@gmail.com>,
	Sebastian Reichel <sre@kernel.org>
Subject: [PATCH 1/3] w1: Constify struct w1_family_ops
Date: Sun,  4 Oct 2020 21:32:00 +0200	[thread overview]
Message-ID: <20201004193202.4044-2-rikard.falkeborn@gmail.com> (raw)
In-Reply-To: <20201004193202.4044-1-rikard.falkeborn@gmail.com>

The fops field in the w1_family struct is never modified. Make it const
to indicate that. Constifying the pointer makes it possible for drivers
to declare static w1_family_ops structs const, which in turn will allow
the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/w1/w1.c    | 2 +-
 include/linux/w1.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index e58c7592008d..6bd64bcb6316 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -613,7 +613,7 @@ static int w1_uevent(struct device *dev, struct kobj_uevent_env *env)
 
 static int w1_family_notify(unsigned long action, struct w1_slave *sl)
 {
-	struct w1_family_ops *fops;
+	const struct w1_family_ops *fops;
 	int err;
 
 	fops = sl->family->fops;
diff --git a/include/linux/w1.h b/include/linux/w1.h
index cebf3464bc03..949d3b10e531 100644
--- a/include/linux/w1.h
+++ b/include/linux/w1.h
@@ -269,7 +269,7 @@ struct w1_family {
 	struct list_head	family_entry;
 	u8			fid;
 
-	struct w1_family_ops	*fops;
+	const struct w1_family_ops *fops;
 
 	const struct of_device_id *of_match_table;
 
-- 
2.28.0


  reply	other threads:[~2020-10-04 19:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-04 19:31 [PATCH 0/3] w1: Constify w1_family_ops Rikard Falkeborn
2020-10-04 19:32 ` Rikard Falkeborn [this message]
2020-10-04 21:55   ` [PATCH 1/3] w1: Constify struct w1_family_ops Sebastian Reichel
2020-10-04 19:32 ` [PATCH 2/3] w1: Constify static w1_family_ops structs Rikard Falkeborn
2020-10-04 19:32 ` [PATCH 3/3] power: supply: " Rikard Falkeborn
2020-10-04 22:03   ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201004193202.4044-2-rikard.falkeborn@gmail.com \
    --to=rikard.falkeborn@gmail.com \
    --cc=akira215corp@gmail.com \
    --cc=angelo.dureghello@timesys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=zbr@ioremap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®