Skip to content

Commit 02ee149

Browse files
Claudio ImbrendaAlexander Gordeev
authored andcommitted
s390/pgtable: Make crdte() and cspg() return a value
Make the crdte() and cspg() wrappers return a boolean to indicate success, like the other already existing "compare and swap" type of wrappers. Add documentation for those functions as well. Acked-by: Alexander Gordeev <[email protected]> Signed-off-by: Claudio Imbrenda <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent d6d1aa5 commit 02ee149

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

arch/s390/include/asm/pgtable.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,15 @@ static inline void csp(unsigned int *ptr, unsigned int old, unsigned int new)
609609
: "cc");
610610
}
611611

612-
static inline void cspg(unsigned long *ptr, unsigned long old, unsigned long new)
612+
/**
613+
* cspg() - Compare and Swap and Purge (CSPG)
614+
* @ptr: Pointer to the value to be exchanged
615+
* @old: The expected old value
616+
* @new: The new value
617+
*
618+
* Return: True if compare and swap was successful, otherwise false.
619+
*/
620+
static inline bool cspg(unsigned long *ptr, unsigned long old, unsigned long new)
613621
{
614622
union register_pair r1 = { .even = old, .odd = new, };
615623
unsigned long address = (unsigned long)ptr | 1;
@@ -619,6 +627,7 @@ static inline void cspg(unsigned long *ptr, unsigned long old, unsigned long new
619627
: [r1] "+&d" (r1.pair), "+m" (*ptr)
620628
: [address] "d" (address)
621629
: "cc");
630+
return old == r1.even;
622631
}
623632

624633
#define CRDTE_DTT_PAGE 0x00UL
@@ -627,7 +636,18 @@ static inline void cspg(unsigned long *ptr, unsigned long old, unsigned long new
627636
#define CRDTE_DTT_REGION2 0x18UL
628637
#define CRDTE_DTT_REGION1 0x1cUL
629638

630-
static inline void crdte(unsigned long old, unsigned long new,
639+
/**
640+
* crdte() - Compare and Replace DAT Table Entry
641+
* @old: The expected old value
642+
* @new: The new value
643+
* @table: Pointer to the value to be exchanged
644+
* @dtt: Table type of the table to be exchanged
645+
* @address: The address mapped by the entry to be replaced
646+
* @asce: The ASCE of this entry
647+
*
648+
* Return: True if compare and replace was successful, otherwise false.
649+
*/
650+
static inline bool crdte(unsigned long old, unsigned long new,
631651
unsigned long *table, unsigned long dtt,
632652
unsigned long address, unsigned long asce)
633653
{
@@ -638,6 +658,7 @@ static inline void crdte(unsigned long old, unsigned long new,
638658
: [r1] "+&d" (r1.pair)
639659
: [r2] "d" (r2.pair), [asce] "a" (asce)
640660
: "memory", "cc");
661+
return old == r1.even;
641662
}
642663

643664
/*

0 commit comments

Comments
 (0)