1*4882a593Smuzhiyun/* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun/* 3*4882a593Smuzhiyun * Based on arch/arm/lib/strrchr.S 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 1995-2000 Russell King 6*4882a593Smuzhiyun * Copyright (C) 2013 ARM Ltd. 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun#include <linux/linkage.h> 10*4882a593Smuzhiyun#include <asm/assembler.h> 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun/* 13*4882a593Smuzhiyun * Find the last occurrence of a character in a string. 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * Parameters: 16*4882a593Smuzhiyun * x0 - str 17*4882a593Smuzhiyun * x1 - c 18*4882a593Smuzhiyun * Returns: 19*4882a593Smuzhiyun * x0 - address of last occurrence of 'c' or 0 20*4882a593Smuzhiyun */ 21*4882a593SmuzhiyunSYM_FUNC_START_WEAK_PI(strrchr) 22*4882a593Smuzhiyun mov x3, #0 23*4882a593Smuzhiyun and w1, w1, #0xff 24*4882a593Smuzhiyun1: ldrb w2, [x0], #1 25*4882a593Smuzhiyun cbz w2, 2f 26*4882a593Smuzhiyun cmp w2, w1 27*4882a593Smuzhiyun b.ne 1b 28*4882a593Smuzhiyun sub x3, x0, #1 29*4882a593Smuzhiyun b 1b 30*4882a593Smuzhiyun2: mov x0, x3 31*4882a593Smuzhiyun ret 32*4882a593SmuzhiyunSYM_FUNC_END_PI(strrchr) 33*4882a593SmuzhiyunEXPORT_SYMBOL_NOKASAN(strrchr) 34