Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp140905lqg; Fri, 26 Apr 2024 10:56:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDC3Rzvl/Jrkr0mgEmI+GMyyRfTNSb3vfLSeFWRNbjr30ntxsj1mNkQgGzjjHBIRxVSey0jFtUU1LEQyBN/aXh45OuGBnCek7sR9G1OQ== X-Google-Smtp-Source: AGHT+IFNMV431VQWEcKw2XzkdqKrWq92afPOaWKzVsWrL10Bz9/gakfq8f+gYtaxtuZPBIpbBJ29 X-Received: by 2002:a05:6a20:da93:b0:1a3:dc33:2e47 with SMTP id iy19-20020a056a20da9300b001a3dc332e47mr4474582pzb.4.1714154177512; Fri, 26 Apr 2024 10:56:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714154177; cv=pass; d=google.com; s=arc-20160816; b=FtSdHgd/herkdXWSM7rH9T1rXb5vyi7fK4AQyiQiuNhgDY0dtkFWXbq2l4AdRlVf0N 0601BYAuBCLzca+Jl8z+38ESG/0Lj5z/t5zB82GaBgE2i02T4Ro3XfH0ufvIN+CJlKir ziVBvrBqE+Y0fT9JT9hWaKxihK/dWAVyq2Ry/uJrS0GJQEL7AxTsH8jyoe7lhCN7Fcyq T2j9u8/km7ppScgSjbLLq+0Q73OPJHrboQeMfNk0Hc1KZfouM2M0MapAUhjsLfLGJU5v KSOHVs88qxwj9eOf4UiER6WJg76+yAeg23Lybz5ZWS5pf0N/7VMDcyvJiUVJYQWeDKtX Dylw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=8Mye90PZLFSMMR1XMX0dWDyuqCbfXVLPAYYOAPvRdE0=; fh=YwIIDFvbQ6F6hQ2/Pjtc4Jp18LXkeun4AwpA2AI++I8=; b=L2T7MEQsHfgxbF4gFbZ+R11PW/aWfxMw+xjnkQbvrFBMsU5lnWc9i/UXGsGMqWTDFU aqZkECQBfzZQQLdHBnwjqqCwP82d+zOeuhiNgkF2PJn0J0UhZjvgK4vzGQPUNPSWDq+L umK96pHLBtr92ZhPjCJdqCS7XTBOgmdTKEAX8Wih9e+bxQNu9cYSWm3bXPcxxCvighVS uSQxxnZ4JpfyOrWs/ZQyhRA711lj4ffBTJ5l+0xIPxlTVChgIjIFBzoXatrhHBrmu6+B XY0OGm9CBjmDQjZlDF4cpJwzv99H2FTzbyBboCTfcJc1rUVGGQfrcNmBZEwJ/HdmmjXv /jAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RNTRe161; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-160281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c10-20020aa7880a000000b006ed4a9726besi15304741pfo.295.2024.04.26.10.56.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 10:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RNTRe161; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-160281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8FB09B25B16 for ; Fri, 26 Apr 2024 15:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A549614AD1A; Fri, 26 Apr 2024 15:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RNTRe161" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97BEE143886; Fri, 26 Apr 2024 15:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714145133; cv=none; b=cOwB0ZvrxdYBodz5z82Vr7nyw4BAgBPfPxTadkRa3VbmnXCFfkX5UuiUa4BQ3Rx1X1ww8gCFIsdYoMqjKLADh9bMNCjpkG8V0tQQhDGlaBDT6DEePUBKCzVTOhkP8Xzdad/gid1Dho4F/caqidGJvGhMoV36VuK5opFgqbYzIOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714145133; c=relaxed/simple; bh=IL2++mNo2aq1MBXdWEeDx4hUUCVamp5GSDIQcKWJuhY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Kxgcp9KRy6ohxOASAHAKkeUdDhZf5JgU6QroeMhQNGrP3ORiGsE35jLHPAmQ3sfR7aP7tl/RrRcNalMbweOl4b1TJxnfVXaCJcLo3lo7a+NawimMxX5ivRD5qdnhZV1/MrNrGFJnOhH0SThYevzjrk1UIeToWO6kS09x6COMmzk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RNTRe161; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714145133; x=1745681133; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=IL2++mNo2aq1MBXdWEeDx4hUUCVamp5GSDIQcKWJuhY=; b=RNTRe161LOr/5ptq90ev0Wa1eq2n2x14GA3vepkNRaWcP27xvUSFuMkZ WLEU6bBvjUvlB5ME77nE1x1EPotLyayErOmIr+o2u/FSA/4S5NpgDN0MM eB0drR6R3+smdeZvpwgLYHXn9+puuXxaO05i+0C9FyMUJpkfx7ZhcNOpJ xPBXjLgYIH78RDxMDhVFe+RfePBvm/pDsFgHffuSMODtmKQNGTaf0Z5Qh 4V3BL/kZqT6JL6UdDUkv+jC+7ETrYwuszMkCxWjoxUGepzUZYm/Z82a4C buOBNSv2xptf4SmJA+g6MTe2RJZNzM7Ua8Yicne3Gdi9QWULKBDg6Bq0l A==; X-CSE-ConnectionGUID: qCPKZeNpQmSPVepkfKHkLQ== X-CSE-MsgGUID: BD/9o2ZLSsa0dQsfB0hIOA== X-IronPort-AV: E=McAfee;i="6600,9927,11056"; a="10005888" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="10005888" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 08:25:32 -0700 X-CSE-ConnectionGUID: 1bBkQqt7QkSddjdFx/K+hg== X-CSE-MsgGUID: AtZdl5jVTUSEYoTRDvhmlw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="30084013" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 26 Apr 2024 08:25:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1DFF01CB; Fri, 26 Apr 2024 18:25:28 +0300 (EEST) From: Andy Shevchenko To: Samuel Holland , Andy Shevchenko , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones , Chen-Yu Tsai , Jernej Skrabec Subject: [PATCH v1 1/1] leds: sun50i-a100: Use match_string() helper to simplify the code Date: Fri, 26 Apr 2024 18:25:15 +0300 Message-ID: <20240426152515.872917-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit match_string() returns the array index of a matching string. Use it instead of the open-coded implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-sun50i-a100.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-sun50i-a100.c b/drivers/leds/leds-sun50i-a100.c index 62d21c3a3575..119eff9471f0 100644 --- a/drivers/leds/leds-sun50i-a100.c +++ b/drivers/leds/leds-sun50i-a100.c @@ -252,18 +252,16 @@ static int sun50i_a100_ledc_parse_format(struct device *dev, struct sun50i_a100_ledc *priv) { const char *format = "grb"; - u32 i; + int i; device_property_read_string(dev, "allwinner,pixel-format", &format); - for (i = 0; i < ARRAY_SIZE(sun50i_a100_ledc_formats); i++) { - if (!strcmp(format, sun50i_a100_ledc_formats[i])) { - priv->format = i; - return 0; - } - } + i = match_string(sun50i_a100_ledc_formats, ARRAY_SIZE(sun50i_a100_ledc_formats), format); + if (i < 0) + return dev_err_probe(dev, i, "Bad pixel format '%s'\n", format); - return dev_err_probe(dev, -EINVAL, "Bad pixel format '%s'\n", format); + priv->format = i; + return 0; } static void sun50i_a100_ledc_set_format(struct sun50i_a100_ledc *priv) -- 2.43.0.rc1.1336.g36b5255a03ac