hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/leds/leds-pca963x.c
....@@ -1,15 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2011 bct electronic GmbH
34 * Copyright 2013 Qtechnology/AS
45 *
56 * Author: Peter Meerwald <p.meerwald@bct-electronic.com>
6
- * Author: Ricardo Ribalda <ricardo.ribalda@gmail.com>
7
+ * Author: Ricardo Ribalda <ribalda@kernel.org>
78 *
89 * Based on leds-pca955x.c
9
- *
10
- * This file is subject to the terms and conditions of version 2 of
11
- * the GNU General Public License. See the file COPYING in the main
12
- * directory of this archive for more details.
1310 *
1411 * LED driver for the PCA9633 I2C LED driver (7-bit slave address 0x62)
1512 * LED driver for the PCA9634/5 I2C LED driver (7-bit slave address set by hw.)
....@@ -25,7 +22,6 @@
2522 * or by adding the 'nxp,hw-blink' property to the DTS.
2623 */
2724
28
-#include <linux/acpi.h>
2925 #include <linux/module.h>
3026 #include <linux/delay.h>
3127 #include <linux/string.h>
....@@ -33,9 +29,9 @@
3329 #include <linux/leds.h>
3430 #include <linux/err.h>
3531 #include <linux/i2c.h>
32
+#include <linux/property.h>
3633 #include <linux/slab.h>
3734 #include <linux/of.h>
38
-#include <linux/platform_data/leds-pca963x.h>
3935
4036 /* LED select registers determine the source that drives LED outputs */
4137 #define PCA963X_LED_OFF 0x0 /* LED driver off */
....@@ -99,151 +95,148 @@
9995 };
10096 MODULE_DEVICE_TABLE(i2c, pca963x_id);
10197
102
-static const struct acpi_device_id pca963x_acpi_ids[] = {
103
- { "PCA9632", pca9633 },
104
- { "PCA9633", pca9633 },
105
- { "PCA9634", pca9634 },
106
- { "PCA9635", pca9635 },
107
- { }
108
-};
109
-MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
110
-
111
-struct pca963x_led;
112
-
113
-struct pca963x {
114
- struct pca963x_chipdef *chipdef;
115
- struct mutex mutex;
116
- struct i2c_client *client;
117
- struct pca963x_led *leds;
118
- unsigned long leds_on;
119
-};
98
+struct pca963x;
12099
121100 struct pca963x_led {
122101 struct pca963x *chip;
123102 struct led_classdev led_cdev;
124103 int led_num; /* 0 .. 15 potentially */
125
- char name[32];
126104 u8 gdc;
127105 u8 gfrq;
128106 };
129107
130
-static int pca963x_brightness(struct pca963x_led *pca963x,
131
- enum led_brightness brightness)
108
+struct pca963x {
109
+ struct pca963x_chipdef *chipdef;
110
+ struct mutex mutex;
111
+ struct i2c_client *client;
112
+ unsigned long leds_on;
113
+ struct pca963x_led leds[];
114
+};
115
+
116
+static int pca963x_brightness(struct pca963x_led *led,
117
+ enum led_brightness brightness)
132118 {
133
- u8 ledout_addr = pca963x->chip->chipdef->ledout_base
134
- + (pca963x->led_num / 4);
135
- u8 ledout;
136
- int shift = 2 * (pca963x->led_num % 4);
137
- u8 mask = 0x3 << shift;
119
+ struct i2c_client *client = led->chip->client;
120
+ struct pca963x_chipdef *chipdef = led->chip->chipdef;
121
+ u8 ledout_addr, ledout, mask, val;
122
+ int shift;
138123 int ret;
139124
140
- ledout = i2c_smbus_read_byte_data(pca963x->chip->client, ledout_addr);
125
+ ledout_addr = chipdef->ledout_base + (led->led_num / 4);
126
+ shift = 2 * (led->led_num % 4);
127
+ mask = 0x3 << shift;
128
+ ledout = i2c_smbus_read_byte_data(client, ledout_addr);
129
+
141130 switch (brightness) {
142131 case LED_FULL:
143
- ret = i2c_smbus_write_byte_data(pca963x->chip->client,
144
- ledout_addr,
145
- (ledout & ~mask) | (PCA963X_LED_ON << shift));
132
+ val = (ledout & ~mask) | (PCA963X_LED_ON << shift);
133
+ ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
146134 break;
147135 case LED_OFF:
148
- ret = i2c_smbus_write_byte_data(pca963x->chip->client,
149
- ledout_addr, ledout & ~mask);
136
+ val = ledout & ~mask;
137
+ ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
150138 break;
151139 default:
152
- ret = i2c_smbus_write_byte_data(pca963x->chip->client,
153
- PCA963X_PWM_BASE + pca963x->led_num,
154
- brightness);
140
+ ret = i2c_smbus_write_byte_data(client,
141
+ PCA963X_PWM_BASE +
142
+ led->led_num,
143
+ brightness);
155144 if (ret < 0)
156145 return ret;
157
- ret = i2c_smbus_write_byte_data(pca963x->chip->client,
158
- ledout_addr,
159
- (ledout & ~mask) | (PCA963X_LED_PWM << shift));
146
+
147
+ val = (ledout & ~mask) | (PCA963X_LED_PWM << shift);
148
+ ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
160149 break;
161150 }
162151
163152 return ret;
164153 }
165154
166
-static void pca963x_blink(struct pca963x_led *pca963x)
155
+static void pca963x_blink(struct pca963x_led *led)
167156 {
168
- u8 ledout_addr = pca963x->chip->chipdef->ledout_base +
169
- (pca963x->led_num / 4);
170
- u8 ledout;
171
- u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client,
172
- PCA963X_MODE2);
173
- int shift = 2 * (pca963x->led_num % 4);
174
- u8 mask = 0x3 << shift;
157
+ struct i2c_client *client = led->chip->client;
158
+ struct pca963x_chipdef *chipdef = led->chip->chipdef;
159
+ u8 ledout_addr, ledout, mask, val, mode2;
160
+ int shift;
175161
176
- i2c_smbus_write_byte_data(pca963x->chip->client,
177
- pca963x->chip->chipdef->grppwm, pca963x->gdc);
162
+ ledout_addr = chipdef->ledout_base + (led->led_num / 4);
163
+ shift = 2 * (led->led_num % 4);
164
+ mask = 0x3 << shift;
165
+ mode2 = i2c_smbus_read_byte_data(client, PCA963X_MODE2);
178166
179
- i2c_smbus_write_byte_data(pca963x->chip->client,
180
- pca963x->chip->chipdef->grpfreq, pca963x->gfrq);
167
+ i2c_smbus_write_byte_data(client, chipdef->grppwm, led->gdc);
168
+
169
+ i2c_smbus_write_byte_data(client, chipdef->grpfreq, led->gfrq);
181170
182171 if (!(mode2 & PCA963X_MODE2_DMBLNK))
183
- i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2,
184
- mode2 | PCA963X_MODE2_DMBLNK);
172
+ i2c_smbus_write_byte_data(client, PCA963X_MODE2,
173
+ mode2 | PCA963X_MODE2_DMBLNK);
185174
186
- mutex_lock(&pca963x->chip->mutex);
187
- ledout = i2c_smbus_read_byte_data(pca963x->chip->client, ledout_addr);
188
- if ((ledout & mask) != (PCA963X_LED_GRP_PWM << shift))
189
- i2c_smbus_write_byte_data(pca963x->chip->client, ledout_addr,
190
- (ledout & ~mask) | (PCA963X_LED_GRP_PWM << shift));
191
- mutex_unlock(&pca963x->chip->mutex);
175
+ mutex_lock(&led->chip->mutex);
176
+
177
+ ledout = i2c_smbus_read_byte_data(client, ledout_addr);
178
+ if ((ledout & mask) != (PCA963X_LED_GRP_PWM << shift)) {
179
+ val = (ledout & ~mask) | (PCA963X_LED_GRP_PWM << shift);
180
+ i2c_smbus_write_byte_data(client, ledout_addr, val);
181
+ }
182
+
183
+ mutex_unlock(&led->chip->mutex);
192184 }
193185
194
-static int pca963x_power_state(struct pca963x_led *pca963x)
186
+static int pca963x_power_state(struct pca963x_led *led)
195187 {
196
- unsigned long *leds_on = &pca963x->chip->leds_on;
197
- unsigned long cached_leds = pca963x->chip->leds_on;
188
+ struct i2c_client *client = led->chip->client;
189
+ unsigned long *leds_on = &led->chip->leds_on;
190
+ unsigned long cached_leds = *leds_on;
198191
199
- if (pca963x->led_cdev.brightness)
200
- set_bit(pca963x->led_num, leds_on);
192
+ if (led->led_cdev.brightness)
193
+ set_bit(led->led_num, leds_on);
201194 else
202
- clear_bit(pca963x->led_num, leds_on);
195
+ clear_bit(led->led_num, leds_on);
203196
204197 if (!(*leds_on) != !cached_leds)
205
- return i2c_smbus_write_byte_data(pca963x->chip->client,
206
- PCA963X_MODE1, *leds_on ? 0 : BIT(4));
198
+ return i2c_smbus_write_byte_data(client, PCA963X_MODE1,
199
+ *leds_on ? 0 : BIT(4));
207200
208201 return 0;
209202 }
210203
211204 static int pca963x_led_set(struct led_classdev *led_cdev,
212
- enum led_brightness value)
205
+ enum led_brightness value)
213206 {
214
- struct pca963x_led *pca963x;
207
+ struct pca963x_led *led;
215208 int ret;
216209
217
- pca963x = container_of(led_cdev, struct pca963x_led, led_cdev);
210
+ led = container_of(led_cdev, struct pca963x_led, led_cdev);
218211
219
- mutex_lock(&pca963x->chip->mutex);
212
+ mutex_lock(&led->chip->mutex);
220213
221
- ret = pca963x_brightness(pca963x, value);
214
+ ret = pca963x_brightness(led, value);
222215 if (ret < 0)
223216 goto unlock;
224
- ret = pca963x_power_state(pca963x);
217
+ ret = pca963x_power_state(led);
225218
226219 unlock:
227
- mutex_unlock(&pca963x->chip->mutex);
220
+ mutex_unlock(&led->chip->mutex);
228221 return ret;
229222 }
230223
231
-static unsigned int pca963x_period_scale(struct pca963x_led *pca963x,
232
- unsigned int val)
224
+static unsigned int pca963x_period_scale(struct pca963x_led *led,
225
+ unsigned int val)
233226 {
234
- unsigned int scaling = pca963x->chip->chipdef->scaling;
227
+ unsigned int scaling = led->chip->chipdef->scaling;
235228
236229 return scaling ? DIV_ROUND_CLOSEST(val * scaling, 1000) : val;
237230 }
238231
239232 static int pca963x_blink_set(struct led_classdev *led_cdev,
240
- unsigned long *delay_on, unsigned long *delay_off)
233
+ unsigned long *delay_on, unsigned long *delay_off)
241234 {
242
- struct pca963x_led *pca963x;
243235 unsigned long time_on, time_off, period;
236
+ struct pca963x_led *led;
244237 u8 gdc, gfrq;
245238
246
- pca963x = container_of(led_cdev, struct pca963x_led, led_cdev);
239
+ led = container_of(led_cdev, struct pca963x_led, led_cdev);
247240
248241 time_on = *delay_on;
249242 time_off = *delay_off;
....@@ -254,14 +247,14 @@
254247 time_off = 500;
255248 }
256249
257
- period = pca963x_period_scale(pca963x, time_on + time_off);
250
+ period = pca963x_period_scale(led, time_on + time_off);
258251
259252 /* If period not supported by hardware, default to someting sane. */
260253 if ((period < PCA963X_BLINK_PERIOD_MIN) ||
261254 (period > PCA963X_BLINK_PERIOD_MAX)) {
262255 time_on = 500;
263256 time_off = 500;
264
- period = pca963x_period_scale(pca963x, 1000);
257
+ period = pca963x_period_scale(led, 1000);
265258 }
266259
267260 /*
....@@ -269,7 +262,7 @@
269262 * (time_on / period) = (GDC / 256) ->
270263 * GDC = ((time_on * 256) / period)
271264 */
272
- gdc = (pca963x_period_scale(pca963x, time_on) * 256) / period;
265
+ gdc = (pca963x_period_scale(led, time_on) * 256) / period;
273266
274267 /*
275268 * From manual: period = ((GFRQ + 1) / 24) in seconds.
....@@ -278,10 +271,10 @@
278271 */
279272 gfrq = (period * 24 / 1000) - 1;
280273
281
- pca963x->gdc = gdc;
282
- pca963x->gfrq = gfrq;
274
+ led->gdc = gdc;
275
+ led->gfrq = gfrq;
283276
284
- pca963x_blink(pca963x);
277
+ pca963x_blink(led);
285278
286279 *delay_on = time_on;
287280 *delay_off = time_off;
....@@ -289,68 +282,84 @@
289282 return 0;
290283 }
291284
292
-#if IS_ENABLED(CONFIG_OF)
293
-static struct pca963x_platform_data *
294
-pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
285
+static int pca963x_register_leds(struct i2c_client *client,
286
+ struct pca963x *chip)
295287 {
296
- struct device_node *np = client->dev.of_node, *child;
297
- struct pca963x_platform_data *pdata;
298
- struct led_info *pca963x_leds;
299
- int count;
288
+ struct pca963x_chipdef *chipdef = chip->chipdef;
289
+ struct pca963x_led *led = chip->leds;
290
+ struct device *dev = &client->dev;
291
+ struct fwnode_handle *child;
292
+ bool hw_blink;
293
+ s32 mode2;
294
+ u32 reg;
295
+ int ret;
300296
301
- count = of_get_child_count(np);
302
- if (!count || count > chip->n_leds)
303
- return ERR_PTR(-ENODEV);
297
+ if (device_property_read_u32(dev, "nxp,period-scale",
298
+ &chipdef->scaling))
299
+ chipdef->scaling = 1000;
304300
305
- pca963x_leds = devm_kcalloc(&client->dev,
306
- chip->n_leds, sizeof(struct led_info), GFP_KERNEL);
307
- if (!pca963x_leds)
308
- return ERR_PTR(-ENOMEM);
301
+ hw_blink = device_property_read_bool(dev, "nxp,hw-blink");
309302
310
- for_each_child_of_node(np, child) {
311
- struct led_info led = {};
312
- u32 reg;
313
- int res;
314
-
315
- res = of_property_read_u32(child, "reg", &reg);
316
- if ((res != 0) || (reg >= chip->n_leds))
317
- continue;
318
- led.name =
319
- of_get_property(child, "label", NULL) ? : child->name;
320
- led.default_trigger =
321
- of_get_property(child, "linux,default-trigger", NULL);
322
- pca963x_leds[reg] = led;
323
- }
324
- pdata = devm_kzalloc(&client->dev,
325
- sizeof(struct pca963x_platform_data), GFP_KERNEL);
326
- if (!pdata)
327
- return ERR_PTR(-ENOMEM);
328
-
329
- pdata->leds.leds = pca963x_leds;
330
- pdata->leds.num_leds = chip->n_leds;
303
+ mode2 = i2c_smbus_read_byte_data(client, PCA963X_MODE2);
304
+ if (mode2 < 0)
305
+ return mode2;
331306
332307 /* default to open-drain unless totem pole (push-pull) is specified */
333
- if (of_property_read_bool(np, "nxp,totem-pole"))
334
- pdata->outdrv = PCA963X_TOTEM_POLE;
308
+ if (device_property_read_bool(dev, "nxp,totem-pole"))
309
+ mode2 |= PCA963X_MODE2_OUTDRV;
335310 else
336
- pdata->outdrv = PCA963X_OPEN_DRAIN;
337
-
338
- /* default to software blinking unless hardware blinking is specified */
339
- if (of_property_read_bool(np, "nxp,hw-blink"))
340
- pdata->blink_type = PCA963X_HW_BLINK;
341
- else
342
- pdata->blink_type = PCA963X_SW_BLINK;
343
-
344
- if (of_property_read_u32(np, "nxp,period-scale", &chip->scaling))
345
- chip->scaling = 1000;
311
+ mode2 &= ~PCA963X_MODE2_OUTDRV;
346312
347313 /* default to non-inverted output, unless inverted is specified */
348
- if (of_property_read_bool(np, "nxp,inverted-out"))
349
- pdata->dir = PCA963X_INVERTED;
314
+ if (device_property_read_bool(dev, "nxp,inverted-out"))
315
+ mode2 |= PCA963X_MODE2_INVRT;
350316 else
351
- pdata->dir = PCA963X_NORMAL;
317
+ mode2 &= ~PCA963X_MODE2_INVRT;
352318
353
- return pdata;
319
+ ret = i2c_smbus_write_byte_data(client, PCA963X_MODE2, mode2);
320
+ if (ret < 0)
321
+ return ret;
322
+
323
+ device_for_each_child_node(dev, child) {
324
+ struct led_init_data init_data = {};
325
+ char default_label[32];
326
+
327
+ ret = fwnode_property_read_u32(child, "reg", &reg);
328
+ if (ret || reg >= chipdef->n_leds) {
329
+ dev_err(dev, "Invalid 'reg' property for node %pfw\n",
330
+ child);
331
+ ret = -EINVAL;
332
+ goto err;
333
+ }
334
+
335
+ led->led_num = reg;
336
+ led->chip = chip;
337
+ led->led_cdev.brightness_set_blocking = pca963x_led_set;
338
+ if (hw_blink)
339
+ led->led_cdev.blink_set = pca963x_blink_set;
340
+
341
+ init_data.fwnode = child;
342
+ /* for backwards compatibility */
343
+ init_data.devicename = "pca963x";
344
+ snprintf(default_label, sizeof(default_label), "%d:%.2x:%u",
345
+ client->adapter->nr, client->addr, reg);
346
+ init_data.default_label = default_label;
347
+
348
+ ret = devm_led_classdev_register_ext(dev, &led->led_cdev,
349
+ &init_data);
350
+ if (ret) {
351
+ dev_err(dev, "Failed to register LED for node %pfw\n",
352
+ child);
353
+ goto err;
354
+ }
355
+
356
+ ++led;
357
+ }
358
+
359
+ return 0;
360
+err:
361
+ fwnode_handle_put(child);
362
+ return ret;
354363 }
355364
356365 static const struct of_device_id of_pca963x_match[] = {
....@@ -361,147 +370,50 @@
361370 {},
362371 };
363372 MODULE_DEVICE_TABLE(of, of_pca963x_match);
364
-#else
365
-static struct pca963x_platform_data *
366
-pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
367
-{
368
- return ERR_PTR(-ENODEV);
369
-}
370
-#endif
371373
372374 static int pca963x_probe(struct i2c_client *client,
373
- const struct i2c_device_id *id)
375
+ const struct i2c_device_id *id)
374376 {
375
- struct pca963x *pca963x_chip;
376
- struct pca963x_led *pca963x;
377
- struct pca963x_platform_data *pdata;
378
- struct pca963x_chipdef *chip;
379
- int i, err;
377
+ struct device *dev = &client->dev;
378
+ struct pca963x_chipdef *chipdef;
379
+ struct pca963x *chip;
380
+ int i, count;
380381
381
- if (id) {
382
- chip = &pca963x_chipdefs[id->driver_data];
383
- } else {
384
- const struct acpi_device_id *acpi_id;
382
+ chipdef = &pca963x_chipdefs[id->driver_data];
385383
386
- acpi_id = acpi_match_device(pca963x_acpi_ids, &client->dev);
387
- if (!acpi_id)
388
- return -ENODEV;
389
- chip = &pca963x_chipdefs[acpi_id->driver_data];
390
- }
391
- pdata = dev_get_platdata(&client->dev);
392
-
393
- if (!pdata) {
394
- pdata = pca963x_dt_init(client, chip);
395
- if (IS_ERR(pdata)) {
396
- dev_warn(&client->dev, "could not parse configuration\n");
397
- pdata = NULL;
398
- }
399
- }
400
-
401
- if (pdata && (pdata->leds.num_leds < 1 ||
402
- pdata->leds.num_leds > chip->n_leds)) {
403
- dev_err(&client->dev, "board info must claim 1-%d LEDs",
404
- chip->n_leds);
384
+ count = device_get_child_node_count(dev);
385
+ if (!count || count > chipdef->n_leds) {
386
+ dev_err(dev, "Node %pfw must define between 1 and %d LEDs\n",
387
+ dev_fwnode(dev), chipdef->n_leds);
405388 return -EINVAL;
406389 }
407390
408
- pca963x_chip = devm_kzalloc(&client->dev, sizeof(*pca963x_chip),
409
- GFP_KERNEL);
410
- if (!pca963x_chip)
411
- return -ENOMEM;
412
- pca963x = devm_kcalloc(&client->dev, chip->n_leds, sizeof(*pca963x),
413
- GFP_KERNEL);
414
- if (!pca963x)
391
+ chip = devm_kzalloc(dev, struct_size(chip, leds, count), GFP_KERNEL);
392
+ if (!chip)
415393 return -ENOMEM;
416394
417
- i2c_set_clientdata(client, pca963x_chip);
395
+ i2c_set_clientdata(client, chip);
418396
419
- mutex_init(&pca963x_chip->mutex);
420
- pca963x_chip->chipdef = chip;
421
- pca963x_chip->client = client;
422
- pca963x_chip->leds = pca963x;
397
+ mutex_init(&chip->mutex);
398
+ chip->chipdef = chipdef;
399
+ chip->client = client;
423400
424401 /* Turn off LEDs by default*/
425
- for (i = 0; i < chip->n_leds / 4; i++)
426
- i2c_smbus_write_byte_data(client, chip->ledout_base + i, 0x00);
427
-
428
- for (i = 0; i < chip->n_leds; i++) {
429
- pca963x[i].led_num = i;
430
- pca963x[i].chip = pca963x_chip;
431
-
432
- /* Platform data can specify LED names and default triggers */
433
- if (pdata && i < pdata->leds.num_leds) {
434
- if (pdata->leds.leds[i].name)
435
- snprintf(pca963x[i].name,
436
- sizeof(pca963x[i].name), "pca963x:%s",
437
- pdata->leds.leds[i].name);
438
- if (pdata->leds.leds[i].default_trigger)
439
- pca963x[i].led_cdev.default_trigger =
440
- pdata->leds.leds[i].default_trigger;
441
- }
442
- if (!pdata || i >= pdata->leds.num_leds ||
443
- !pdata->leds.leds[i].name)
444
- snprintf(pca963x[i].name, sizeof(pca963x[i].name),
445
- "pca963x:%d:%.2x:%d", client->adapter->nr,
446
- client->addr, i);
447
-
448
- pca963x[i].led_cdev.name = pca963x[i].name;
449
- pca963x[i].led_cdev.brightness_set_blocking = pca963x_led_set;
450
-
451
- if (pdata && pdata->blink_type == PCA963X_HW_BLINK)
452
- pca963x[i].led_cdev.blink_set = pca963x_blink_set;
453
-
454
- err = led_classdev_register(&client->dev, &pca963x[i].led_cdev);
455
- if (err < 0)
456
- goto exit;
457
- }
402
+ for (i = 0; i < chipdef->n_leds / 4; i++)
403
+ i2c_smbus_write_byte_data(client, chipdef->ledout_base + i, 0x00);
458404
459405 /* Disable LED all-call address, and power down initially */
460406 i2c_smbus_write_byte_data(client, PCA963X_MODE1, BIT(4));
461407
462
- if (pdata) {
463
- u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client,
464
- PCA963X_MODE2);
465
- /* Configure output: open-drain or totem pole (push-pull) */
466
- if (pdata->outdrv == PCA963X_OPEN_DRAIN)
467
- mode2 &= ~PCA963X_MODE2_OUTDRV;
468
- else
469
- mode2 |= PCA963X_MODE2_OUTDRV;
470
- /* Configure direction: normal or inverted */
471
- if (pdata->dir == PCA963X_INVERTED)
472
- mode2 |= PCA963X_MODE2_INVRT;
473
- i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2,
474
- mode2);
475
- }
476
-
477
- return 0;
478
-
479
-exit:
480
- while (i--)
481
- led_classdev_unregister(&pca963x[i].led_cdev);
482
-
483
- return err;
484
-}
485
-
486
-static int pca963x_remove(struct i2c_client *client)
487
-{
488
- struct pca963x *pca963x = i2c_get_clientdata(client);
489
- int i;
490
-
491
- for (i = 0; i < pca963x->chipdef->n_leds; i++)
492
- led_classdev_unregister(&pca963x->leds[i].led_cdev);
493
-
494
- return 0;
408
+ return pca963x_register_leds(client, chip);
495409 }
496410
497411 static struct i2c_driver pca963x_driver = {
498412 .driver = {
499413 .name = "leds-pca963x",
500
- .of_match_table = of_match_ptr(of_pca963x_match),
501
- .acpi_match_table = ACPI_PTR(pca963x_acpi_ids),
414
+ .of_match_table = of_pca963x_match,
502415 },
503416 .probe = pca963x_probe,
504
- .remove = pca963x_remove,
505417 .id_table = pca963x_id,
506418 };
507419