Skip to content

Commit

Permalink
ubnt-ledbar: fix compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Nov 14, 2024
1 parent cb33d17 commit 0404234
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package/kernel/ubnt-ledbar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define KernelPackage/leds-ubnt-ledbar
FILES:= \
$(PKG_BUILD_DIR)/leds-ubnt-ledbar.ko
AUTOLOAD:=$(call AutoProbe,leds-ubnt-ledbar,1)
DEPENDS:=+kmod-i2c-core
DEPENDS:=@TARGET_mediatek_mt7622||TARGET_ramips_mt7621 +kmod-i2c-core
endef

define KernelPackage/leds-ubnt-ledbar/description
Expand Down
42 changes: 10 additions & 32 deletions package/kernel/ubnt-ledbar/src/leds-ubnt-ledbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ static int ubnt_ledbar_init_led(struct device_node *np, struct ubnt_ledbar *ledb
struct led_classdev *led_cdev)
{
struct led_init_data init_data = {};
int ret;

if (!np)
return 0;
Expand All @@ -158,48 +157,37 @@ static int ubnt_ledbar_init_led(struct device_node *np, struct ubnt_ledbar *ledb

led_cdev->max_brightness = UBNT_LEDBAR_MAX_BRIGHTNESS;

ret = devm_led_classdev_register_ext(&ledbar->client->dev, led_cdev,
&init_data);
if (ret)
dev_err(&ledbar->client->dev, "led register err: %d\n", ret);

return ret;
return devm_led_classdev_register_ext(&ledbar->client->dev, led_cdev, &init_data);
}


static int ubnt_ledbar_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int ubnt_ledbar_probe(struct i2c_client *client)
{
struct device_node *np = client->dev.of_node;
struct ubnt_ledbar *ledbar;
int ret;
int err;

ledbar = devm_kzalloc(&client->dev, sizeof(*ledbar), GFP_KERNEL);
if (!ledbar)
return -ENOMEM;

ledbar->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);

if (IS_ERR(ledbar->enable_gpio)) {
ret = PTR_ERR(ledbar->enable_gpio);
dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);
return ret;
}
if (IS_ERR(ledbar->enable_gpio))
return dev_err_probe(&client->dev, PTR_ERR(ledbar->enable_gpio), "Failed to get enable gpio");

ledbar->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);

if (IS_ERR(ledbar->reset_gpio)) {
ret = PTR_ERR(ledbar->reset_gpio);
dev_err(&client->dev, "Failed to get reset gpio: %d\n", ret);
return ret;
}
if (IS_ERR(ledbar->reset_gpio))
return dev_err_probe(&client->dev, PTR_ERR(ledbar->reset_gpio), "Failed to get reset gpio");

ledbar->led_count = 1;
of_property_read_u32(np, "led-count", &ledbar->led_count);

ledbar->client = client;

mutex_init(&ledbar->lock);
err = devm_mutex_init(&client->dev, &ledbar->lock);
if (err)
return err;

i2c_set_clientdata(client, ledbar);

Expand All @@ -218,15 +206,6 @@ static int ubnt_ledbar_probe(struct i2c_client *client,
return ubnt_ledbar_apply_state(ledbar);
}

static int ubnt_ledbar_remove(struct i2c_client *client)
{
struct ubnt_ledbar *ledbar = i2c_get_clientdata(client);

mutex_destroy(&ledbar->lock);

return 0;
}

static const struct i2c_device_id ubnt_ledbar_id[] = {
{ "ubnt-ledbar", 0 },
{ }
Expand All @@ -245,7 +224,6 @@ static struct i2c_driver ubnt_ledbar_driver = {
.of_match_table = of_ubnt_ledbar_match,
},
.probe = ubnt_ledbar_probe,
.remove = ubnt_ledbar_remove,
.id_table = ubnt_ledbar_id,
};
module_i2c_driver(ubnt_ledbar_driver);
Expand Down

0 comments on commit 0404234

Please sign in to comment.