Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp922587pxb; Thu, 9 Sep 2021 15:28:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcrgcf6FbGdEffc9qVyGkrGeW0vTW/UhG57DBWuu7L3CkpcAuCzo4sModq7v9w8Ji8tk+O X-Received: by 2002:a92:194b:: with SMTP id e11mr3870409ilm.200.1631226515124; Thu, 09 Sep 2021 15:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631226515; cv=none; d=google.com; s=arc-20160816; b=YfFFp9rNtkc/fsHsHwPTiKDqlXX4/lz7NMfhLU061tZvpnSBdd50+8bhB7Z7lFDx6k vMMiOr8+GvTGlebTISDjstYj0alHF/WMEQZbaJNRom1r237G6CJUN48yACOvjQHD1XKD a+0CeVfh8GeX/Jphmh6vQkI8t8cDXfS6ZNRsheBEGncHwTs4/Y/UhHBVUO0ni9SyqN51 cITZOoZDZ1zQhNNp/as64ULJizEDCAOL0mWehVRB4dW9uA5KetucBnM40V3BXtbhv3W4 +lXXtZq99sEupWE4j/IrJnWPqtULb2vp8Pm4vtdVdih40JnGsUrB0evpXwtsZCoWHAYQ Jv0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2Hi3pqytord6VA6AZ/0fy4UVgNbJFo01Go8vz0Qkno0=; b=WiPnJeEVS5HHfcSMx0APq1v6zL5X0Q2c6aBIBu4Og+M3Ii0tpqGeRJCXddmbqIQmVn nEIyGaVN6qEUdXx/6Wlp5ke6nhc0gEI55jjUg9IUzx54li/cwdr/2+ZPbd1C6Y2THAfF uwJT3lsqazqvuBijzDvIYDAc11SSudWQMJeCGjmuTMfOULkpvZrx5mbvv/JnkND55ajK VCL4VqU3zgXoYCs+yu7ZDdC2uk7DcfqS91KxKCFYbmO/mmcYbXVYPsdCVRm8Wa1AGtu8 3JENaz0gVuDpjfocK8cIEM/TggjXbcMWByw7G7yPRZvC0FisPVBlL14ZI/Jg/kXX40HY njkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TSplS6Yn; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k35si2930282jac.46.2021.09.09.15.28.22; Thu, 09 Sep 2021 15:28:35 -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=@gmail.com header.s=20210112 header.b=TSplS6Yn; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349358AbhIIW1X (ORCPT + 99 others); Thu, 9 Sep 2021 18:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345835AbhIIW0j (ORCPT ); Thu, 9 Sep 2021 18:26:39 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92A5DC061575; Thu, 9 Sep 2021 15:25:29 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id x10-20020a056830408a00b004f26cead745so4552061ott.10; Thu, 09 Sep 2021 15:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Hi3pqytord6VA6AZ/0fy4UVgNbJFo01Go8vz0Qkno0=; b=TSplS6Yn6eAoeV4ddIRj6XrP5QxQ8Xa9Y21MMWF2ELp6X5d9C677r47b+QL3CO3hmB BzegxKvURdRvBJbR7tJt9TgLBH5cs/Y0c7wGJsI1vtrPXDmKhe8SuYScGtMed9VAg+Mb 169ZKk0ro/Q2sNc0pYSJHkAAT1sxCbmanu8Y1rOL0EPWIFlRxgMM5Hhmwewi2P8vex/1 m7945xyUWTC5TG/7A3ip7l1MrEF/8BxiF7y6o+Kedy+CSxn70dKJIvcU29cm5L4rLXEr 5JMyu0420EQqBrJ45LEeJAtdstCTFrOXBcLh3byS7aCrg78Hifj9xIuPDlQV74oQFl20 +ZhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Hi3pqytord6VA6AZ/0fy4UVgNbJFo01Go8vz0Qkno0=; b=LnxFTsnmaWKjlkIsyfSSpQHULTC8TANL7kqkkai4VCQuS/TQXty2PMrY02AQ+qmmyJ OLCVURwoJqOpOi16hSaQL75/atcWTEBONvyapgRiOrsFZqjGum/mhxiUYgXhADWOjkLp EixTx+LSfyA4Dzt7fJA6+3jIIzYQ0Fq7lWtYzdYrSK3FJU3qGP8udmauRsccB6QCcYOR gOBG3A69VSTcXfRbHbB3tiKeJIVNfGaa+hy3r3J5ZoqDf0fASpmSUTwJMPG0XBGMNRuJ Q+CzyoFJBzIMZknebGaVMR9fgX010S0Nu6tD+hblEk+YYpdSHLbkircUVLnbB+cYxSP8 9ukQ== X-Gm-Message-State: AOAM532/ABAFiavp1o1Q7Nfyn6aQOJXh/bJmb61qH9JRJruKHaPCFH3M 7KD+U6TSOh/GUDUj7zhxYGI= X-Received: by 2002:a9d:7ccc:: with SMTP id r12mr1946300otn.350.1631226328999; Thu, 09 Sep 2021 15:25:28 -0700 (PDT) Received: from ian.penurio.us ([47.184.51.90]) by smtp.gmail.com with ESMTPSA id 4sm747293oil.38.2021.09.09.15.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 15:25:28 -0700 (PDT) From: Ian Pilcher To: axboe@kernel.dk, pavel@ucw.cz Cc: linux-leds@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, kabel@kernel.org Subject: [PATCH v2 13/15] leds: trigger: blkdev: Add LED trigger deactivate function Date: Thu, 9 Sep 2021 17:25:11 -0500 Message-Id: <20210909222513.2184795-14-arequipeno@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210909222513.2184795-1-arequipeno@gmail.com> References: <20210909222513.2184795-1-arequipeno@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove all device links from this LED Remove /sys/class/leds//block_devices directory Free per-LED data structure Decrement module reference count Signed-off-by: Ian Pilcher --- drivers/leds/trigger/ledtrig-blkdev.c | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/leds/trigger/ledtrig-blkdev.c b/drivers/leds/trigger/ledtrig-blkdev.c index fff67ebd28f2..c7e101935bf6 100644 --- a/drivers/leds/trigger/ledtrig-blkdev.c +++ b/drivers/leds/trigger/ledtrig-blkdev.c @@ -435,6 +435,33 @@ static ssize_t unlink_device_store(struct device *const dev, static DEVICE_ATTR_WO(unlink_device); +/* + * + * Disassociate an LED from the trigger + * + */ + +static void blkdev_deactivate(struct led_classdev *const led_dev) +{ + struct ledtrig_blkdev_led *const led = led_get_trigger_data(led_dev); + struct ledtrig_blkdev_link *link; + struct hlist_node *next; + + mutex_lock(&ledtrig_blkdev_mutex); + + hlist_for_each_entry_safe(link, next, &led->disks, led_disks_node) + blkdev_disk_unlink_locked(led, link, link->disk); + + hlist_del(&led->leds_node); + kobject_put(led->dir); + kfree(led); + + mutex_unlock(&ledtrig_blkdev_mutex); + + module_put(THIS_MODULE); +} + + /* * * Initialization - register the trigger @@ -459,5 +486,6 @@ static const struct attribute_group *ledtrig_blkdev_attr_groups[] = { struct led_trigger ledtrig_blkdev_trigger = { .name = "blkdev", .activate = blkdev_activate, + .deactivate = blkdev_deactivate, .groups = ledtrig_blkdev_attr_groups, }; -- 2.31.1