コード例 #1
0
static irqreturn_t sec_fg_irq_thread(int irq, void *irq_data)
{
	struct sec_fuelgauge_info *fuelgauge = irq_data;
	bool fuel_alerted;

	if (fuelgauge->pdata->fuel_alert_soc >= 0) {
		fuel_alerted =
			sec_hal_fg_is_fuelalerted(fuelgauge->client);

		dev_info(&fuelgauge->client->dev,
			"%s: Fuel-alert %salerted!\n",
			__func__, fuel_alerted ? "" : "NOT ");

		if (fuel_alerted == fuelgauge->is_fuel_alerted) {
			if (!fuelgauge->pdata->repeated_fuelalert) {
				dev_dbg(&fuelgauge->client->dev,
					"%s: Fuel-alert Repeated (%d)\n",
					__func__, fuelgauge->is_fuel_alerted);
				return IRQ_HANDLED;
			}
		}

		if (fuel_alerted)
			wake_lock(&fuelgauge->fuel_alert_wake_lock);
		else
			wake_unlock(&fuelgauge->fuel_alert_wake_lock);

		schedule_delayed_work(&fuelgauge->isr_work, 0);

		fuelgauge->is_fuel_alerted = fuel_alerted;
	}

	return IRQ_HANDLED;
}
コード例 #2
0
static void sec_fg_isr_work(struct work_struct *work)
{
    struct sec_fuelgauge_info *fuelgauge =
        container_of(work, struct sec_fuelgauge_info, isr_work.work);
    bool is_fuel_alerted_now;

    is_fuel_alerted_now =
        sec_hal_fg_is_fuelalerted(fuelgauge->client);

    dev_info(&fuelgauge->client->dev,
             "%s: Fuel-alert %salerted!\n",
             __func__, is_fuel_alerted_now ? "" : "NOT ");

    if (is_fuel_alerted_now)
        wake_lock(&fuelgauge->fuel_alert_wake_lock);
    else
        wake_unlock(&fuelgauge->fuel_alert_wake_lock);

    if (!(fuelgauge->pdata->repeated_fuelalert) &&
            (fuelgauge->is_fuel_alerted == is_fuel_alerted_now)) {
        dev_dbg(&fuelgauge->client->dev,
                "%s: Fuel-alert Repeated (%d)\n",
                __func__, fuelgauge->is_fuel_alerted);
        return;
    }

    /* process for fuel gauge chip */
    sec_hal_fg_fuelalert_process(fuelgauge, is_fuel_alerted_now);

    /* process for others */
    fuelgauge->pdata->fuelalert_process(is_fuel_alerted_now);

    fuelgauge->is_fuel_alerted = is_fuel_alerted_now;
}