Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp600641ybh; Wed, 15 Jul 2020 10:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwanwe7SECEOEeoj+3VlovRodzKUjZE2IJF/5+XVxEq41KWEKR4SozOE9EvXkW5KOQ0xMSX X-Received: by 2002:aa7:df08:: with SMTP id c8mr559891edy.372.1594832887125; Wed, 15 Jul 2020 10:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594832887; cv=none; d=google.com; s=arc-20160816; b=G+PHc/euNX5niszaEIPrcofqpcUR+LC/oRHkSEHkUQAT0TqjQySR7wTDwanGCCN3t/ WbeTa72DbPJozS2pR9EFQzt5MoUqCT/SXovNdBvUo74F1x++mgaPNUzdK3VhcWQBsc2f GTS6nM+PFwsDSmceuFBSCV2EVByiA+FRZpJiK2fR3hkw/NK4ja5S02AkwRhzS+QNb8zU cIdl8QANwjjTOpMSP6zJQCZpwF+RmozLcFg1mx/UR+HMPoPKZyz0WOvzsnVO+yKzYLdV Z/JV2qp0KhGSeD0L+YImuZ+aQIjEQXOMR7kzZf/kZS7UmPIrjv2QmuAlUeKO+m6gpNWr LUow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=a2Y6mnKGy5eVzj99llxlLI/z5Wm42gV/kzF7Jo/n9jA=; b=r/uTO1AcL+BtVZbOEucN+Shh4vltWdxkK8dUBYJFrPz1adnT4ur93rM4LOWXnv8Xdx JseI4hr7eH2bFnRL7vhvWtjt9AI1Y+zd3B9xkDnAnj/ckJWFcqVtMD9SpxWRdh5+Ni2X yp5OKvdioV1LePDG9SG2/KH4qNDnpShzYIP3RuEscZsJdopfmIOg1IJqY7nJlJgJKiso WcIv6/kiPkIxvGYWY7aijMIMNCzrDwwPBLWpBv1PFBEFPqMd/fdOYPjKGnoBO5w9X7VI 0B62+kaNBH71rV9iVTBe0fH+5rPM0uKDpXMDAU2k3pmcGEA1T8dtvvFW7ZnhhgWQK20H a+eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=qWr4UoxZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si1578308ejj.363.2020.07.15.10.07.42; Wed, 15 Jul 2020 10:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=qWr4UoxZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726023AbgGORHc (ORCPT + 99 others); Wed, 15 Jul 2020 13:07:32 -0400 Received: from lists.nic.cz ([217.31.204.67]:50594 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbgGORHb (ORCPT ); Wed, 15 Jul 2020 13:07:31 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTPSA id AD5D413F695; Wed, 15 Jul 2020 19:07:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1594832848; bh=VJj/3rJKfaRGY2IQDV9pYisRvsVavLbXwD9XAifjC1M=; h=Date:From:To; b=qWr4UoxZ1GL7pNbGinsFPhwXkbtxUFnBb2k1jiXNlUcz83T/I9NKE4w79cSLTwETT HdcNg6Ha6A3MtRzYscXljrqts8jDkQV5Ftf2xT1xj9kGWBIueOahqAAdIsUnBguFbN 5SqSB/xPY3oDvRpElqnhvcIvEan/U8+XAfumNHlk= Date: Wed, 15 Jul 2020 19:07:27 +0200 From: Marek =?ISO-8859-1?Q?Beh=FAn?= To: Pavel Machek Cc: Ondrej Jirman , linux-kernel@vger.kernel.org, Jacek Anaszewski , Dan Murphy , "open list:LED SUBSYSTEM" Subject: Re: [PATCH RFC] leds: Add support for per-LED device triggers Message-ID: <20200715190727.4bb528dc@dellmb.labs.office.nic.cz> In-Reply-To: <20200711100409.GA18901@amd> References: <20200702144712.1994685-1-megous@megous.com> <20200711100409.GA18901@amd> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-100.0 required=5.9 tests=SHORTCIRCUIT, USER_IN_WHITELIST shortcircuit=ham autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nic.cz X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Jul 2020 12:04:09 +0200 Pavel Machek wrote: > What about this? Should address Marek's concerns about resource use... > > Best regards, > Pavel > ... > @@ -280,7 +291,8 @@ int led_trigger_register(struct led_trigger *trig) > down_write(&triggers_list_lock); > /* Make sure the trigger's name isn't already in use */ > list_for_each_entry(_trig, &trigger_list, next_trig) { > - if (!strcmp(_trig->name, trig->name)) { > + if (!strcmp(_trig->name, trig->name) && > + (!_trig->private_led || _trig->private_led == > trig->private_led)) { up_write(&triggers_list_lock); > return -EEXIST; > } Hi Pavel, Your proposal does not add private_led member to struct led_trigger. I think you forgot to change this from Ondrej's proposal. This should instead check: the names are same and both trigger have the same type (either none or same). In that case return -EEXIST. Also a couple of lines below there is code for enabling this trigger for LEDs that have it set as default trigger. There should also be a check whether the trigger is relevant. In the linux/leds.h header the trigger_type in led_classdev should be inside the CONFIG_LEDS_TRIGGERS block. I will send new version with an example usage for a Marvell PHY driver. Marek