static void mtk_set_vbus(struct musb *musb, int is_on) { #ifndef CONFIG_MT6575T_FPGA DBG(0,"mt65xx_usb20_vbus++,is_on=%d\r\n",is_on); if(is_on) { //power on VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_set_opa_mode(1); fan5405_set_otg_pl(1); fan5405_set_otg_en(1); #elif defined(MTK_NCP1851_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 1); #else mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN, GPIO_OUT_ONE); #endif } else{ //power off VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_config_interface_liao(0x01,0x30); fan5405_config_interface_liao(0x02,0x8e); #elif defined(MTK_NCP1851_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 0); #else mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN, GPIO_OUT_ZERO); #endif } #endif return; }
void intel_dsi_set_drrs_state(struct intel_encoder *intel_encoder) { struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private; struct drm_display_mode *target_mode = dev_priv->drrs.connector->panel.target_mode; struct intel_mipi_drrs_work *work = dev_priv->drrs.mipi_drrs_work; unsigned int ret; ret = work_busy(&work->work.work); if (ret) { if (work->target_mode) if (work->target_mode->vrefresh == target_mode->vrefresh) { DRM_DEBUG_KMS("Repeated request for %dHz\n", target_mode->vrefresh); return; } DRM_DEBUG_KMS("Cancelling an queued/executing work\n"); atomic_set(&work->abort_wait_loop, 1); cancel_delayed_work_sync(&work->work); atomic_set(&work->abort_wait_loop, 0); if (ret & WORK_BUSY_PENDING) drm_mode_destroy(intel_encoder->base.dev, work->target_mode); } work->intel_encoder = intel_encoder; work->target_rr_type = dev_priv->drrs_state.target_rr_type; work->target_mode = drm_mode_duplicate(intel_encoder->base.dev, target_mode); schedule_delayed_work(&dev_priv->drrs.mipi_drrs_work->work, 0); }
static int ctrl_bridge_start_read(struct ctrl_bridge *dev) { int retval = 0; if (!dev->inturb) { dev_err(&dev->intf->dev, "%s: inturb is NULL\n", __func__); return -ENODEV; } if (work_busy(&dev->get_encap_work)) { pr_info("work busy, passthrough"); return 0; } if (!dev->inturb->anchor) { usb_anchor_urb(dev->inturb, &dev->tx_submitted); retval = usb_submit_urb(dev->inturb, GFP_KERNEL); if (retval < 0) { dev_err(&dev->intf->dev, "%s error submitting int urb %d\n", __func__, retval); usb_unanchor_urb(dev->inturb); } } return retval; }
static void mtk_set_vbus(struct musb *musb, int is_on) { DBG(0,"mt65xx_usb20_vbus++,is_on=%d\r\n",is_on); #ifndef CONFIG_MT6589_FPGA if(is_on){ //power on VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_set_opa_mode(1); fan5405_set_otg_pl(1); fan5405_set_otg_en(1); #elif defined(MTK_BQ24158_SUPPORT) bq24158_set_opa_mode(1); bq24158_set_otg_pl(1); bq24158_set_otg_en(1); //<2013/1/21-20645-jessicatseng, [Pelican] Intrgrate charging IC BQ24157 for PRE-MP SW #elif defined(MTK_BQ24157_SUPPORT) bq24157_set_opa_mode(1); bq24157_set_otg_pl(1); bq24157_set_otg_en(1); //>2013/1/21-20645-jessicatseng #elif defined(MTK_NCP1851_SUPPORT) || defined(MTK_BQ24196_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 1); #else mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN,GPIO_OUT_ONE); #endif } else { //power off VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_config_interface_liao(0x01,0x30); fan5405_config_interface_liao(0x02,0x8e); #elif defined(MTK_BQ24158_SUPPORT) bq24158_config_interface_reg(0x01,0x30); bq24158_config_interface_reg(0x02,0x8e); //<2013/1/21-20645-jessicatseng, [Pelican] Intrgrate charging IC BQ24157 for PRE-MP SW #elif defined(MTK_BQ24157_SUPPORT) bq24157_config_interface_liao(0x01,0x30); bq24157_config_interface_liao(0x02,0x8e); //>2013/1/21-20645-jessicatseng #elif defined(MTK_NCP1851_SUPPORT) || defined(MTK_BQ24196_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 0); #else mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN,GPIO_OUT_ZERO); #endif } #endif return; }
void mt_usb_set_vbus(struct musb *musb, int is_on) { DBG(0,"mt65xx_usb20_vbus++,is_on=%d\r\n",is_on); #ifndef FPGA_PLATFORM if(is_on){ //power on VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_set_opa_mode(1); fan5405_set_otg_pl(1); fan5405_set_otg_en(1); #elif defined(MTK_BQ24157_SUPPORT) bq24157_set_opa_mode(1); bq24157_set_otg_pl(1); bq24157_set_otg_en(1); #elif defined(MTK_BQ24158_SUPPORT) bq24158_set_opa_mode(1); bq24158_set_otg_pl(1); bq24158_set_otg_en(1); #elif defined(MTK_NCP1851_SUPPORT) || defined(MTK_BQ24196_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 1); #else mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN,GPIO_OTG_DRVVBUS_PIN_M_GPIO); mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN,GPIO_OUT_ONE); #endif } else { //power off VBUS, implement later... #ifdef MTK_FAN5405_SUPPORT fan5405_config_interface_liao(0x01,0x30); fan5405_config_interface_liao(0x02,0x8e); #elif defined(MTK_BQ24157_SUPPORT) bq24157_config_interface_liao(0x01,0x30); bq24157_config_interface_liao(0x02,0x8e); #elif defined(MTK_BQ24158_SUPPORT) bq24158_config_interface_liao(0x01,0x30); bq24158_config_interface_liao(0x02,0x8e); #elif defined(MTK_NCP1851_SUPPORT) || defined(MTK_BQ24196_SUPPORT) tbl_charger_otg_vbus((work_busy(&musb->id_pin_work.work)<< 8)| 0); #else mt_set_gpio_mode(GPIO_OTG_DRVVBUS_PIN,GPIO_OTG_DRVVBUS_PIN_M_GPIO); mt_set_gpio_out(GPIO_OTG_DRVVBUS_PIN,GPIO_OUT_ZERO); #endif } #endif }
int rmnet_usb_ctrl_suspend(struct rmnet_ctrl_dev *dev) { int ret = 0; ret = work_busy(&dev->get_encap_work); if (ret) return -EBUSY; usb_kill_anchored_urbs(&dev->rx_submitted); return 0; }
static int rmnet_usb_suspend(struct usb_interface *iface, pm_message_t message) { struct usbnet *unet = usb_get_intfdata(iface); struct rmnet_ctrl_udev *dev; dev = (struct rmnet_ctrl_udev *)unet->data[1]; if (work_busy(&dev->get_encap_work)) return -EBUSY; usb_kill_anchored_urbs(&dev->rx_submitted); if (work_busy(&dev->get_encap_work)) return -EBUSY; if (usbnet_suspend(iface, message)) { rmnet_usb_ctrl_start_rx(dev); return -EBUSY; } return 0; }
static bool suspend_sync(void) { if (work_busy(&suspend_sync_work)) { /* When last sys_sync() work is still running, * we need wait for it to be finished. */ if (!check_sys_sync()) return false; } INIT_COMPLETION(suspend_sync_complete); schedule_work(&suspend_sync_work); return check_sys_sync(); }
int ctrl_bridge_suspend(unsigned int id) { struct ctrl_bridge *dev; if (id >= MAX_BRIDGE_DEVICES) return -EINVAL; dev = __dev[id]; if (!dev) return -ENODEV; if (work_busy(&dev->get_encap_work)) return -EBUSY; set_bit(SUSPENDED, &dev->flags); usb_kill_anchored_urbs(&dev->tx_submitted); return 0; }
static int rmnet_usb_resume(struct usb_interface *iface) { int retval = 0; struct usbnet *unet; struct rmnet_ctrl_dev *dev; pr_debug("%s", __func__); unet = usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; usbnet_resume(iface); if (work_busy(&dev->get_encap_work)) { pr_debug("%s ret", __func__); return 0; } retval = rmnet_usb_ctrl_start_rx(dev); return retval; }
static int rmnet_usb_suspend(struct usb_interface *iface, pm_message_t message) { struct usbnet *unet; struct rmnet_ctrl_dev *dev; pr_debug("%s", __func__); unet = usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; if (work_busy(&dev->get_encap_work)) return -EBUSY; if (usbnet_suspend(iface, message)) return -EBUSY; usb_kill_anchored_urbs(&dev->rx_submitted); return 0; }
static int rmnet_usb_suspend(struct usb_interface *iface, pm_message_t message) { struct usbnet *unet; struct rmnet_ctrl_dev *dev; char *suspended[2] = {"QMI_STATE=SUSPENDED", NULL}; unet = usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; if (work_busy(&dev->get_encap_work)) return -EBUSY; if (usbnet_suspend(iface, message)) return -EBUSY; usb_kill_anchored_urbs(&dev->rx_submitted); kobject_uevent_env(&dev->devicep->kobj, KOBJ_CHANGE, suspended); return 0; }
static int mbox_debugfs_msg_send(int index, mbox_msg_t *msg, mbox_msg_len_t len) { if ((index > DEBUGFS_MBOXES_NUM) || (index < 1)) { pr_err("mailbox debugfs index %d error\n", index); return -EINVAL; } if (!debugfs_mboxes[index - 1].mbox) { pr_err("mailbox-%d debugfs no such mbox\n", index); return -EINVAL; } debugfs_mboxes[index - 1].msg = kmalloc(sizeof(mbox_msg_t) * len, GFP_KERNEL); if (!debugfs_mboxes[index - 1].msg) { pr_err("mailbox-%d debugfs no mem\n", index); return -ENOMEM; } memcpy(debugfs_mboxes[index - 1].msg, msg, sizeof(mbox_msg_t) * len); debugfs_mboxes[index - 1].len = len; debugfs_mboxes[index - 1].index = index; if (!debugfs_mboxes[index - 1].initialized) { INIT_WORK(&debugfs_mboxes[index - 1].work, mbox_debugfs_send_work); debugfs_mboxes[index - 1].initialized = 1; } else { pr_err("mailbox-%d debugfs has initialize its work\n", index); } if (!work_busy(&debugfs_mboxes[index - 1].work)) schedule_work(&debugfs_mboxes[index - 1].work); else pr_err("mailbox-%d debugfs work busy, wait a moment\n", index); return 0; }
static int rmnet_usb_suspend(struct usb_interface *iface, pm_message_t message) { struct usbnet *unet = usb_get_intfdata(iface); struct rmnet_ctrl_dev *dev; int i, n, rdev_cnt, unet_id; int retval = 0; rdev_cnt = unet->data[4] ? no_rmnet_insts_per_dev : 1; for (n = 0; n < rdev_cnt; n++) { unet_id = n + unet->driver_info->data * no_rmnet_insts_per_dev; unet = unet->data[4] ? unet_list[unet_id] : usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; spin_lock_irq(&unet->txq.lock); if (work_busy(&dev->get_encap_work) || unet->txq.qlen) { spin_unlock_irq(&unet->txq.lock); retval = -EBUSY; goto abort_suspend; } set_bit(EVENT_DEV_ASLEEP, &unet->flags); spin_unlock_irq(&unet->txq.lock); usb_kill_anchored_urbs(&dev->rx_submitted); if (work_busy(&dev->get_encap_work)) { spin_lock_irq(&unet->txq.lock); clear_bit(EVENT_DEV_ASLEEP, &unet->flags); spin_unlock_irq(&unet->txq.lock); retval = -EBUSY; goto abort_suspend; } } for (n = 0; n < rdev_cnt; n++) { unet_id = n + unet->driver_info->data * no_rmnet_insts_per_dev; unet = unet->data[4] ? unet_list[unet_id] : usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; netif_device_detach(unet->net); usbnet_terminate_urbs(unet); netif_device_attach(unet->net); } #if defined(CONFIG_MONITOR_STREAMING_PORT_SOCKET) && defined(CONFIG_MSM_NONSMD_PACKET_FILTER) if (use_extend_suspend_timer) { if (original_autosuspend_timer != 0) { struct usb_device *udev= unet->udev; if (udev) { use_extend_suspend_timer= false; pm_runtime_set_autosuspend_delay(&udev->dev, original_autosuspend_timer); dev_err(&udev->dev, "is_streaming_sock_connectted:%d pm_runtime_set_autosuspend_delay %d\n", is_streaming_sock_connectted, original_autosuspend_timer); } } } #endif return 0; abort_suspend: for (i = 0; i < n; i++) { unet_id = i + unet->driver_info->data * no_rmnet_insts_per_dev; unet = unet->data[4] ? unet_list[unet_id] : usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; rmnet_usb_ctrl_start_rx(dev); spin_lock_irq(&unet->txq.lock); clear_bit(EVENT_DEV_ASLEEP, &unet->flags); spin_unlock_irq(&unet->txq.lock); } return retval; }
/** * dwc3_ext_event_notify - callback to handle events from external transceiver * @otg: Pointer to the otg transceiver structure * @event: Event reported by transceiver * * Returns 0 on success */ static void dwc3_ext_event_notify(struct usb_otg *otg, enum dwc3_ext_events event) { static bool init; struct dwc3_otg *dotg = container_of(otg, struct dwc3_otg, otg); struct dwc3_ext_xceiv *ext_xceiv = dotg->ext_xceiv; struct usb_phy *phy = dotg->otg.phy; int ret = 0; /* Flush processing any pending events before handling new ones */ if (init) flush_delayed_work(&dotg->sm_work); if (event == DWC3_EVENT_PHY_RESUME) { if (!pm_runtime_status_suspended(phy->dev)) { dev_warn(phy->dev, "PHY_RESUME event out of LPM!!!!\n"); } else { dev_dbg(phy->dev, "ext PHY_RESUME event received\n"); /* ext_xceiver would have taken h/w out of LPM by now */ ret = pm_runtime_get(phy->dev); if ((phy->state == OTG_STATE_A_HOST) && dotg->host_bus_suspend) dotg->host_bus_suspend = 0; if (ret == -EACCES) { /* pm_runtime_get may fail during system resume with -EACCES error */ pm_runtime_disable(phy->dev); pm_runtime_set_active(phy->dev); pm_runtime_enable(phy->dev); } else if (ret < 0) { dev_warn(phy->dev, "pm_runtime_get failed!\n"); } } } else if (event == DWC3_EVENT_XCEIV_STATE) { if (pm_runtime_status_suspended(phy->dev)) { dev_warn(phy->dev, "PHY_STATE event in LPM!!!!\n"); ret = pm_runtime_get(phy->dev); if (ret < 0) dev_warn(phy->dev, "pm_runtime_get failed!!\n"); } if (ext_xceiv->id == DWC3_ID_FLOAT) { dev_dbg(phy->dev, "XCVR: ID set\n"); set_bit(ID, &dotg->inputs); } else { dev_dbg(phy->dev, "XCVR: ID clear\n"); clear_bit(ID, &dotg->inputs); } if (ext_xceiv->bsv) { dev_dbg(phy->dev, "XCVR: BSV set\n"); set_bit(B_SESS_VLD, &dotg->inputs); } else { dev_dbg(phy->dev, "XCVR: BSV clear\n"); clear_bit(B_SESS_VLD, &dotg->inputs); } if (!init) { init = true; if (!work_busy(&dotg->sm_work.work)) queue_delayed_work(system_nrt_wq, &dotg->sm_work, 0); complete(&dotg->dwc3_xcvr_vbus_init); dev_dbg(phy->dev, "XCVR: BSV init complete\n"); return; } queue_delayed_work(system_nrt_wq, &dotg->sm_work, 0); } }
static int rmnet_usb_suspend(struct usb_interface *iface, pm_message_t message) { struct usbnet *unet = usb_get_intfdata(iface); struct rmnet_ctrl_dev *dev; int i, n, rdev_cnt, unet_id; int retval = 0; rdev_cnt = unet->data[4] ? no_rmnet_insts_per_dev : 1; for (n = 0; n < rdev_cnt; n++) { unet_id = n + unet->driver_info->data * no_rmnet_insts_per_dev; unet = unet->data[4] ? unet_list[unet_id] : usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; spin_lock_irq(&unet->txq.lock); if (work_busy(&dev->get_encap_work) || unet->txq.qlen) { spin_unlock_irq(&unet->txq.lock); retval = -EBUSY; goto abort_suspend; } set_bit(EVENT_DEV_ASLEEP, &unet->flags); spin_unlock_irq(&unet->txq.lock); usb_kill_anchored_urbs(&dev->rx_submitted); if (work_busy(&dev->get_encap_work)) { spin_lock_irq(&unet->txq.lock); clear_bit(EVENT_DEV_ASLEEP, &unet->flags); spin_unlock_irq(&unet->txq.lock); retval = -EBUSY; goto abort_suspend; } } for (n = 0; n < rdev_cnt; n++) { unet_id = n + unet->driver_info->data * no_rmnet_insts_per_dev; unet = unet->data[4] ? unet_list[unet_id] : usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; netif_device_detach(unet->net); usbnet_terminate_urbs(unet); netif_device_attach(unet->net); } return 0; abort_suspend: for (i = 0; i < n; i++) { unet_id = i + unet->driver_info->data * no_rmnet_insts_per_dev; unet = unet->data[4] ? unet_list[unet_id] : usb_get_intfdata(iface); dev = (struct rmnet_ctrl_dev *)unet->data[1]; rmnet_usb_ctrl_start_rx(dev); spin_lock_irq(&unet->txq.lock); clear_bit(EVENT_DEV_ASLEEP, &unet->flags); spin_unlock_irq(&unet->txq.lock); } return retval; }
static unsigned int mmc_host_work_busy(struct work_struct *work) { return work_busy(work); }
static enum hrtimer_restart ev3_output_port_timer_callback(struct hrtimer *timer) { struct ev3_output_port_data *data = container_of(timer, struct ev3_output_port_data, timer); enum motor_type prev_motor_type = data->motor_type; unsigned new_pin_state_flags = 0; unsigned new_pin5_mv = 0; hrtimer_forward_now(timer, ktime_set(0, OUTPUT_PORT_POLL_NS)); data->timer_loop_cnt++; switch(data->con_state) { case CON_STATE_INIT: if (!data->motor) { ev3_output_port_float(data); data->timer_loop_cnt = 0; data->motor_type = MOTOR_NONE; data->con_state = CON_STATE_INIT_SETTLE; } break; case CON_STATE_INIT_SETTLE: if (data->timer_loop_cnt >= SETTLE_CNT) { data->timer_loop_cnt = 0; data->con_state = CON_STATE_NO_DEV; } break; case CON_STATE_NO_DEV: new_pin5_mv = legoev3_analog_out_pin5_value(data->analog, data->id); if (gpio_get_value(data->gpio[GPIO_PIN6_DIR].gpio)) new_pin_state_flags |= BIT(PIN_STATE_FLAG_PIN6_HIGH); if ((new_pin5_mv < PIN5_BALANCE_LOW) || (new_pin5_mv > PIN5_BALANCE_HIGH)) new_pin_state_flags |= BIT(PIN_STATE_FLAG_PIN5_LOADED); if (new_pin_state_flags != data->pin_state_flags) { data->pin_state_flags = new_pin_state_flags; data->timer_loop_cnt = 0; } if (data->pin_state_flags && (data->timer_loop_cnt >= ADD_CNT)) { data->pin5_float_mv = new_pin5_mv; data->timer_loop_cnt = 0; gpio_direction_output(data->gpio[GPIO_PIN6_DIR].gpio, 0); data->con_state = CON_STATE_PIN6_SETTLE; } break; case CON_STATE_PIN6_SETTLE: new_pin5_mv = legoev3_analog_out_pin5_value(data->analog, data->id); if (data->timer_loop_cnt >= SETTLE_CNT) { data->pin5_low_mv = new_pin5_mv; data->timer_loop_cnt = 0; gpio_direction_input(data->gpio[GPIO_PIN6_DIR].gpio); data->con_state = CON_STATE_CONNECTED; } break; case CON_STATE_CONNECTED: /* * Make a temporary variable that we can use to determine the relative * difference between pin5_float_mv and pin5_low_mv */ new_pin5_mv = ADC_REF + data->pin5_float_mv - data->pin5_low_mv; if ((new_pin5_mv > (ADC_REF - 50)) && (new_pin5_mv < (ADC_REF + 50))) { // The pin5 values are the same, let's see what we have! if ((data->pin5_float_mv >= PIN5_BALANCE_LOW) && (data->pin5_float_mv <= PIN5_BALANCE_HIGH) && (data->pin_state_flags & (0x01 << PIN_STATE_FLAG_PIN6_HIGH))) { /* NXT TOUCH SENSOR, NXT SOUND SENSOR or NEW UART SENSOR */ data->motor_type = MOTOR_ERR; data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } else if (data->pin5_float_mv < PIN5_NEAR_GND) { /* NEW DUMB SENSOR */ data->motor_type = MOTOR_ERR; data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } else if ((data->pin5_float_mv >= PIN5_LIGHT_LOW) && (data->pin5_float_mv <= PIN5_LIGHT_HIGH)) { /* NXT LIGHT SENSOR */ data->motor_type = MOTOR_ERR; data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } else if ((data->pin5_float_mv >= PIN5_IIC_LOW) && (data->pin5_float_mv <= PIN5_IIC_HIGH)) { /* NXT IIC SENSOR */ data->motor_type = MOTOR_ERR; data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } else if (data->pin5_float_mv < PIN5_BALANCE_LOW) { data->motor_type = MOTOR_TACHO; if (data->pin5_float_mv > PIN5_MINITACHO_HIGH2) { data->motor_id = LEGO_EV3_LARGE_MOTOR; } else if (data->pin5_float_mv > PIN5_MINITACHO_LOW2) { data->motor_id = LEGO_EV3_MEDIUM_MOTOR; } else { data->motor_id = LEGO_EV3_LARGE_MOTOR; } data->con_state = CON_STATE_DEVICE_CONNECTED; } else { gpio_direction_output(data->gpio[GPIO_PIN5].gpio, 1); data->timer_loop_cnt = 0; data->con_state = CON_STATE_PIN5_SETTLE; } /* Value5Float is NOT equal to Value5Low */ } else if ((data->pin5_float_mv > PIN5_NEAR_GND) && (data->pin5_float_mv < PIN5_BALANCE_LOW)) { /* NEW ACTUATOR */ data->motor_type = MOTOR_ERR; data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } else { data->motor_type = MOTOR_ERR; data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } break; case CON_STATE_PIN5_SETTLE: /* Update connection type, may need to force pin5 low to determine motor type */ if (data->timer_loop_cnt >= SETTLE_CNT) { data->pin5_low_mv = legoev3_analog_out_pin5_value(data->analog, data->id); data->timer_loop_cnt = 0; gpio_direction_output(data->gpio[GPIO_PIN5].gpio, 0); if (data->pin5_low_mv < PIN5_MINITACHO_LOW1) { data->motor_type = MOTOR_ERR; } else { data->motor_type = MOTOR_TACHO; if (data->pin5_low_mv < PIN5_MINITACHO_HIGH1) data->motor_id = LEGO_EV3_MEDIUM_MOTOR; else data->motor_id = LEGO_EV3_LARGE_MOTOR; } data->con_state = CON_STATE_DEVICE_CONNECTED; } break; case CON_STATE_DEVICE_CONNECTED: data->timer_loop_cnt = 0; if (data->motor_type != MOTOR_ERR && !work_busy(&data->work)) { INIT_WORK(&data->work, ev3_output_port_register_motor); schedule_work(&data->work); data->con_state = CON_STATE_WAITING_FOR_DISCONNECT; } break; case CON_STATE_WAITING_FOR_DISCONNECT: new_pin5_mv = legoev3_analog_out_pin5_value(data->analog, data->id); if ((new_pin5_mv < PIN5_BALANCE_LOW) || (new_pin5_mv > PIN5_BALANCE_HIGH)) data->timer_loop_cnt = 0; if ((data->timer_loop_cnt >= REMOVE_CNT) && !work_busy(&data->work) && data) { INIT_WORK(&data->work, ev3_output_port_unregister_motor); schedule_work(&data->work); data->con_state = CON_STATE_INIT; } break; default: data->con_state = CON_STATE_INIT; break; } /* * data->tacho_motor_type determines the status for the lego-port class * so we need to trigger a change uevent when it changes. */ if (prev_motor_type != data->motor_type) schedule_work(&data->change_uevent_work); return HRTIMER_RESTART; }
static void sec_esd_work_func(struct work_struct *work) { #if defined(CONFIG_FB_MSM_MIPI_NOVATEK_VIDEO_HD_PT_PANEL) #define LCD_ESD_GPIO_CHECK_DELAY 300 int gpio_value = 0; #endif struct esd_data_t *p_esd_data = container_of(work, struct esd_data_t, det_work); p_esd_data->esd_count++; if (p_esd_data->esd_count <= ESD_EXCEPT_CNT) pr_info("%s : %d ignore Cnt(%d)\n", __func__, p_esd_data->esd_count, ESD_EXCEPT_CNT); else if (p_esd_data->esd_ignore) pr_info("%s : %d ignore FLAG,esd_processed:%d\n", __func__, p_esd_data->esd_count, p_esd_data->esd_processed_count); else { #if defined(CONFIG_FB_MSM_MIPI_NOVATEK_VIDEO_HD_PT_PANEL) gpio_value = gpio_get_value(GPIO_LCD_ESD_DET); pr_info("%s : GPIO_LCD_ESD_DET :%d\n",__func__, gpio_value); msleep(LCD_ESD_GPIO_CHECK_DELAY); gpio_value = gpio_get_value(GPIO_LCD_ESD_DET); pr_info("%s : GPIO_LCD_ESD_DET :%d After Delay %d ms \n",__func__, gpio_value,LCD_ESD_GPIO_CHECK_DELAY); #if defined(CONFIG_MACH_MELIUS_SPR) if(system_rev >= 3) { #elif defined(CONFIG_MACH_MELIUS_USC) if(system_rev >= 2) { #else if(system_rev >= 11) { #endif if(gpio_value) lcd_esd_seq(p_esd_data); } else { if(!gpio_value) lcd_esd_seq(p_esd_data); } #else lcd_esd_seq(p_esd_data); #endif } p_esd_data->esd_irq_enable = true; return; } #ifdef ESD_DEBUG static ssize_t mipi_samsung_esd_check_show(struct device *dev, struct device_attribute *attr, char *buf) { struct esd_data_t *p_esd_data = dev_get_drvdata(dev); char temp[20]; snprintf(temp, 20, "ESD Status:%d\n", p_esd_data->refresh_ongoing); strncat(buf, temp, 20); return strnlen(buf, 20); } static ssize_t mipi_samsung_esd_check_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct esd_data_t *p_esd_data = dev_get_drvdata(dev); sec_esd_irq_handler(0, p_esd_data); return 1; } static DEVICE_ATTR(esd_check, S_IRUGO , mipi_samsung_esd_check_show,\ mipi_samsung_esd_check_store); #endif static irqreturn_t sec_esd_irq_handler(int irq, void *handle) { struct esd_data_t *p_esd_data = (struct esd_data_t *) handle; struct msm_fb_data_type *mfd; if (!mipi_control.mipi_dev) return IRQ_HANDLED; else mfd = platform_get_drvdata(mipi_control.mipi_dev); if (!mfd->panel_power_on || p_esd_data->refresh_ongoing || p_esd_data->esd_irq_enable == false) { /* Panel is not powered ON So bogus ESD/ ESD Already executing*/ return IRQ_HANDLED; } #if defined(CONFIG_FB_MSM_MIPI_NOVATEK_VIDEO_HD_PT_PANEL) /* ESD occurred during Wakeup/Suspend, So ignore */ if (mfd->resume_state) return IRQ_HANDLED; #endif p_esd_data->esd_irq_enable = false; schedule_work(&p_esd_data->det_work); return IRQ_HANDLED; } #ifdef READ_REGISTER_ESD void esd_execute(void) { if (esd_enable->esd_irq_enable) { if (work_busy(&esd_enable->det_work)) pr_info("%s ESD work queue is working", __func__); else { pr_info("%s start", __func__); INIT_COMPLETION(esd_completion); schedule_work(&esd_enable->det_work); wait_for_completion_timeout(&esd_completion, 10 * HZ); pr_info("%s end", __func__); } } else pr_info("%s ESD is armed from ISR", __func__); } #endif void register_mipi_dev(struct platform_device *mipi_dev) { mipi_control.mipi_dev = mipi_dev; } static void set_esd_enable_work_func(struct work_struct *work) { pr_info("%s is called\n", __func__); esd_enable->esd_ignore = false; } void set_esd_enable(void) { pr_info("%s is called\n", __func__); if (!esd_enable) { pr_err("ESD Driver data is NULL!!\n"); return; } #if defined(CONFIG_FB_MSM_MIPI_NOVATEK_VIDEO_HD_PT_PANEL) schedule_delayed_work(&esd_enable->esd_enable_delay,\ msecs_to_jiffies(100)); #else schedule_delayed_work(&esd_enable->esd_enable_delay,\ msecs_to_jiffies(500)); #endif }
* dump debugging info about an object */ static noinline void __cachefiles_printk_object(struct cachefiles_object *object, const char *prefix, u8 *keybuf) { struct fscache_cookie *cookie; unsigned keylen, loop; printk(KERN_ERR "%sobject: OBJ%x\n", prefix, object->fscache.debug_id); <<<<<<< HEAD printk(KERN_ERR "%sobjstate=%s fl=%lx wbusy=%x ev=%lx[%lx]\n", prefix, fscache_object_states[object->fscache.state], object->fscache.flags, work_busy(&object->fscache.work), ======= printk(KERN_ERR "%sobjstate=%s fl=%lx swfl=%lx ev=%lx[%lx]\n", prefix, fscache_object_states[object->fscache.state], object->fscache.flags, object->fscache.work.flags, >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a object->fscache.events, object->fscache.event_mask & FSCACHE_OBJECT_EVENTS_MASK); printk(KERN_ERR "%sops=%u inp=%u exc=%u\n", prefix, object->fscache.n_ops, object->fscache.n_in_progress, object->fscache.n_exclusive); printk(KERN_ERR "%sparent=%p\n", prefix, object->fscache.parent); spin_lock(&object->fscache.lock); cookie = object->fscache.cookie;
static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, unsigned char __user *buf, size_t nr) { unsigned char __user *b = buf; DECLARE_WAITQUEUE(wait, current); int c; int minimum, time; ssize_t retval = 0; ssize_t size; long timeout; unsigned long flags; int packet; struct tty_buffer *head; int count; do_it_again: if (WARN_ON(!tty->read_buf)) return -EAGAIN; c = job_control(tty, file); if (c < 0) return c; minimum = time = 0; timeout = MAX_SCHEDULE_TIMEOUT; if (!tty->icanon) { time = (HZ / 10) * TIME_CHAR(tty); minimum = MIN_CHAR(tty); if (minimum) { if (time) tty->minimum_to_wake = 1; else if (!waitqueue_active(&tty->read_wait) || (tty->minimum_to_wake > minimum)) tty->minimum_to_wake = minimum; } else { timeout = 0; if (time) { timeout = time; time = 0; } tty->minimum_to_wake = minimum = 1; } } if (file->f_flags & O_NONBLOCK) { if (!mutex_trylock(&tty->atomic_read_lock)) return -EAGAIN; } else { if (mutex_lock_interruptible(&tty->atomic_read_lock)) return -ERESTARTSYS; } packet = tty->packet; add_wait_queue(&tty->read_wait, &wait); while (nr) { if (packet && tty->link->ctrl_status) { unsigned char cs; if (b != buf) break; spin_lock_irqsave(&tty->link->ctrl_lock, flags); cs = tty->link->ctrl_status; tty->link->ctrl_status = 0; spin_unlock_irqrestore(&tty->link->ctrl_lock, flags); if (tty_put_user(tty, cs, b++)) { retval = -EFAULT; b--; break; } nr--; break; } set_current_state(TASK_INTERRUPTIBLE); if (((minimum - (b - buf)) < tty->minimum_to_wake) && ((minimum - (b - buf)) >= 1)) tty->minimum_to_wake = (minimum - (b - buf)); if (!input_available_p(tty, 0)) { if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { retval = -EIO; break; } if (tty_hung_up_p(file)) break; if (!timeout) break; if (file->f_flags & O_NONBLOCK) { retval = -EAGAIN; break; } if (signal_pending(current)) { retval = -ERESTARTSYS; break; } n_tty_set_room(tty); timeout = schedule_timeout(timeout); BUG_ON(!tty->read_buf); continue; } __set_current_state(TASK_RUNNING); if (packet && b == buf) { if (tty_put_user(tty, TIOCPKT_DATA, b++)) { retval = -EFAULT; b--; break; } nr--; } if (tty->icanon && !L_EXTPROC(tty)) { while (nr && tty->read_cnt) { int eol; eol = test_and_clear_bit(tty->read_tail, tty->read_flags); c = tty->read_buf[tty->read_tail]; spin_lock_irqsave(&tty->read_lock, flags); tty->read_tail = ((tty->read_tail+1) & (N_TTY_BUF_SIZE-1)); tty->read_cnt--; if (eol) { if (--tty->canon_data < 0) tty->canon_data = 0; } spin_unlock_irqrestore(&tty->read_lock, flags); if (!eol || (c != __DISABLED_CHAR)) { if (tty_put_user(tty, c, b++)) { retval = -EFAULT; b--; break; } nr--; } if (eol) { tty_audit_push(tty); break; } } if (retval) break; } else { int uncopied; uncopied = copy_from_read_buf(tty, &b, &nr); uncopied += copy_from_read_buf(tty, &b, &nr); if (uncopied) { retval = -EFAULT; break; } } if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) { n_tty_set_room(tty); check_unthrottle(tty); } if (b - buf >= minimum) break; if (time) timeout = time; } mutex_unlock(&tty->atomic_read_lock); remove_wait_queue(&tty->read_wait, &wait); if (!waitqueue_active(&tty->read_wait)) tty->minimum_to_wake = minimum; __set_current_state(TASK_RUNNING); size = b - buf; if (size) { retval = size; if (nr) clear_bit(TTY_PUSH, &tty->flags); } else if (test_and_clear_bit(TTY_PUSH, &tty->flags)) goto do_it_again; n_tty_set_room(tty); if(tty->update_room_in_ldisc){ spin_lock_irqsave(&tty->buf.lock, flags); head = tty->buf.head; if (head) { count = head->commit - head->read; if ((count || tty->buf.head != tty->buf.tail) && tty->receive_room && !work_busy(&tty->buf.work)){ schedule_work(&tty->buf.work); } } spin_unlock_irqrestore(&tty->buf.lock, flags); } return retval; }