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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21A80C4167B for ; Fri, 16 Dec 2022 13:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbiLPNnR (ORCPT ); Fri, 16 Dec 2022 08:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiLPNnQ (ORCPT ); Fri, 16 Dec 2022 08:43:16 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964D715822; Fri, 16 Dec 2022 05:43:15 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10563"; a="298638701" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="298638701" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2022 05:43:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10563"; a="978613460" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="978613460" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga005.fm.intel.com with ESMTP; 16 Dec 2022 05:43:11 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1p6AzU-00AsQs-35; Fri, 16 Dec 2022 15:43:08 +0200 Date: Fri, 16 Dec 2022 15:43:08 +0200 From: Andy Shevchenko To: Hans de Goede Cc: Mark Gross , Pavel Machek , Lee Jones , Linus Walleij , Daniel Scally , Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus , platform-driver-x86@vger.kernel.org, linux-leds@vger.kernel.org, linux-gpio@vger.kernel.org, Kate Hsuan , Mark Pearson , Andy Yeh , Yao Hao , linux-media@vger.kernel.org Subject: Re: [PATCH v3 05/11] leds: led-class: Add generic [devm_]led_get() Message-ID: References: <20221216113013.126881-1-hdegoede@redhat.com> <20221216113013.126881-6-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221216113013.126881-6-hdegoede@redhat.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org On Fri, Dec 16, 2022 at 12:30:07PM +0100, Hans de Goede wrote: > Add a generic [devm_]led_get() method which can be used on both devicetree > and non devicetree platforms to get a LED classdev associated with > a specific function on a specific device, e.g. the privacy LED associated > with a specific camera sensor. > > Note unlike of_led_get() this takes a string describing the function > rather then an index. This is done because e.g. camera sensors might > have a privacy LED, or a flash LED, or both and using an index > approach leaves it unclear what the function of index 0 is if there is > only 1 LED. The existing of support is extended to also support > getting a LED by function-name using the standard devicetree pattern > of adding a -names string array to map names to the indexes. > > For non devicetree platforms a lookup-table mechanism is added to > allow the platform code to map specific LED class_dev-s to specific > device,function combinations this way. ... > + list_for_each_entry(lookup, &leds_lookup_list, list) { > + if (!strcmp(lookup->consumer_dev_name, dev_name(dev)) && > + !strcmp(lookup->consumer_function, function)) { > + led_name = kstrdup(lookup->led_name, GFP_KERNEL); kstrdup_const() ? > + break; > + } > + } > + if (!led_name) > + return ERR_PTR(-ENOENT); > + > + led_dev = class_find_device_by_name(leds_class, led_name); > + kfree(led_name); kfree_const() ? > + return __led_get(led_dev); > +} ... > +EXPORT_SYMBOL_GPL(led_add_lookup); > +EXPORT_SYMBOL_GPL(led_remove_lookup); Wondering why we can't make at least those two to be namespaced from day 1, -- With Best Regards, Andy Shevchenko