Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp755078pxk; Thu, 17 Sep 2020 15:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs8/vK6jv7fY2H0Prgahh53jFNKdfyZNzD81Zq1P6NIDeVsXzjtrETuxYcVcHSSY48v7Ya X-Received: by 2002:a05:6402:228c:: with SMTP id cw12mr36679634edb.174.1600382360832; Thu, 17 Sep 2020 15:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600382360; cv=none; d=google.com; s=arc-20160816; b=AWWo/4Jha3KuJlrDK8QvLP0XzYTNjA8T2zZOrECfPccAAAU9kFinC2cctLpCrFKTyA RrbBBOm/zJsrSgqJdyALo1tRE+TtDS4+l2NjYLX9L3GB7pezSb3dADhH1EY7OalWWD24 x+WW0U4gnFb1+bproUwfNHZtnfg4V185++cxilr8YTRGXcd8bssdPFFNFm4KIyf3I4oU W3eV8j/0BnQC6Um33psdA5nyuo3NggsBpS+5e5z2aWFvSm5dz3nwGFJ+YR7MgCBQL/gP djCoYgp7F0VqKTuyhVRBlZ/ydE3XnZdzGbKv9j/0iD5AF/uP2v53AMkssj4SKBty5ygC AtDg== 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=l1DLr9udeM/Ei/bEV+DEOzTrnZUvuEwVsjBNdpSM1hw=; b=b20iaTuEAaIWoIA+oD1turwtgfu1fdISEqqc6lfRBEDYVjTtmhhEcnosrRxs+r8P3i i4ASzzHtE1NcnsSlUl+rpK0n2SvmcC1NgcpR75irdTLEKzg/kNyVjiBzl6Ss4XuT+iFe dVtmSOY41YTEtyPJIcdmj8383X5FGQDAM6dXyrrqnyutw7blLs6XUpkmCCKpE9/mavRg Zcq/k6LriDxt/hALydF5mIcj4x2rgPF6rWgzpPb36dirhiF7LINrVG9gmZ9e5WPyIdX8 nh7bORKTj3F34saJj04zRFEraehtmz98s8AtwVcgXS3vrr/TijZCQw9GQLjiv6nhz1OB RrnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=QePUZ4WS; 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 x23si814847ejb.588.2020.09.17.15.38.57; Thu, 17 Sep 2020 15:39:20 -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=QePUZ4WS; 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 S1726690AbgIQWfT (ORCPT + 99 others); Thu, 17 Sep 2020 18:35:19 -0400 Received: from lists.nic.cz ([217.31.204.67]:35560 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgIQWeN (ORCPT ); Thu, 17 Sep 2020 18:34:13 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 0267F142059; Fri, 18 Sep 2020 00:34:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382040; bh=/t1nSFHylk9lL02X5X71l6V/n4Ec26C/fK5mF77jSUw=; h=From:To:Date; b=QePUZ4WSxKcsjqjbBBPydWuWluzIw8q2qPiQR3I1HI9esw5BzC/DRPS0jxb4Ue3zS bH0HY+FC4ol75s5YIQhNI30Cv8kE1z496SU7FKVyu6omwL39RH0PX7+ZD734EcHI5t /6KEFXuoNgXUqr2anma4vNT8fUWKFBC+jO/qJ+7E= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?UTF-8?q?Ond=C5=99ej=20Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?UTF-8?q?Marek=20Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 37/50] leds: ns2: alloc simple array instead of struct ns2_led_priv Date: Fri, 18 Sep 2020 00:33:25 +0200 Message-Id: <20200917223338.14164-38-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nic.cz X-Spam-Status: No, score=0.00 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since .remove method is not needed now that we use devres, there is no need to remember the number of LEDs in struct ns2_led_priv. Alloc simple array of ns2_led_data structs. Signed-off-by: Marek BehĂșn Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 1a7ef66464b5d..8cd020b340840 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -334,15 +334,10 @@ static const struct of_device_id of_ns2_leds_match[] = { MODULE_DEVICE_TABLE(of, of_ns2_leds_match); #endif /* CONFIG_OF_GPIO */ -struct ns2_led_priv { - int num_leds; - struct ns2_led_data leds_data[]; -}; - static int ns2_led_probe(struct platform_device *pdev) { struct ns2_led_platform_data *pdata = dev_get_platdata(&pdev->dev); - struct ns2_led_priv *priv; + struct ns2_led_data *leds; int i; int ret; @@ -363,20 +358,18 @@ static int ns2_led_probe(struct platform_device *pdev) return -EINVAL; #endif /* CONFIG_OF_GPIO */ - priv = devm_kzalloc(&pdev->dev, struct_size(priv, leds_data, pdata->num_leds), GFP_KERNEL); - if (!priv) + leds = devm_kzalloc(&pdev->dev, array_size(sizeof(*leds), + pdata->num_leds), + GFP_KERNEL); + if (!leds) return -ENOMEM; - priv->num_leds = pdata->num_leds; - for (i = 0; i < priv->num_leds; i++) { - ret = create_ns2_led(pdev, &priv->leds_data[i], - &pdata->leds[i]); + for (i = 0; i < pdata->num_leds; i++) { + ret = create_ns2_led(pdev, &leds[i], &pdata->leds[i]); if (ret < 0) return ret; } - platform_set_drvdata(pdev, priv); - return 0; } -- 2.26.2