/* * cn_test.c * * 2004 Copyright (c) Evgeniy Polyakov * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "connector.h" static struct cb_id cn_test_id = { 0x123, 0x456 }; static char cn_test_name[] = "cn_test"; void cn_test_callback(void *data) { struct cn_msg *msg = (struct cn_msg *)data; printk("%s: idx=%x, val=%x, len=%d.\n", __func__, msg->id.idx, msg->id.val, msg->len); } static int cn_test_init(void) { int err; err = cn_add_callback(&cn_test_id, cn_test_name, cn_test_callback); if (err) return err; cn_test_id.val++; err = cn_add_callback(&cn_test_id, cn_test_name, cn_test_callback); if (err) { cn_del_callback(&cn_test_id); return err; } return 0; } static void cn_test_fini(void) { cn_del_callback(&cn_test_id); cn_test_id.val--; cn_del_callback(&cn_test_id); } module_init(cn_test_init); module_exit(cn_test_fini);