From patchwork Wed Oct 2 12:40:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 174993 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp704896ill; Wed, 2 Oct 2019 05:40:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa1sJSSMfdJwYKY3w+DGmJuvYhMGKzjOKI+zYvvBWcvjU8BHCV6g97Ri5CBHUrrYqji9uw X-Received: by 2002:a17:906:938b:: with SMTP id l11mr2843640ejx.67.1570020021925; Wed, 02 Oct 2019 05:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570020021; cv=none; d=google.com; s=arc-20160816; b=tpahXfl2X3Z6U7CnzntmDy17HfF7SLOFHclDJgg2mhzThwUwoVCGGKlmc5WiuG6RU1 hXegef0mXfpywsCL8UCPwA6nXO+bsEKW6OeN2tud53XpNwytUfELPXXuTQwZPrqvjabp OBwiF2f2wUK7QLz9UjugOhjg/VPYDSiomZMRJhZclhzXDbnw+dNvN/MuHDi9ov7cnH2x 9I00/PH0JTWOssoGBwEbAqHSMg5n5EEnUFY4BX0NJaEf1/OlZNLSvb7r2QIr2yvkF255 jGSXlUZL7395c6dO+69a8w35xa0sYpq0TFXrGQawHqJLy2NAjvydbIUwFyu6jC0UC1xD B7DA== 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:date:subject:cc:to:from :dkim-signature; bh=V5i2WFcuhfe5u3LBdg2gXDOnWB+ykjunjzamA4BciLw=; b=yQ69e268WjlyrTv4Oq1XBuoWIhF4LwR+T5IW9MJB2esVfnWc+OTBd+iqED6NajBPN1 avuFegww4jYfVHYKkcbRpwZHMIXr5eOzr+/jlbEJ0VmJmisfjy1vqcL6GeQ2bP9eT+wP 8bYOlYWGg7jZ1s20hq6ODtdeSzQVpVFLP8L0VNOSQeOiUnh38SJ0PV6IjtT1ToRiWmK6 XRAH5eeJlk5t5epqvlI6lacdL0I5TxWBq7HWxE22Gc05sXnWkrMI7y3PfH05HXrIgKex w40zY2nYbkKWtCzpOmnC80UCbbCYsM409K31t42QwRNt3xyUbRYQ2FVf9k3HZ6AqS9TP prjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ADbsjyBT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si10392513eja.377.2019.10.02.05.40.21; Wed, 02 Oct 2019 05:40:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ADbsjyBT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbfJBMkJ (ORCPT + 27 others); Wed, 2 Oct 2019 08:40:09 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:35524 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbfJBMkH (ORCPT ); Wed, 2 Oct 2019 08:40:07 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x92Ce4aO077277; Wed, 2 Oct 2019 07:40:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570020004; bh=V5i2WFcuhfe5u3LBdg2gXDOnWB+ykjunjzamA4BciLw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ADbsjyBTQUaxS/nzDvILG3lryMg4fpiDTj8PsjRlU5htCc6gQj8in9ht3QB9wt4ow q5LXlM4ERHlgcHbbbK/Nmplc5WZf1wOdkNPkDWZxXgGRfMlVTIVKSjvvPgaQa8tZU5 JXDizV1HfVjto15hIcecp9WToeavkwTmY19Yj7hc= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x92Ce4dH009167 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 2 Oct 2019 07:40:04 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 2 Oct 2019 07:39:53 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 2 Oct 2019 07:40:03 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x92Ce3mf094920; Wed, 2 Oct 2019 07:40:03 -0500 From: Dan Murphy To: , CC: , , Dan Murphy Subject: [PATCH v2 2/6] leds: flash: Add devm_* functions to the flash class Date: Wed, 2 Oct 2019 07:40:38 -0500 Message-ID: <20191002124042.25593-2-dmurphy@ti.com> X-Mailer: git-send-email 2.22.0.214.g8dca754b1e In-Reply-To: <20191002124042.25593-1-dmurphy@ti.com> References: <20191002124042.25593-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the missing device managed API for registration and unregistration for the LED flash class. Signed-off-by: Dan Murphy --- drivers/leds/led-class-flash.c | 50 +++++++++++++++++++++++++++++++++ include/linux/led-class-flash.h | 14 +++++++++ 2 files changed, 64 insertions(+) -- 2.22.0.214.g8dca754b1e diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c index 60c3de5c6b9f..6eeb9effcf65 100644 --- a/drivers/leds/led-class-flash.c +++ b/drivers/leds/led-class-flash.c @@ -327,6 +327,56 @@ void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) } EXPORT_SYMBOL_GPL(led_classdev_flash_unregister); +static void devm_led_classdev_flash_release(struct device *dev, void *res) +{ + led_classdev_flash_unregister(*(struct led_classdev_flash **)res); +} + +int devm_led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + struct led_classdev_flash **dr; + int ret; + + dr = devres_alloc(devm_led_classdev_flash_release, sizeof(*dr), + GFP_KERNEL); + if (!dr) + return -ENOMEM; + + ret = led_classdev_flash_register_ext(parent, fled_cdev, init_data); + if (ret) { + devres_free(dr); + return ret; + } + + *dr = fled_cdev; + devres_add(parent, dr); + + return 0; +} +EXPORT_SYMBOL_GPL(devm_led_classdev_flash_register_ext); + +static int devm_led_classdev_flash_match(struct device *dev, + void *res, void *data) +{ + struct led_classdev_flash **p = res; + + if (WARN_ON(!p || !*p)) + return 0; + + return *p == data; +} + +void devm_led_classdev_flash_unregister(struct device *dev, + struct led_classdev_flash *fled_cdev) +{ + WARN_ON(devres_release(dev, + devm_led_classdev_flash_release, + devm_led_classdev_flash_match, fled_cdev)); +} +EXPORT_SYMBOL_GPL(devm_led_classdev_flash_unregister); + static void led_clamp_align(struct led_flash_setting *s) { u32 v, offset; diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 1bd83159fa4c..21a3358a1731 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -113,6 +113,20 @@ static inline int led_classdev_flash_register(struct device *parent, */ void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev); +int devm_led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data); + + +static inline int devm_led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on