static void tda19988_blk_other(message * m, int ipc_status) { log_trace(&log, "tda19988_blk_other(0x%x)\n", m->m_type); if (is_ipc_notify(ipc_status)) { if (m->m_source == DS_PROC_NR) { log_debug(&log, "bus driver changed state, update endpoint\n"); i2cdriver_handle_bus_update(&cec_bus_endpoint, cec_bus, cec_address); i2cdriver_handle_bus_update(&hdmi_bus_endpoint, hdmi_bus, hdmi_address); } } else { log_warn(&log, "Invalid message type (0x%x)\n", m->m_type); } }
int main(int argc, char *argv[]) { int r, i; struct tm t; endpoint_t user, caller; message m; int ipc_status, reply_status; env_setargs(argc, argv); r = i2cdriver_env_parse(&bus, &addresses[0], valid_addrs); if (r < 0) { log_warn(&log, "Expecting -args 'bus=X address=0xYY'\n"); log_warn(&log, "Example -args 'bus=1 address=0x48'\n"); return EXIT_FAILURE; } else if (r > 0) { log_warn(&log, "Invalid slave address for device, expecting 0x48\n"); return EXIT_FAILURE; } sef_local_startup(); while (TRUE) { /* Receive Message */ r = sef_receive_status(ANY, &m, &ipc_status); if (r != OK) { log_warn(&log, "sef_receive_status() failed\n"); continue; } if (is_ipc_notify(ipc_status)) { if (m.m_source == DS_PROC_NR) { for (i = 0; i < NADDRESSES; i++) { /* changed state, update endpoint */ i2cdriver_handle_bus_update (&bus_endpoint, bus, addresses[i]); } } /* Do not reply to notifications. */ continue; } caller = m.m_source; log_debug(&log, "Got message 0x%x from 0x%x\n", m.m_type, caller); switch (m.m_type) { case RTCDEV_GET_TIME_G: /* Any user can read the time */ reply_status = rtc_get_time(&t, m.RTCDEV_FLAGS); if (reply_status != OK) { break; } /* write results back to calling process */ reply_status = store_t(caller, (cp_grant_id_t) m.RTCDEV_GRANT, &t); break; case RTCDEV_SET_TIME_G: /* Only super user is allowed to set the time */ if (getnuid(caller) == SUPER_USER) { /* read time from calling process */ reply_status = fetch_t(caller, (cp_grant_id_t) m.RTCDEV_GRANT, &t); if (reply_status != OK) { break; } reply_status = rtc_set_time(&t, m.RTCDEV_FLAGS); } else { reply_status = EPERM; } break; case RTCDEV_PWR_OFF: reply_status = ENOSYS; break; default: /* Unrecognized call */ reply_status = EINVAL; break; } /* Send Reply */ m.m_type = RTCDEV_REPLY; m.RTCDEV_STATUS = reply_status; log_debug(&log, "Sending Reply"); r = sendnb(caller, &m); if (r != OK) { log_warn(&log, "sendnb() failed\n"); continue; } } rtc_exit(); return 0; }
int main(int argc, char *argv[]) { int r; endpoint_t user, caller; message m; int ipc_status; env_setargs(argc, argv); r = i2cdriver_env_parse(&bus, &address, valid_addrs); if (r < 0) { log_warn(&log, "Expecting -args 'bus=X address=0xYY'\n"); log_warn(&log, "Example -args 'bus=1 address=0x24'\n"); return EXIT_FAILURE; } else if (r > 0) { log_warn(&log, "Invalid slave address for device, expecting 0x24\n"); return EXIT_FAILURE; } sef_local_startup(); while (TRUE) { /* Receive Message */ r = sef_receive_status(ANY, &m, &ipc_status); if (r != OK) { log_warn(&log, "sef_receive_status() failed\n"); continue; } log_trace(&log, "Got a message 0x%x from 0x%x\n", m.m_type, m.m_source); if (is_ipc_notify(ipc_status)) { switch (m.m_source) { case DS_PROC_NR: /* bus driver changed state, update endpoint */ i2cdriver_handle_bus_update(&bus_endpoint, bus, address); break; case HARDWARE: intr_handler(); break; default: break; } /* Do not reply to notifications. */ continue; } caller = m.m_source; user = m.USER_ENDPT; /* * Handle Message * * So far this driver only deals with notifications * so it always replies to non-notifications with EINVAL. */ /* Send Reply */ m.m_type = TASK_REPLY; m.REP_ENDPT = user; m.REP_STATUS = EINVAL; r = sendnb(caller, &m); if (r != OK) { log_warn(&log, "sendnb() failed\n"); continue; } } return 0; }