All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Tony Makkiel <tony.makkiel@daqri.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Richard Purdie <rpurdie@rpsys.net>,
	linux-leds@vger.kernel.org
Subject: [PATCH] leds: lp3952: Store leds[LP3952_LED_ALL] in struct lp3952_led_array
Date: Sun, 17 Jul 2016 10:18:18 +0800	[thread overview]
Message-ID: <1468721898.9106.1.camel@ingics.com> (raw)

The LP3952_LED_ALL is known at compile time, so we can just store
leds[LP3952_LED_ALL] in struct lp3952_led_array rather than calling
devm_kcalloc() to allocate the memory.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/leds/leds-lp3952.c  | 9 ---------
 include/linux/leds-lp3952.h | 2 +-
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/leds/leds-lp3952.c b/drivers/leds/leds-lp3952.c
index f6157c0..a73c8ff 100644
--- a/drivers/leds/leds-lp3952.c
+++ b/drivers/leds/leds-lp3952.c
@@ -215,21 +215,12 @@ static int lp3952_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
 	int status;
-	struct lp3952_ctrl_hdl *leds;
 	struct lp3952_led_array *priv;
 
 	priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	leds = devm_kcalloc(&client->dev, LP3952_LED_ALL, sizeof(*leds),
-			    GFP_KERNEL);
-	if (!leds) {
-		devm_kfree(&client->dev, priv);
-		return -ENOMEM;
-	}
-
-	priv->leds = leds;
 	priv->client = client;
 
 	priv->enable_gpio = devm_gpiod_get(&client->dev, "nrst",
diff --git a/include/linux/leds-lp3952.h b/include/linux/leds-lp3952.h
index edd5ed6..49b37ed 100644
--- a/include/linux/leds-lp3952.h
+++ b/include/linux/leds-lp3952.h
@@ -119,7 +119,7 @@ struct lp3952_led_array {
 	struct regmap *regmap;
 	struct i2c_client *client;
 	struct gpio_desc *enable_gpio;
-	struct lp3952_ctrl_hdl *leds;
+	struct lp3952_ctrl_hdl leds[LP3952_LED_ALL];
 };
 
 #endif /* LEDS_LP3952_H_ */
-- 
2.5.0

             reply	other threads:[~2016-07-17  2:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17  2:18 Axel Lin [this message]
2016-07-18  6:48 ` [PATCH] leds: lp3952: Store leds[LP3952_LED_ALL] in struct lp3952_led_array Jacek Anaszewski
     [not found]   ` <CAFRkauAKLnXakKH1qBKyGdTn7-0-z7Gp_7zj7ii6RBK1uXavAA@mail.gmail.com>
2016-07-18  7:29     ` Jacek Anaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468721898.9106.1.camel@ingics.com \
    --to=axel.lin@ingics.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rpurdie@rpsys.net \
    --cc=tony.makkiel@daqri.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.