Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: various: use device_get_match_data

Simply use device_get_match_data instead of matching against the match
table again.

Signed-off-by: Marek 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: Pavel Machek <pavel@ucw.cz>

authored by

Marek Behún and committed by
Pavel Machek
2779f472 2aebb780

+6 -34
+1 -6
drivers/leds/leds-cpcap.c
··· 158 158 159 159 static int cpcap_led_probe(struct platform_device *pdev) 160 160 { 161 - const struct of_device_id *match; 162 161 struct cpcap_led *led; 163 162 int err; 164 - 165 - match = of_match_device(of_match_ptr(cpcap_led_of_match), &pdev->dev); 166 - if (!match || !match->data) 167 - return -EINVAL; 168 163 169 164 led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); 170 165 if (!led) 171 166 return -ENOMEM; 172 167 platform_set_drvdata(pdev, led); 173 - led->info = match->data; 168 + led->info = device_get_match_data(&pdev->dev); 174 169 led->dev = &pdev->dev; 175 170 176 171 if (led->info->reg == 0x0000) {
+2 -10
drivers/leds/leds-is31fl319x.c
··· 203 203 struct is31fl319x_chip *is31) 204 204 { 205 205 struct device_node *np = dev->of_node, *child; 206 - const struct of_device_id *of_dev_id; 207 206 int count; 208 207 int ret; 209 208 ··· 218 219 return ret; 219 220 } 220 221 221 - of_dev_id = of_match_device(of_is31fl319x_match, dev); 222 - if (!of_dev_id) { 223 - dev_err(dev, "Failed to match device with supported chips\n"); 224 - return -EINVAL; 225 - } 226 - 227 - is31->cdef = of_dev_id->data; 222 + is31->cdef = device_get_match_data(dev); 228 223 229 224 count = of_get_child_count(np); 230 225 231 - dev_dbg(dev, "probe %s with %d leds defined in DT\n", 232 - of_dev_id->compatible, count); 226 + dev_dbg(dev, "probing with %d leds defined in DT\n", count); 233 227 234 228 if (!count || count > is31->cdef->num_leds) { 235 229 dev_err(dev, "Number of leds defined must be between 1 and %u\n",
+1 -6
drivers/leds/leds-is31fl32xx.c
··· 428 428 const struct i2c_device_id *id) 429 429 { 430 430 const struct is31fl32xx_chipdef *cdef; 431 - const struct of_device_id *of_dev_id; 432 431 struct device *dev = &client->dev; 433 432 struct is31fl32xx_priv *priv; 434 433 int count; 435 434 int ret = 0; 436 435 437 - of_dev_id = of_match_device(of_is31fl32xx_match, dev); 438 - if (!of_dev_id) 439 - return -EINVAL; 440 - 441 - cdef = of_dev_id->data; 436 + cdef = device_get_match_data(dev); 442 437 443 438 count = of_get_child_count(dev->of_node); 444 439 if (!count)
+1 -6
drivers/leds/leds-spi-byte.c
··· 80 80 81 81 static int spi_byte_probe(struct spi_device *spi) 82 82 { 83 - const struct of_device_id *of_dev_id; 84 83 struct device_node *child; 85 84 struct device *dev = &spi->dev; 86 85 struct spi_byte_led *led; 87 86 const char *name = "leds-spi-byte::"; 88 87 const char *state; 89 88 int ret; 90 - 91 - of_dev_id = of_match_device(spi_byte_dt_ids, dev); 92 - if (!of_dev_id) 93 - return -EINVAL; 94 89 95 90 if (of_get_child_count(dev->of_node) != 1) { 96 91 dev_err(dev, "Device must have exactly one LED sub-node."); ··· 101 106 strlcpy(led->name, name, sizeof(led->name)); 102 107 led->spi = spi; 103 108 mutex_init(&led->mutex); 104 - led->cdef = of_dev_id->data; 109 + led->cdef = device_get_match_data(dev); 105 110 led->ldev.name = led->name; 106 111 led->ldev.brightness = LED_OFF; 107 112 led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value;
+1 -6
drivers/leds/leds-tlc591xx.c
··· 150 150 { 151 151 struct device_node *np = client->dev.of_node, *child; 152 152 struct device *dev = &client->dev; 153 - const struct of_device_id *match; 154 153 const struct tlc591xx *tlc591xx; 155 154 struct tlc591xx_priv *priv; 156 155 int err, count, reg; 157 156 158 - match = of_match_device(of_tlc591xx_leds_match, dev); 159 - if (!match) 160 - return -ENODEV; 161 - 162 - tlc591xx = match->data; 157 + tlc591xx = device_get_match_data(dev); 163 158 if (!np) 164 159 return -ENODEV; 165 160