Esempio n. 1
0
static void high_watermark_state(int new_state)
{
	if (high_watermark_reached != new_state) {
		high_watermark_reached = new_state;
		sysfs_notify(kernel_kobj, NULL, "high_watermark");
	}
}
Esempio n. 2
0
static void pil_set_state(struct pil_device *pil, enum pil_state state)
{
	if (pil->state != state) {
		pil->state = state;
		sysfs_notify(&pil->dev.kobj, NULL, "state");
	}
}
Esempio n. 3
0
static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
{
	struct omap24xxcam_fh *ofh = fh;
	struct omap24xxcam_device *cam = ofh->cam;
	int rval;

	mutex_lock(&cam->mutex);
	if (cam->streaming) {
		rval = -EBUSY;
		goto out;
	}

	rval = omap24xxcam_sensor_if_enable(cam);
	if (rval) {
		dev_dbg(cam->dev, "vidioc_int_g_ifparm failed\n");
		goto out;
	}

	rval = videobuf_streamon(&ofh->vbq);
	if (!rval) {
		cam->streaming = file;
		sysfs_notify(&cam->dev->kobj, NULL, "streaming");
	}

out:
	mutex_unlock(&cam->mutex);

	return rval;
}
static void headphone_detect_handler(struct work_struct *work)
{
	struct imx_3stack_priv *priv = &card_priv;
	struct platform_device *pdev = priv->pdev;

	sysfs_notify(&pdev->dev.kobj, NULL, "headphone");
}
static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
{
	struct twl6030_usb *twl = _twl;
	int status;
	u8 vbus_state, hw_state;
	unsigned charger_type;

	hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);

	vbus_state = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE,
						CONTROLLER_STAT1);
	vbus_state = vbus_state & VBUS_DET;

	/* Ignore charger events other than VBUS */
	if (vbus_state == twl->prev_vbus)
		return IRQ_HANDLED;

	if ((vbus_state) && !(hw_state & STS_USB_ID)) {
		regulator_enable(twl->usb3v3);
		charger_type = omap4_charger_detect();
		if ((charger_type == POWER_SUPPLY_TYPE_USB_CDP)
				|| (charger_type == POWER_SUPPLY_TYPE_USB)) {

			status = USB_EVENT_VBUS;
			twl->otg.default_a = false;
			twl->asleep = 1;
			twl->otg.state = OTG_STATE_B_IDLE;
			twl->linkstat = status;
			twl->otg.last_event = status;
		} else if (charger_type == POWER_SUPPLY_TYPE_USB_DCP) {
			regulator_disable(twl->usb3v3);
			status = USB_EVENT_CHARGER;
			twl->usb_cinlimit_mA = 1800;
			twl->otg.last_event = status;
		} else {
			regulator_disable(twl->usb3v3);
			goto vbus_notify;
		}
		atomic_notifier_call_chain(&twl->otg.notifier,
				status, &charger_type);
	}
	if (!vbus_state) {
		status = USB_EVENT_NONE;
		twl->linkstat = status;
		twl->otg.last_event = status;
		if (twl->asleep) {

			atomic_notifier_call_chain(&twl->otg.notifier,
					status, twl->otg.gadget);
			regulator_disable(twl->usb3v3);
			twl->asleep = 0;

		}
	}
	sysfs_notify(&twl->dev->kobj, NULL, "vbus");

vbus_notify:
	twl->prev_vbus = vbus_state;
	return IRQ_HANDLED;
}
static 	int proximity_sensor_value_changed_cb(
    struct oem_rapi_client_streaming_func_cb_arg *arg,
    struct oem_rapi_client_streaming_func_cb_ret *ret)
{
    struct prox_value_from_rpc_t {
        u32 sensor_value;
        u32 adc_value;
    } *args;

    if (arg && arg->event == OEM_RAPI_SERVER_EVENT_PROXIMITY_VALUE_CB &&
            arg->in_len == sizeof(struct prox_value_from_rpc_t) && arg->input) {

        args = (struct prox_value_from_rpc_t *)arg->input;

        DBG(printk(KERN_DEBUG
                   "%s (%s): sensor adc_value = %d, sensor value = %d.\n",
                   DEV_NAME, __func__, args->adc_value, args->sensor_value));

        LOCK();
        proximity.sensor_value = args->sensor_value;
        proximity.adc_value = args->adc_value;
        UNLOCK();
        sysfs_notify(&proximity.semc_dev.dev->kobj, NULL, "sensor");
    } else {
        if (arg)
            printk(KERN_ERR "%s (%s): "
                   "got event %d, in_len %d, input->0x%x\n",
                   DEV_NAME, __func__, arg->event, arg->in_len,
                   (unsigned int)arg->input);
        else
            printk(KERN_ERR "%s (%s): Null arg pointer received\n",
                   DEV_NAME, __func__);
    }
    return 0;
}
Esempio n. 7
0
static ssize_t wait_for_fb_wake_show(struct kobject *kobj,
				     struct kobj_attribute *attr, char *buf)
{
	char *s = buf;
	int ret;
	unsigned long irq_flags;

