Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

PMIC_STATUS pmic_event_unsubscribe ( type_event  event,
pmic_event_callback_t  callback 
)

This function is used to unsubscribe on an event.

Parameters:
event the event number to be unsubscribed
callback the callback funtion to be unsubscribed
Returns:
This function returns 0 on SUCCESS, error on FAILURE.

Definition at line 146 of file pmic_event.c.

References pmic_event_callback_list_t::callback, pmic_event_callback_t::func, pmic_event_callback_t::param, and pmic_event_mask().

Referenced by pmic_adc_deinit(), pmic_audio_deregister(), pmic_audio_set_callback(), pmic_convity_deregister_all(), pmic_convity_set_callback(), pmic_dev_ioctl(), pmic_power_event(), pmic_rtc_event(), pmic_rtc_ioctl(), and pmic_rtc_wait_alarm().

{
      struct list_head *p;
      struct list_head *n;
      pmic_event_callback_list_t *temp = NULL;
      int ret = PMIC_EVENT_NOT_SUBSCRIBED;

      pr_debug("Event:%d Unsubscribe\n", event);

      /* Check whether the event & callback are valid? */
      if (event >= PMIC_MAX_EVENTS) {
            pr_debug("Invalid Event:%d\n", event);
            return -EINVAL;
      }

      if (NULL == callback.func) {
            pr_debug("Null or Invalid Callback\n");
            return -EINVAL;
      }

      /* Obtain the lock to access the list */
      if (down_interruptible(&event_mutex)) {
            return PMIC_SYSTEM_ERROR_EINTR;
      }

      /* Find the entry in the list */
      list_for_each_safe(p, n, &pmic_events[event]) {
            temp = list_entry(p, pmic_event_callback_list_t, list);
            if (temp->callback.func == callback.func
                && temp->callback.param == callback.param) {
                  /* Remove the entry from the list */
                  list_del(p);
                  kfree(temp);
                  ret = PMIC_SUCCESS;
                  break;
            }
      }

      /* Unmask the requested event */
      if (list_empty(&pmic_events[event])) {
            if (pmic_event_mask(event) != PMIC_SUCCESS) {
                  ret = PMIC_UNSUBSCRIBE_ERROR;
            }
      }

      /* Release the lock */
      up(&event_mutex);

      return ret;
}


Generated by  Doxygen 1.6.0   Back to index