mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
Pull bugzilla-9362 into release branch
This commit is contained in:
commit
6e3013932e
3 changed files with 31 additions and 19 deletions
|
@ -54,12 +54,6 @@
|
||||||
#define ACPI_BATTERY_DIR_NAME "BAT%i"
|
#define ACPI_BATTERY_DIR_NAME "BAT%i"
|
||||||
#define ACPI_AC_DIR_NAME "AC0"
|
#define ACPI_AC_DIR_NAME "AC0"
|
||||||
|
|
||||||
enum acpi_sbs_device_addr {
|
|
||||||
ACPI_SBS_CHARGER = 0x9,
|
|
||||||
ACPI_SBS_MANAGER = 0xa,
|
|
||||||
ACPI_SBS_BATTERY = 0xb,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ACPI_SBS_NOTIFY_STATUS 0x80
|
#define ACPI_SBS_NOTIFY_STATUS 0x80
|
||||||
#define ACPI_SBS_NOTIFY_INFO 0x81
|
#define ACPI_SBS_NOTIFY_INFO 0x81
|
||||||
|
|
||||||
|
@ -539,7 +533,7 @@ static struct proc_dir_entry *acpi_battery_dir = NULL;
|
||||||
|
|
||||||
static inline char *acpi_battery_units(struct acpi_battery *battery)
|
static inline char *acpi_battery_units(struct acpi_battery *battery)
|
||||||
{
|
{
|
||||||
return acpi_battery_mode(battery) ? " mWh" : " mAh";
|
return acpi_battery_mode(battery) ? " mW" : " mA";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -556,10 +550,10 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
|
||||||
if (!battery->present)
|
if (!battery->present)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
seq_printf(seq, "design capacity: %i%s\n",
|
seq_printf(seq, "design capacity: %i%sh\n",
|
||||||
battery->design_capacity * acpi_battery_scale(battery),
|
battery->design_capacity * acpi_battery_scale(battery),
|
||||||
acpi_battery_units(battery));
|
acpi_battery_units(battery));
|
||||||
seq_printf(seq, "last full capacity: %i%s\n",
|
seq_printf(seq, "last full capacity: %i%sh\n",
|
||||||
battery->full_charge_capacity * acpi_battery_scale(battery),
|
battery->full_charge_capacity * acpi_battery_scale(battery),
|
||||||
acpi_battery_units(battery));
|
acpi_battery_units(battery));
|
||||||
seq_printf(seq, "battery technology: rechargeable\n");
|
seq_printf(seq, "battery technology: rechargeable\n");
|
||||||
|
@ -590,7 +584,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
|
||||||
{
|
{
|
||||||
struct acpi_battery *battery = seq->private;
|
struct acpi_battery *battery = seq->private;
|
||||||
struct acpi_sbs *sbs = battery->sbs;
|
struct acpi_sbs *sbs = battery->sbs;
|
||||||
int result = 0;
|
int rate;
|
||||||
|
|
||||||
mutex_lock(&sbs->lock);
|
mutex_lock(&sbs->lock);
|
||||||
seq_printf(seq, "present: %s\n",
|
seq_printf(seq, "present: %s\n",
|
||||||
|
@ -604,9 +598,12 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
|
||||||
seq_printf(seq, "charging state: %s\n",
|
seq_printf(seq, "charging state: %s\n",
|
||||||
(battery->current_now < 0) ? "discharging" :
|
(battery->current_now < 0) ? "discharging" :
|
||||||
((battery->current_now > 0) ? "charging" : "charged"));
|
((battery->current_now > 0) ? "charging" : "charged"));
|
||||||
seq_printf(seq, "present rate: %d mA\n",
|
rate = abs(battery->current_now) * acpi_battery_ipscale(battery);
|
||||||
abs(battery->current_now) * acpi_battery_ipscale(battery));
|
rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
|
||||||
seq_printf(seq, "remaining capacity: %i%s\n",
|
acpi_battery_vscale(battery)/1000):1;
|
||||||
|
seq_printf(seq, "present rate: %d%s\n", rate,
|
||||||
|
acpi_battery_units(battery));
|
||||||
|
seq_printf(seq, "remaining capacity: %i%sh\n",
|
||||||
battery->capacity_now * acpi_battery_scale(battery),
|
battery->capacity_now * acpi_battery_scale(battery),
|
||||||
acpi_battery_units(battery));
|
acpi_battery_units(battery));
|
||||||
seq_printf(seq, "present voltage: %i mV\n",
|
seq_printf(seq, "present voltage: %i mV\n",
|
||||||
|
@ -614,7 +611,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
|
||||||
|
|
||||||
end:
|
end:
|
||||||
mutex_unlock(&sbs->lock);
|
mutex_unlock(&sbs->lock);
|
||||||
return result;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
|
static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
|
||||||
|
@ -638,7 +635,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
|
||||||
acpi_battery_get_alarm(battery);
|
acpi_battery_get_alarm(battery);
|
||||||
seq_printf(seq, "alarm: ");
|
seq_printf(seq, "alarm: ");
|
||||||
if (battery->alarm_capacity)
|
if (battery->alarm_capacity)
|
||||||
seq_printf(seq, "%i%s\n",
|
seq_printf(seq, "%i%sh\n",
|
||||||
battery->alarm_capacity *
|
battery->alarm_capacity *
|
||||||
acpi_battery_scale(battery),
|
acpi_battery_scale(battery),
|
||||||
acpi_battery_units(battery));
|
acpi_battery_units(battery));
|
||||||
|
|
|
@ -202,10 +202,9 @@ int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc)
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(acpi_smbus_unregister_callback);
|
EXPORT_SYMBOL_GPL(acpi_smbus_unregister_callback);
|
||||||
|
|
||||||
static void acpi_smbus_callback(void *context)
|
static inline void acpi_smbus_callback(void *context)
|
||||||
{
|
{
|
||||||
struct acpi_smb_hc *hc = context;
|
struct acpi_smb_hc *hc = context;
|
||||||
|
|
||||||
if (hc->callback)
|
if (hc->callback)
|
||||||
hc->callback(hc->context);
|
hc->callback(hc->context);
|
||||||
}
|
}
|
||||||
|
@ -214,6 +213,7 @@ static int smbus_alarm(void *context)
|
||||||
{
|
{
|
||||||
struct acpi_smb_hc *hc = context;
|
struct acpi_smb_hc *hc = context;
|
||||||
union acpi_smb_status status;
|
union acpi_smb_status status;
|
||||||
|
u8 address;
|
||||||
if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw))
|
if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw))
|
||||||
return 0;
|
return 0;
|
||||||
/* Check if it is only a completion notify */
|
/* Check if it is only a completion notify */
|
||||||
|
@ -222,9 +222,18 @@ static int smbus_alarm(void *context)
|
||||||
if (!status.fields.alarm)
|
if (!status.fields.alarm)
|
||||||
return 0;
|
return 0;
|
||||||
mutex_lock(&hc->lock);
|
mutex_lock(&hc->lock);
|
||||||
|
smb_hc_read(hc, ACPI_SMB_ALARM_ADDRESS, &address);
|
||||||
|
status.fields.alarm = 0;
|
||||||
smb_hc_write(hc, ACPI_SMB_STATUS, status.raw);
|
smb_hc_write(hc, ACPI_SMB_STATUS, status.raw);
|
||||||
if (hc->callback)
|
/* We are only interested in events coming from known devices */
|
||||||
acpi_os_execute(OSL_GPE_HANDLER, acpi_smbus_callback, hc);
|
switch (address >> 1) {
|
||||||
|
case ACPI_SBS_CHARGER:
|
||||||
|
case ACPI_SBS_MANAGER:
|
||||||
|
case ACPI_SBS_BATTERY:
|
||||||
|
acpi_os_execute(OSL_GPE_HANDLER,
|
||||||
|
acpi_smbus_callback, hc);
|
||||||
|
default:;
|
||||||
|
}
|
||||||
mutex_unlock(&hc->lock);
|
mutex_unlock(&hc->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@ enum acpi_smb_protocol {
|
||||||
|
|
||||||
static const u8 SMBUS_PEC = 0x80;
|
static const u8 SMBUS_PEC = 0x80;
|
||||||
|
|
||||||
|
enum acpi_sbs_device_addr {
|
||||||
|
ACPI_SBS_CHARGER = 0x9,
|
||||||
|
ACPI_SBS_MANAGER = 0xa,
|
||||||
|
ACPI_SBS_BATTERY = 0xb,
|
||||||
|
};
|
||||||
|
|
||||||
typedef void (*smbus_alarm_callback)(void *context);
|
typedef void (*smbus_alarm_callback)(void *context);
|
||||||
|
|
||||||
extern int acpi_smbus_read(struct acpi_smb_hc *hc, u8 protocol, u8 address,
|
extern int acpi_smbus_read(struct acpi_smb_hc *hc, u8 protocol, u8 address,
|
||||||
|
|
Loading…
Add table
Reference in a new issue