	spin_lock_irqsave(&fb_state_lock, irq_flags);
	if (fb_state == FB_STATE_REQUEST_STOP_DRAWING) {
		fb_state = FB_STATE_STOPPED_DRAWING;
		wake_up(&fb_state_wq);
	}
	spin_unlock_irqrestore(&fb_state_lock, irq_flags);

	ret = wait_event_interruptible(fb_state_wq,
				       fb_state == FB_STATE_DRAWING_OK);
	if (ret && fb_state != FB_STATE_DRAWING_OK)
		return ret;
	else {
		s += sprintf(buf, "awake");
		if (display == 0) {
			display = 1;
			sysfs_notify(power_kobj, NULL, "wait_for_fb_status");
		}
	}
	return s - buf;
}
Esempio n. 8
0
static __ref int do_hotplug(void *data)
{
	int ret = 0;
	int cpu = 0;
	uint32_t mask = 0;

	if (!core_control_enabled)
		return -EINVAL;

	while (!kthread_should_stop()) {
		wait_for_completion(&hotplug_notify_complete);
		INIT_COMPLETION(hotplug_notify_complete);
		mask = 0;

		mutex_lock(&core_control_mutex);
		for_each_possible_cpu(cpu) {
			if (cpus[cpu].offline || cpus[cpu].user_offline)
				mask |= BIT(cpu);
		}
		if (mask != cpus_offlined)
			update_offline_cores(mask);
		mutex_unlock(&core_control_mutex);
		sysfs_notify(cc_kobj, NULL, "cpus_offlined");
	}

	return ret;
}
Esempio n. 9
0
static void headphone_detect_handler(struct work_struct *work)
{
	struct imx_3stack_priv *priv = &card_priv;
	struct platform_device *pdev = priv->pdev;
	struct mxc_audio_platform_data *plat = pdev->dev.platform_data;
	int hp_status;
	char *envp[3];
	char *buf;

	sysfs_notify(&pdev->dev.kobj, NULL, "headphone");
	hp_status = plat->hp_status();

	/* setup a message for userspace headphone in */
	buf = kmalloc(32, GFP_ATOMIC);
	if (!buf) {
		pr_err("%s kmalloc failed\n", __func__);
		return;
	}
	envp[0] = "NAME=headphone";
	snprintf(buf, 32, "STATE=%d", hp_status);
	envp[1] = buf;
	envp[2] = NULL;
	kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, envp);
	kfree(buf);

	if (hp_status)
		set_irq_type(plat->hp_irq, IRQ_TYPE_EDGE_FALLING);
	else
		set_irq_type(plat->hp_irq, IRQ_TYPE_EDGE_RISING);
	enable_irq(plat->hp_irq);
}
Esempio n. 10
0
static void twl6030_usb_irq_wq_func(struct work_struct *twl6030_usb_irq_wq)
//static irqreturn_t twl6030_usb_irq_wq_func(int irq, void *_twl)
{
	struct twl6030_usb *twl = tmp_twl;// hunsoo _twl;
	int status  = USB_EVENT_NONE;
	int vbus_state, hw_state;


	hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);

	vbus_state = twl6030_readb(twl, TWL6030_MODULE_CHARGER,
						CONTROLLER_STAT1);
	/* AC unplugg can also generate this IRQ
	 * we only call the notifier in case of VBUS change
	 */
	if (twl->prev_vbus != (vbus_state & VBUS_DET)) {
		if (!(hw_state & STS_USB_ID)) {
			if (vbus_state & VBUS_DET)
				status = USB_EVENT_VBUS;
			else
				status = USB_EVENT_NONE;

			if (status >= 0) {
				blocking_notifier_call_chain(&twl->otg.notifier,
						status, twl->otg.gadget);
			}
		}
		twl->linkstat = status;
		sysfs_notify(&twl->dev->kobj, NULL, "vbus");
	}
	twl->prev_vbus = vbus_state & VBUS_DET;


	return IRQ_HANDLED;
}
Esempio n. 11
0
ssize_t
cpu_hotplug_store(struct kobject *kobj, struct kobj_attribute *attr,
		const char *buf, size_t n)
{
	sysfs_notify(hotplug_kobj, NULL, "cpu_hotplug");
	return 0;
}
Esempio n. 12
0
static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
{
	struct twl4030_usb *twl = _twl;
	int status;

#ifdef CONFIG_LOCKDEP
	
	local_irq_enable();
#endif

	status = twl4030_usb_linkstat(twl);
	if (status != USB_LINK_UNKNOWN) {

		
		twl4030charger_usb_en(status == USB_LINK_VBUS);

		if (status == USB_LINK_NONE)
			twl4030_phy_suspend(twl, 0);
		else
			twl4030_phy_resume(twl);
	}
	sysfs_notify(&twl->dev->kobj, NULL, "vbus");

	return IRQ_HANDLED;
}
Esempio n. 13
0
static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
{
	struct twl4030_usb *twl = _twl;
	int status;

	status = twl4030_usb_linkstat(twl);
	if (status >= 0) {
		/* FIXME add a set_power() method so that B-devices can
		 * configure the charger appropriately.  It's not always
		 * correct to consume VBUS power, and how much current to
		 * consume is a function of the USB configuration chosen
		 * by the host.
		 *
		 * REVISIT usb_gadget_vbus_connect(...) as needed, ditto
		 * its disconnect() sibling, when changing to/from the
		 * USB_LINK_VBUS state.  musb_hdrc won't care until it
		 * starts to handle softconnect right.
		 */
		if (status == USB_EVENT_NONE)
			twl4030_phy_suspend(twl, 0);
		else
			twl4030_phy_resume(twl);

		blocking_notifier_call_chain(&twl->otg.notifier, status,
				twl->otg.gadget);
	}
	sysfs_notify(&twl->dev->kobj, NULL, "vbus");

	return IRQ_HANDLED;
}
Esempio n. 14
0
static void low_watermark_state(int new_state)
{
	if (low_watermark_reached != new_state) {
		low_watermark_reached = new_state;
		sysfs_notify(kernel_kobj, NULL, "low_watermark");
	}
}
Esempio n. 15
0
/*
 * Message receiver(workqueue)
 */
