Received: by 2002:a05:6a10:8a47:0:0:0:0 with SMTP id dn7csp267197pxb; Mon, 8 Nov 2021 08:47:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjPB2ScwhEE+jrWAbOEShIo7AAS2WuEpU1Jd2L/ohJw8k/oWS2D4PW+XKQPlgH0WHOXj4I X-Received: by 2002:a05:6402:4401:: with SMTP id y1mr585226eda.225.1636390050366; Mon, 08 Nov 2021 08:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636390050; cv=none; d=google.com; s=arc-20160816; b=vq29XFWfQQeZrbMCTiFfYDREsO0Li/qnyX+TKGpJY95AFFVRh5CzoQABuzBz69EnLc 5m/wiHf2ZnJ3kiZldwCmTTwNahkLMNLjqbZA+zFAqtinUN0/qy+OHIWPltGHMEK3ShRc COye9cDO0B/bkoyTqAeSNDhXK2lh94pDM1N5mbUgsYFD2xqXDmFwpRfyQ/pdd1feMkWm NvxR5cHC6DTn3o9GIpkR6gdoCQPcmEYhyzxVzYGY47cp6A9BGuOgfBrV36uj6+q+aMAi AsqKQhWaPgSml0figN9luYUUui6fDg4qX+6daRAoFglWQDaQsprk+x5oL/Gbs2Hn+P+J JXkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wJJrpppjSgRDTFrW+F5oEMLPyVDlFIclMKsDYZzd0Pc=; b=nHIsKrOIz3mWKzMsSRbRuF79Xy9LRo88X356g3CQ6lajOqpe5dUQdYn+u5tLF6MbTJ 3tCjgjyfjIq3iEdMQFmdKaRMlbODYTV+jx2TUDfsc1E+wpUKw+grPO9xqpreU2rcNVN0 zs1q7Ou5MIV7kX8ZkVNh1hN59e4t5FpU2flqg065Cf6MS3gOIdfjTmYWsvcAFOezoXYy ka7yWu5HTBjEQO2lA/QwyuMDpOEctQEJWFn672zHGuMaWguzQwWMi2kLs+mVNVNKxS1v 4KhP7pBqMTaq6xMSmJsvgG5cx10mYHe48NbBEhFXfcrYqhTAbbL0TY9FpkhqFQKzrtIp zK2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=XjSYLHla; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hg5si15267326ejc.701.2021.11.08.08.47.03; Mon, 08 Nov 2021 08:47:30 -0800 (PST) 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=@lunn.ch header.s=20171124 header.b=XjSYLHla; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240197AbhKHOHO (ORCPT + 99 others); Mon, 8 Nov 2021 09:07:14 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:50640 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233956AbhKHOHM (ORCPT ); Mon, 8 Nov 2021 09:07:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=wJJrpppjSgRDTFrW+F5oEMLPyVDlFIclMKsDYZzd0Pc=; b=XjSYLHlaXLwsdK23MobXnt8pMN t0m5+/o+1rvO+cz2IGsLVcTgPk0r6tz6yYzO+nwBQf3IDj7rMP9Jt3P9evizyaO35gyysrqEDy03N P+aJxsoL4Gc9ib08ig32pw/ddxjlv1W/TtYfkNbqJYJ7o26jij/mZqvz+rLlA8BeUxaM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mk5G3-00CtvX-4e; Mon, 08 Nov 2021 15:04:23 +0100 Date: Mon, 8 Nov 2021 15:04:23 +0100 From: Andrew Lunn To: Ansuel Smith Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Rob Herring , Jonathan Corbet , Pavel Machek , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org, Marek =?iso-8859-1?Q?Beh=FAn?= Subject: Re: [RFC PATCH v2 1/5] leds: trigger: add API for HW offloading of triggers Message-ID: References: <20211108002500.19115-1-ansuelsmth@gmail.com> <20211108002500.19115-2-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211108002500.19115-2-ansuelsmth@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static inline int led_trigger_offload(struct led_classdev *led_cdev) > +{ > + int ret; > + > + if (!led_cdev->trigger_offload) > + return -EOPNOTSUPP; > + > + ret = led_cdev->trigger_offload(led_cdev, true); > + led_cdev->offloaded = !ret; > + > + return ret; > +} > + > +static inline void led_trigger_offload_stop(struct led_classdev *led_cdev) > +{ > + if (!led_cdev->trigger_offload) > + return; > + > + if (led_cdev->offloaded) { > + led_cdev->trigger_offload(led_cdev, false); > + led_cdev->offloaded = false; > + } > +} > +#endif I think there should be two calls into the cdev driver, not this true/false parameter. trigger_offload_start() and trigger_offload_stop(). There are also a number of PHYs which don't allow software blinking of the LED. So for them, trigger_offload_stop() is going to return -EOPNOTSUPP. And you need to handle that correctly. It would be go to also document the expectations of trigger_offload_stop(). Should it leave the LED in whatever state it was, or force it off? Andrew