Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chagall & Transformer EC updates #120

Merged
merged 13 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion drivers/input/keyboard/asus-ec-keys.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ASUS Transformer Pad - multimedia keys
*
*/

#include <linux/i2c.h>
Expand Down
1 change: 0 additions & 1 deletion drivers/input/serio/asus-ec-kbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*
* This looks suspiciously similar to i8042, but wrapped in
* I2C/SMBus packets.
*
*/

#include <linux/i2c.h>
Expand Down
4 changes: 2 additions & 2 deletions drivers/leds/leds-asus-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int asusec_led_probe(struct platform_device *pdev)
ret = devm_led_classdev_register(&pdev->dev, amber_led);
if (ret)
return dev_err_probe(&pdev->dev, ret,
"can't register AMBER LED\n");
"failed to register amber LED\n");

green_led = devm_kzalloc(&pdev->dev, sizeof(*green_led), GFP_KERNEL);
if (!green_led)
Expand All @@ -89,7 +89,7 @@ static int asusec_led_probe(struct platform_device *pdev)
ret = devm_led_classdev_register(&pdev->dev, green_led);
if (ret)
return dev_err_probe(&pdev->dev, ret,
"can't register GREEN LED\n");
"failed to register green LED\n");

return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/misc/asus-dockram.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ASUS EC: DockRAM
*
*/

#include <asm/unaligned.h>
Expand Down Expand Up @@ -189,7 +188,7 @@ static ssize_t control_reg_show(struct device *dev,
if (ret < 0)
return ret;

return snprintf(buf, PAGE_SIZE, "%016llx\n", val);
return sysfs_emit(buf, "%016llx\n", val);
}

static ssize_t control_reg_store(struct device *dev,
Expand Down
19 changes: 7 additions & 12 deletions drivers/power/supply/asus-ec-battery.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ASUS EC driver - battery monitoring
*
*/

#include <linux/devm-helpers.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
Expand Down Expand Up @@ -260,6 +260,7 @@ static int asusec_battery_probe(struct platform_device *pdev)
struct asusec_battery_data *priv;
struct asusec_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct power_supply_config cfg = {};
int ret;

priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
Expand Down Expand Up @@ -292,22 +293,17 @@ static int asusec_battery_probe(struct platform_device *pdev)
dev_warn(&pdev->dev,
"No monitored battery, some properties will be missing\n");

INIT_DELAYED_WORK(&priv->poll_work, asusec_battery_poll_work);
ret = devm_delayed_work_autocancel(&pdev->dev, &priv->poll_work,
asusec_battery_poll_work);
if (ret)
return ret;

schedule_delayed_work(&priv->poll_work,
msecs_to_jiffies(ASUSEC_BATTERY_DATA_FRESH_MSEC));

return 0;
}

static int asusec_battery_remove(struct platform_device *pdev)
{
struct asusec_battery_data *priv = dev_get_drvdata(&pdev->dev);

cancel_delayed_work_sync(&priv->poll_work);

return 0;
}

static int __maybe_unused asusec_battery_suspend(struct device *dev)
{
struct asusec_battery_data *priv = dev_get_drvdata(dev);
Expand Down Expand Up @@ -336,7 +332,6 @@ static struct platform_driver asusec_battery_driver = {
.pm = &asusec_battery_pm_ops,
},
.probe = asusec_battery_probe,
.remove = asusec_battery_remove,
};
module_platform_driver(asusec_battery_driver);

Expand Down
19 changes: 7 additions & 12 deletions drivers/power/supply/asus-ec-charger.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ASUS EC driver - charging monitoring
*
*/

#include <linux/delay.h>
#include <linux/devm-helpers.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
Expand Down Expand Up @@ -130,6 +130,7 @@ static int asusec_charger_probe(struct platform_device *pdev)
struct asusec_charger_data *priv;
struct asusec_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct power_supply_config cfg = {};
int ret;

priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
Expand Down Expand Up @@ -164,22 +165,17 @@ static int asusec_charger_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(priv->charger),
"Failed to register power supply\n");

INIT_DELAYED_WORK(&priv->poll_work, asusec_charger_poll_work);
ret = devm_delayed_work_autocancel(&pdev->dev, &priv->poll_work,
asusec_charger_poll_work);
if (ret)
return ret;

schedule_delayed_work(&priv->poll_work,
msecs_to_jiffies(ASUSEC_CHARGER_DELAY_MSEC));

return 0;
}

static int asusec_charger_remove(struct platform_device *pdev)
{
struct asusec_charger_data *priv = dev_get_drvdata(&pdev->dev);

cancel_delayed_work_sync(&priv->poll_work);

return 0;
}

static int __maybe_unused asusec_charger_suspend(struct device *dev)
{
struct asusec_charger_data *priv = dev_get_drvdata(dev);
Expand Down Expand Up @@ -208,7 +204,6 @@ static struct platform_driver asusec_charger_driver = {
.pm = &asusec_charger_pm_ops,
},
.probe = asusec_charger_probe,
.remove = asusec_charger_remove,
};
module_platform_driver(asusec_charger_driver);

Expand Down
26 changes: 11 additions & 15 deletions drivers/power/supply/chagall-battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include <linux/delay.h>
#include <linux/devm-helpers.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/leds.h>
Expand Down Expand Up @@ -318,11 +319,12 @@ static int chagall_battery_probe(struct i2c_client *client)

cg->battery = devm_power_supply_register(&client->dev, &chagall_battery_desc, &cfg);
if (IS_ERR(cg->battery))
return PTR_ERR(cg->battery);
return dev_err_probe(&client->dev, PTR_ERR(cg->battery),
"failed to register power supply\n");

if (power_supply_get_battery_info(cg->battery, &cg->batt_info))
dev_warn(&client->dev,
"No monitored battery, some properties will be missing\n");
"no monitored battery, some properties will be missing\n");

cg->amber_led.name = "power::amber";
cg->amber_led.max_brightness = 1;
Expand All @@ -332,7 +334,7 @@ static int chagall_battery_probe(struct i2c_client *client)
ret = devm_led_classdev_register(&client->dev, &cg->amber_led);
if (ret)
return dev_err_probe(&client->dev, ret,
"can't register AMBER LED\n");
"failed to register amber LED\n");

cg->white_led.name = "power::white";
cg->white_led.max_brightness = 1;
Expand All @@ -342,27 +344,22 @@ static int chagall_battery_probe(struct i2c_client *client)
ret = devm_led_classdev_register(&client->dev, &cg->white_led);
if (ret)
return dev_err_probe(&client->dev, ret,
"can't register WHITE LED\n");
"failed to register white LED\n");

led_set_brightness(&cg->amber_led, LED_OFF);
led_set_brightness(&cg->white_led, LED_OFF);

INIT_DELAYED_WORK(&cg->poll_work, chagall_battery_poll_work);
ret = devm_delayed_work_autocancel(&client->dev, &cg->poll_work,
chagall_battery_poll_work);
if (ret)
return ret;

schedule_delayed_work(&cg->poll_work,
msecs_to_jiffies(CHAGALL_BATTERY_DATA_REFRESH));

return 0;
}

static int chagall_battery_remove(struct i2c_client *client)
{
struct chagall_battery_data *cg = i2c_get_clientdata(client);

cancel_delayed_work_sync(&cg->poll_work);

return 0;
}

static int __maybe_unused chagall_battery_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
Expand Down Expand Up @@ -400,7 +397,6 @@ static struct i2c_driver chagall_battery_driver = {
.of_match_table = chagall_match,
},
.probe_new = chagall_battery_probe,
.remove = chagall_battery_remove,
};
module_i2c_driver(chagall_battery_driver);

Expand Down