static void mbox_rx_work(struct work_struct *work)
{
    struct omap_mbox_queue *mq =
            container_of(work, struct omap_mbox_queue, work);
    struct omap_mbox *mbox = mq->queue->queuedata;
    struct request_queue *q = mbox->rxq->queue;
    struct request *rq;
    mbox_msg_t msg;
    unsigned long flags;

    if (mbox->rxq->callback == NULL) {
        sysfs_notify(&mbox->dev.kobj, NULL, "mbox");
        return;
    }

    while (1) {
        spin_lock_irqsave(q->queue_lock, flags);
        rq = elv_next_request(q);
        spin_unlock_irqrestore(q->queue_lock, flags);
        if (!rq)
            break;

        msg = (mbox_msg_t) rq->data;

        if (blk_end_request(rq, 0, 0))
            BUG();

        mbox->rxq->callback((void *)msg);
    }
}
Esempio n. 16
0
static void notify_uspace_tsens_fn(struct work_struct *work)
{
	struct tsens_tm_device_sensor *tm = container_of(work,
		struct tsens_tm_device_sensor, work);

	sysfs_notify(&tm->tz_dev->device.kobj,
					NULL, "type");
}
Esempio n. 17
0
static void touch_event_fn(struct work_struct *work)
{
	/* wakeup the userspace poll */
	tc_ev_processed = 1;
	sysfs_notify(power_kobj, NULL, "touch_event");

	return;
}
Esempio n. 18
0
static void touch_event_fn(struct work_struct *work)
{
	
	tc_ev_processed = 1;
	sysfs_notify(power_kobj, NULL, "touch_event");

	return;
}
static void notify_uspace_work_fn(struct work_struct *work)
{
	struct sleep_data *sleep_info = container_of(work, struct sleep_data,
			work);

	/* Notify polling threads on change of value */
	sysfs_notify(sleep_info->kobj, NULL, "timer_expired");
}
Esempio n. 20
0
/* Handle ACPI event notifications */
static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
{
	struct acpi_power_meter_resource *resource;
	int res;

	if (!device || !acpi_driver_data(device))
		return;

	resource = acpi_driver_data(device);

	mutex_lock(&resource->lock);
	switch (event) {
	case METER_NOTIFY_CONFIG:
		free_capabilities(resource);
		res = read_capabilities(resource);
		if (res)
			break;

		remove_attrs(resource);
		setup_attrs(resource);
		break;
	case METER_NOTIFY_TRIP:
		sysfs_notify(&device->dev.kobj, NULL, POWER_AVERAGE_NAME);
		update_meter(resource);
		break;
	case METER_NOTIFY_CAP:
		sysfs_notify(&device->dev.kobj, NULL, POWER_CAP_NAME);
		update_cap(resource);
		break;
	case METER_NOTIFY_INTERVAL:
		sysfs_notify(&device->dev.kobj, NULL, POWER_AVG_INTERVAL_NAME);
		update_avg_interval(resource);
		break;
	case METER_NOTIFY_CAPPING:
		sysfs_notify(&device->dev.kobj, NULL, POWER_ALARM_NAME);
		dev_info(&device->dev, "Capping in progress.\n");
		break;
	default:
		WARN(1, "Unexpected event %d\n", event);
		break;
	}
	mutex_unlock(&resource->lock);

	acpi_bus_generate_netlink_event(ACPI_POWER_METER_CLASS,
					dev_name(&device->dev), event, 0);
}
Esempio n. 21
0
static void stts751_alert(struct i2c_client *client,
			  enum i2c_alert_protocol type, unsigned int data)
{
	int ret;
	struct stts751_priv *priv = i2c_get_clientdata(client);

	if (type != I2C_PROTOCOL_SMBUS_ALERT)
		return;

	dev_dbg(&client->dev, "alert!");

	mutex_lock(&priv->access_lock);
	ret = stts751_update_alert(priv);
	if (ret < 0) {
		/* default to worst case */
		priv->max_alert = true;
		priv->min_alert = true;

		dev_warn(priv->dev,
			 "Alert received, but can't communicate to the device. Triggering all alarms!");
	}

	if (priv->max_alert) {
		if (priv->notify_max)
			dev_notice(priv->dev, "got alert for HIGH temperature");
		priv->notify_max = false;

		/* unblock alert poll */
		sysfs_notify(&priv->dev->kobj, NULL, "temp1_max_alarm");
	}

	if (priv->min_alert) {
		if (priv->notify_min)
			dev_notice(priv->dev, "got alert for LOW temperature");
		priv->notify_min = false;

		/* unblock alert poll */
		sysfs_notify(&priv->dev->kobj, NULL, "temp1_min_alarm");
	}

	if (priv->min_alert || priv->max_alert)
		kobject_uevent(&priv->dev->kobj, KOBJ_CHANGE);

	mutex_unlock(&priv->access_lock);
}
static void mmpfb_vsync_notify_work(struct work_struct *work)
{
	struct mmpfb_vsync *vsync =
		container_of(work, struct mmpfb_vsync, work);
	struct mmpfb_info *fbi =
		container_of(vsync, struct mmpfb_info, vsync);

	sysfs_notify(&fbi->dev->kobj, NULL, "vsync_ts");
}
Esempio n. 23
0
static void headphone_detect_handler(struct work_struct *work)
{
	struct imx_3stack_priv *priv = &machine_priv;
	struct platform_device *pdev = priv->pdev;
	struct wm8350 *wm8350 = priv->wm8350;

	sysfs_notify(&pdev->dev.kobj, NULL, "headphone");
	wm8350_unmask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R);
}
Esempio n. 24
0
static irqreturn_t rmidev_sysfs_irq(int irq, void *data)
{
	struct synaptics_rmi4_data *rmi4_data = data;

	sysfs_notify(&rmi4_data->input_dev->dev.kobj,
			ATTRIBUTE_FOLDER_NAME, "attn_state");

	return IRQ_HANDLED;
}
Esempio n. 25
0
static void pm2xxx_charger_ac_work(struct work_struct *work)
{
	struct pm2xxx_charger *pm2 = container_of(work,
		struct pm2xxx_charger, ac_work);


	power_supply_changed(pm2->ac_chg.psy);
	sysfs_notify(&pm2->ac_chg.psy->dev.kobj, NULL, "present");
};
Esempio n. 26
0
static int dp_altmode_configured(struct dp_altmode *dp)
{
	int ret;

	sysfs_notify(&dp->alt->dev.kobj, "displayport", "configuration");

	if (!dp->data.conf)
		return typec_altmode_notify(dp->alt, TYPEC_STATE_USB,
					    &dp->data);

	ret = dp_altmode_notify(dp);
	if (ret)
		return ret;

	sysfs_notify(&dp->alt->dev.kobj, "displayport", "pin_assignment");

	return 0;
}
Esempio n. 27
0
/* chip->mutex is kept when this is called */
static int bh1770_prox_read_result(struct bh1770_chip *chip)
{
	int ret;
	bool above;
	u8 mode;

	ret = i2c_smbus_read_byte_data(chip->client, BH1770_PS_DATA_LED1);
	if (ret < 0)
		goto out;

	if (ret > chip->prox_threshold_hw)
		above = true;
	else
		above = false;

	/*
	 * when ALS levels goes above limit, proximity result may be
	 * false proximity. Thus ignore the result. With real proximity
	 * there is a shadow causing low als levels.
	 */
	if (chip->lux_data_raw > PROX_IGNORE_LUX_LIMIT)
		ret = 0;

	chip->prox_data = bh1770_psraw_to_adjusted(chip, ret);

	/* Strong proximity level or force mode requires immediate response */
	if (chip->prox_data >= chip->prox_abs_thres ||
	    chip->prox_force_update)
		chip->prox_persistence_counter = chip->prox_persistence;

	chip->prox_force_update = false;

	/* Persistence filttering to reduce false proximity events */
	if (likely(above)) {
		if (chip->prox_persistence_counter < chip->prox_persistence) {
			chip->prox_persistence_counter++;
			ret = -ENODATA;
		} else {
			mode = PROX_ABOVE_THRESHOLD;
			ret = 0;
		}
	} else {
		chip->prox_persistence_counter = 0;
		mode = PROX_BELOW_THRESHOLD;
		chip->prox_data = 0;
		ret = 0;
	}

	/* Set proximity detection rate based on above or below value */
	if (ret == 0) {
		bh1770_prox_rate(chip, mode);
		sysfs_notify(&chip->client->dev.kobj, NULL, "prox0_raw");
	}
out:
	return ret;
}
Esempio n. 28
0
int pnpmgr_battery_charging_enabled(int charging_enabled)
{
	pr_debug("%s: result = %d\n", __func__, charging_enabled);
	if (charging_enabled_value != charging_enabled) {
		charging_enabled_value = charging_enabled;
		sysfs_notify(battery_kobj, NULL, "charging_enabled");
	}

	return 0;
}
Esempio n. 29
0
static void check_vbus_state(struct tahvo_usb *tu)
{
	int reg, prev_state;

	reg = tahvo_read_reg(TAHVO_REG_IDSR);
	if (reg & 0x01) {
		u32 l;

		vbus_active = 1;
		switch (tu->otg.state) {
		case OTG_STATE_B_IDLE:
			/* Enable the gadget driver */
			if (tu->otg.gadget)
				usb_gadget_vbus_connect(tu->otg.gadget);
			/* Set B-session valid and not B-sessio ended to indicate
			 * Vbus to be ok. */
			l = omap_readl(OTG_CTRL);
			l &= ~OTG_BSESSEND;
			l |= OTG_BSESSVLD;
			omap_writel(l, OTG_CTRL);

			tu->otg.state = OTG_STATE_B_PERIPHERAL;
			break;
		case OTG_STATE_A_IDLE:
			/* Session is now valid assuming the USB hub is driving Vbus */
			tu->otg.state = OTG_STATE_A_HOST;
			host_resume(tu);
			break;
		default:
			break;
		}
		printk("USB cable connected\n");
	} else {
		switch (tu->otg.state) {
		case OTG_STATE_B_PERIPHERAL:
			if (tu->otg.gadget)
				usb_gadget_vbus_disconnect(tu->otg.gadget);
			tu->otg.state = OTG_STATE_B_IDLE;
			break;
		case OTG_STATE_A_HOST:
			tu->otg.state = OTG_STATE_A_IDLE;
			break;
		default:
			break;
		}
		printk("USB cable disconnected\n");
		vbus_active = 0;
	}

	prev_state = tu->vbus_state;
	tu->vbus_state = reg & 0x01;
	if (prev_state != tu->vbus_state)
		sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state");
}
static void def_work_fn(struct work_struct *work)
{
	int64_t diff;

	diff = ktime_to_ns(ktime_get()) - rq_info.def_start_time;
	do_div(diff, 1000 * 1000);
	rq_info.def_interval = (unsigned int) diff;

	/* Notify polling threads on change of value */
	sysfs_notify(rq_info.kobj, NULL, "def_timer_ms");
}