Skip to contentSkip to conversation

mm/hmm: constify hmm_devmem_page_get_drvdata() parameter

PATCH Applied Jérôme Glisse 3 participants 4 messages Oct 2, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/hmm: constify hmm_devmem_page_get_drvdata() parameter

From: Ralph Campbell <[email protected]>

Constify pointer parameter to avoid issue when use from code that only has const struct page pointer to use in the first place.

---
 include/linux/hmm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/hmm.h +2 -2
index 96e6997..325017a 100644
@@ -471,9 +471,9 @@ static inline void hmm_devmem_page_set_drvdata(struct page *page,
  * @page: pointer to struct page
  * Return: driver data value
  */
-static inline unsigned long hmm_devmem_page_get_drvdata(struct page *page)
+static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page)
 {
-	unsigned long *drvdata = (unsigned long *)&page->pgmap;
+	const unsigned long *drvdata = (const unsigned long *)&page->pgmap;
 
 	return drvdata[1];
 }
Signature · 7 lines
2.4.11

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw
Quoted 4 lines · On Mon, 2 Oct 2017 15:32:54 -0400 Jérôme Glisse <[email protected]> wrote:

From: Ralph Campbell <[email protected]>

Constify pointer parameter to avoid issue when use from code that only has const struct page pointer to use in the first place.

That's rather vague. Does such calling code exist in the kernel? This affects the which-kernel-gets-patched decision.

#2 lore raw
Quoted 9 lines · Andrew Morton
Quoted 4 lines · On Mon, 2 Oct 2017 15:32:54 -0400 Jerome Glisse <[email protected]> wrote:

From: Ralph Campbell <[email protected]>

Constify pointer parameter to avoid issue when use from code that only has const struct page pointer to use in the first place.

That's rather vague. Does such calling code exist in the kernel? This affects the which-kernel-gets-patched decision.

This is use by device driver, no driver upstream yet so it does not affect anybody upstream yet.

Jerome

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Andrew Morton

The use case is when called by struct hmm_devmem_ops.fault() which passes a const struct page * pointer and hmm_devmem_page_get_drvdata() is called to get the private data. Since HMM was only recently added, it only affects kernels after September 8, 2017.

Quoted 12 lines

-----Original Message-----
From: Andrew Morton [mailto:[email protected]]
Sent: Monday, October 2, 2017 2:41 PM
To: Jérôme Glisse <[email protected]>
Cc: [email protected]; [email protected]; Ralph Campbell <[email protected]>
Subject: Re: [PATCH] mm/hmm: constify hmm_devmem_page_get_drvdata() parameter

On Mon, 2 Oct 2017 15:32:54 -0400 Jérôme Glisse <[email protected]> wrote:

Quoted 7 lines
Quoted 4 lines

From: Ralph Campbell <[email protected]>

Constify pointer parameter to avoid issue when use from code that only has const struct page pointer to use in the first place.

That's rather vague. Does such calling code exist in the kernel? This affects the which-kernel-gets-patched decision.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>