Commit 2779f472 authored by Marek Behún's avatar Marek Behún Committed by Pavel Machek

leds: various: use device_get_match_data

Simply use device_get_match_data instead of matching against the match
table again.
Signed-off-by: default avatarMarek Behún <marek.behun@nic.cz>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: David Rivshin <drivshin@allworx.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Christian Mauderer <oss@c-mauderer.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent 2aebb780
...@@ -158,19 +158,14 @@ MODULE_DEVICE_TABLE(of, cpcap_led_of_match); ...@@ -158,19 +158,14 @@ MODULE_DEVICE_TABLE(of, cpcap_led_of_match);
static int cpcap_led_probe(struct platform_device *pdev) static int cpcap_led_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match;
struct cpcap_led *led; struct cpcap_led *led;
int err; int err;
match = of_match_device(of_match_ptr(cpcap_led_of_match), &pdev->dev);
if (!match || !match->data)
return -EINVAL;
led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (!led) if (!led)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, led); platform_set_drvdata(pdev, led);
led->info = match->data; led->info = device_get_match_data(&pdev->dev);
led->dev = &pdev->dev; led->dev = &pdev->dev;
if (led->info->reg == 0x0000) { if (led->info->reg == 0x0000) {
......
...@@ -203,7 +203,6 @@ static int is31fl319x_parse_dt(struct device *dev, ...@@ -203,7 +203,6 @@ static int is31fl319x_parse_dt(struct device *dev,
struct is31fl319x_chip *is31) struct is31fl319x_chip *is31)
{ {
struct device_node *np = dev->of_node, *child; struct device_node *np = dev->of_node, *child;
const struct of_device_id *of_dev_id;
int count; int count;
int ret; int ret;
...@@ -219,18 +218,11 @@ static int is31fl319x_parse_dt(struct device *dev, ...@@ -219,18 +218,11 @@ static int is31fl319x_parse_dt(struct device *dev,
return ret; return ret;
} }
of_dev_id = of_match_device(of_is31fl319x_match, dev); is31->cdef = device_get_match_data(dev);
if (!of_dev_id) {
dev_err(dev, "Failed to match device with supported chips\n");
return -EINVAL;
}
is31->cdef = of_dev_id->data;
count = of_get_child_count(np); count = of_get_child_count(np);
dev_dbg(dev, "probe %s with %d leds defined in DT\n", dev_dbg(dev, "probing with %d leds defined in DT\n", count);
of_dev_id->compatible, count);
if (!count || count > is31->cdef->num_leds) { if (!count || count > is31->cdef->num_leds) {
dev_err(dev, "Number of leds defined must be between 1 and %u\n", dev_err(dev, "Number of leds defined must be between 1 and %u\n",
......
...@@ -428,17 +428,12 @@ static int is31fl32xx_probe(struct i2c_client *client, ...@@ -428,17 +428,12 @@ static int is31fl32xx_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
const struct is31fl32xx_chipdef *cdef; const struct is31fl32xx_chipdef *cdef;
const struct of_device_id *of_dev_id;
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct is31fl32xx_priv *priv; struct is31fl32xx_priv *priv;
int count; int count;
int ret = 0; int ret = 0;
of_dev_id = of_match_device(of_is31fl32xx_match, dev); cdef = device_get_match_data(dev);
if (!of_dev_id)
return -EINVAL;
cdef = of_dev_id->data;
count = of_get_child_count(dev->of_node); count = of_get_child_count(dev->of_node);
if (!count) if (!count)
......
...@@ -80,7 +80,6 @@ static int spi_byte_brightness_set_blocking(struct led_classdev *dev, ...@@ -80,7 +80,6 @@ static int spi_byte_brightness_set_blocking(struct led_classdev *dev,
static int spi_byte_probe(struct spi_device *spi) static int spi_byte_probe(struct spi_device *spi)
{ {
const struct of_device_id *of_dev_id;
struct device_node *child; struct device_node *child;
struct device *dev = &spi->dev; struct device *dev = &spi->dev;
struct spi_byte_led *led; struct spi_byte_led *led;
...@@ -88,10 +87,6 @@ static int spi_byte_probe(struct spi_device *spi) ...@@ -88,10 +87,6 @@ static int spi_byte_probe(struct spi_device *spi)
const char *state; const char *state;
int ret; int ret;
of_dev_id = of_match_device(spi_byte_dt_ids, dev);
if (!of_dev_id)
return -EINVAL;
if (of_get_child_count(dev->of_node) != 1) { if (of_get_child_count(dev->of_node) != 1) {
dev_err(dev, "Device must have exactly one LED sub-node."); dev_err(dev, "Device must have exactly one LED sub-node.");
return -EINVAL; return -EINVAL;
...@@ -106,7 +101,7 @@ static int spi_byte_probe(struct spi_device *spi) ...@@ -106,7 +101,7 @@ static int spi_byte_probe(struct spi_device *spi)
strlcpy(led->name, name, sizeof(led->name)); strlcpy(led->name, name, sizeof(led->name));
led->spi = spi; led->spi = spi;
mutex_init(&led->mutex); mutex_init(&led->mutex);
led->cdef = of_dev_id->data; led->cdef = device_get_match_data(dev);
led->ldev.name = led->name; led->ldev.name = led->name;
led->ldev.brightness = LED_OFF; led->ldev.brightness = LED_OFF;
led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value; led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value;
......
...@@ -150,16 +150,11 @@ tlc591xx_probe(struct i2c_client *client, ...@@ -150,16 +150,11 @@ tlc591xx_probe(struct i2c_client *client,
{ {
struct device_node *np = client->dev.of_node, *child; struct device_node *np = client->dev.of_node, *child;
struct device *dev = &client->dev; struct device *dev = &client->dev;
const struct of_device_id *match;
const struct tlc591xx *tlc591xx; const struct tlc591xx *tlc591xx;
struct tlc591xx_priv *priv; struct tlc591xx_priv *priv;
int err, count, reg; int err, count, reg;
match = of_match_device(of_tlc591xx_leds_match, dev); tlc591xx = device_get_match_data(dev);
if (!match)
return -ENODEV;
tlc591xx = match->data;
if (!np) if (!np)
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment