14a899227SCatalin Marinas/* 24a899227SCatalin Marinas * Based on arch/arm/lib/memchr.S 34a899227SCatalin Marinas * 44a899227SCatalin Marinas * Copyright (C) 1995-2000 Russell King 54a899227SCatalin Marinas * Copyright (C) 2013 ARM Ltd. 64a899227SCatalin Marinas * 74a899227SCatalin Marinas * This program is free software; you can redistribute it and/or modify 84a899227SCatalin Marinas * it under the terms of the GNU General Public License version 2 as 94a899227SCatalin Marinas * published by the Free Software Foundation. 104a899227SCatalin Marinas * 114a899227SCatalin Marinas * This program is distributed in the hope that it will be useful, 124a899227SCatalin Marinas * but WITHOUT ANY WARRANTY; without even the implied warranty of 134a899227SCatalin Marinas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144a899227SCatalin Marinas * GNU General Public License for more details. 154a899227SCatalin Marinas * 164a899227SCatalin Marinas * You should have received a copy of the GNU General Public License 174a899227SCatalin Marinas * along with this program. If not, see <http://www.gnu.org/licenses/>. 184a899227SCatalin Marinas */ 194a899227SCatalin Marinas 204a899227SCatalin Marinas#include <linux/linkage.h> 214a899227SCatalin Marinas#include <asm/assembler.h> 224a899227SCatalin Marinas 234a899227SCatalin Marinas/* 244a899227SCatalin Marinas * Find a character in an area of memory. 254a899227SCatalin Marinas * 264a899227SCatalin Marinas * Parameters: 274a899227SCatalin Marinas * x0 - buf 284a899227SCatalin Marinas * x1 - c 294a899227SCatalin Marinas * x2 - n 304a899227SCatalin Marinas * Returns: 314a899227SCatalin Marinas * x0 - address of first occurrence of 'c' or 0 324a899227SCatalin Marinas */ 3319a2ca0fSAndrey RyabininWEAK(memchr) 344a899227SCatalin Marinas and w1, w1, #0xff 354a899227SCatalin Marinas1: subs x2, x2, #1 364a899227SCatalin Marinas b.mi 2f 374a899227SCatalin Marinas ldrb w3, [x0], #1 384a899227SCatalin Marinas cmp w3, w1 394a899227SCatalin Marinas b.ne 1b 404a899227SCatalin Marinas sub x0, x0, #1 414a899227SCatalin Marinas ret 424a899227SCatalin Marinas2: mov x0, #0 434a899227SCatalin Marinas ret 4420791846SArd BiesheuvelENDPIPROC(memchr) 45*ac0e8c72SMark RutlandEXPORT_SYMBOL_NOKASAN(memchr) 46