From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A489C531DC for ; Fri, 23 Aug 2024 13:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jMOQ8tyTvY6Y9KXnBUUvnuEqtz33/151pP1+klm/Eaw=; b=NesJh9YXDjQfdKxZEzfbLr0HmA Ho6xUdLpyhXN3IXXk+MY7qqtx+JB2m51JXBANWJnaPmagYT8WFUsYQiyQU60xdk1IlI2JwZ7fg/mg GSeTg+h3j8ui6Q3aqLCFWlR8GdPr6btbLg4+X4qfdbBK1KsqU7FJqD/iSg36js/Zj1QCxoUXPKKhX RGsnd4SLWXYc6+1Am/w91tyhYewX7Wqpgfn7aGosrl50050L2DLX1hdykz946Q9LJ9MUxaJMMrwmG t3clb1hPiqC9DRK871wHbXQzRVbU2BYXPNFg2ybV/oSpWqhbjGiMnII9L38Ei1oo2GqACAf5167w4 Ucq5mgHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shUdP-0000000Gw0z-21rq; Fri, 23 Aug 2024 13:47:23 +0000 Received: from mgamail.intel.com ([198.175.65.11]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shUcd-0000000GvuL-0zK9; Fri, 23 Aug 2024 13:46:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724420795; x=1755956795; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=oj4nyYMV4gB+mypoya7w5RGqytEUERznSMy5TvYxR6Y=; b=HeVtSMUNgveKSRtG1UIa0YX8ECUoUU1synEkhOMgpPi+Cce43Fzaddux OUT66GJiGP2QDO4bvTsebq51rpIpd7yBt5hQGUoSmdZ7cnsYRbHp+1Kdf gvX1wPV/8682yzQolWgIdCQjs8m9Zp4fGWp2wcJenorFwRhs3QLJ6AlX7 CNa/pNyvnQuRdGlHmbRN1Qj5VQ//qoZkgEyrv3D63FFizTMZj/flad/zi miSYkkLS06Vx01Ah9mAwTLWXKYhyntkn5Sk15VsBSWytk5tFaXa/+6xmJ k5LoQQykhjkcBvtKsiVeKtsxKvdwb/ubZ9QOeINgp5i3fgyxh7ZLPwwoS Q==; X-CSE-ConnectionGUID: 16yeh2wNQF+wXD4+MmmpVQ== X-CSE-MsgGUID: HRgEJbqCQHWHg/Fm2Okfig== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="33456388" X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="33456388" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 06:46:34 -0700 X-CSE-ConnectionGUID: WWhL323KQ3WR5KbQYnhSwA== X-CSE-MsgGUID: rYcEtennSpqHFKRmjZnPvA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="66729372" Received: from smile.fi.intel.com ([10.237.72.54]) by orviesa004.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 06:46:30 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1shUcV-00000000oDe-2JZj; Fri, 23 Aug 2024 16:46:27 +0300 Date: Fri, 23 Aug 2024 16:46:27 +0300 From: Andy Shevchenko To: Chen-Yu Tsai Cc: Rob Herring , Saravana Kannan , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih , Mark Brown , Liam Girdwood , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , Jiri Kosina , linux-i2c@vger.kernel.org Subject: Re: [PATCH v5 05/10] gpiolib: Add gpio_property_name_length() Message-ID: References: <20240822092006.3134096-1-wenst@chromium.org> <20240822092006.3134096-6-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_064635_349328_352F19AF X-CRM114-Status: GOOD ( 20.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 23, 2024 at 03:50:55PM +0800, Chen-Yu Tsai wrote: > On Thu, Aug 22, 2024 at 10:37 PM Andy Shevchenko > wrote: > > On Thu, Aug 22, 2024 at 05:19:58PM +0800, Chen-Yu Tsai wrote: ... > > > + len = strlen(str); > > > > If it has a thousands characters...? > > Shouldn't matter much? I suppose using strrchr() as you suggested > requires one less pass. Yes, this is the point. ... > > This can be combined with the above > > > > for (const char *const *p = gpio_suffixes; *p; p++) { > > /* > > * Find right-most '-' and check if remainder matches suffix. > > * If no separator found, check for no-name cases. > > */ > > dash = strrchr(propname, '-'); > > I believe this line could be moved out of the for-loop. Otherwise it > looks much more concise compared to my version. I'll omit the comment > though, as it is just rehashing the kerneldoc description, and now > that the function is so short, it shouldn't be hard to read. Agree. And I put comment inside the loop, while it should be outside. But then, as you said, the function becomes so little that kernel-doc above does the job, hence no comment in the code needed. > I'll add you as "Suggested-by". Fine with me. > > if (!strcmp(dash ? dash + 1 : propname, *p)) > > return i; > > } -- With Best Regards, Andy Shevchenko