master/master.c
changeset 986 a486591ba86b
parent 958 02a789e9f1c5
child 990 4f223f3df05a
equal deleted inserted replaced
985:90bcaf9ce3d5 986:a486591ba86b
   186     memset(&master->kobj, 0x00, sizeof(struct kobject));
   186     memset(&master->kobj, 0x00, sizeof(struct kobject));
   187     kobject_init(&master->kobj);
   187     kobject_init(&master->kobj);
   188     master->kobj.ktype = &ktype_ec_master;
   188     master->kobj.ktype = &ktype_ec_master;
   189     master->kobj.parent = module_kobj;
   189     master->kobj.parent = module_kobj;
   190     
   190     
   191     if (kobject_set_name(&master->kobj, "master%i", index)) {
   191     if (kobject_set_name(&master->kobj, "master%u", index)) {
   192         EC_ERR("Failed to set master kobject name.\n");
   192         EC_ERR("Failed to set master kobject name.\n");
   193         kobject_put(&master->kobj);
   193         kobject_put(&master->kobj);
   194         goto out_clear_fsm;
   194         goto out_clear_fsm;
   195     }
   195     }
   196     
   196     
   652         // pad frame
   652         // pad frame
   653         while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN)
   653         while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN)
   654             EC_WRITE_U8(cur_data++, 0x00);
   654             EC_WRITE_U8(cur_data++, 0x00);
   655 
   655 
   656         if (unlikely(master->debug_level > 1))
   656         if (unlikely(master->debug_level > 1))
   657             EC_DBG("frame size: %i\n", cur_data - frame_data);
   657             EC_DBG("frame size: %u\n", cur_data - frame_data);
   658 
   658 
   659         // send frame
   659         // send frame
   660         ec_device_send(&master->main_device, cur_data - frame_data);
   660         ec_device_send(&master->main_device, cur_data - frame_data);
   661         cycles_sent = get_cycles();
   661         cycles_sent = get_cycles();
   662         jiffies_sent = jiffies;
   662         jiffies_sent = jiffies;
   673     }
   673     }
   674     while (more_datagrams_waiting);
   674     while (more_datagrams_waiting);
   675 
   675 
   676     if (unlikely(master->debug_level > 1)) {
   676     if (unlikely(master->debug_level > 1)) {
   677         cycles_end = get_cycles();
   677         cycles_end = get_cycles();
   678         EC_DBG("ec_master_send_datagrams sent %i frames in %ius.\n",
   678         EC_DBG("ec_master_send_datagrams sent %u frames in %uus.\n",
   679                frame_count,
   679                frame_count,
   680                (unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz);
   680                (unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz);
   681     }
   681     }
   682 }
   682 }
   683 
   683 
   793 {
   793 {
   794     if (unlikely(jiffies - master->stats.output_jiffies >= HZ)) {
   794     if (unlikely(jiffies - master->stats.output_jiffies >= HZ)) {
   795         master->stats.output_jiffies = jiffies;
   795         master->stats.output_jiffies = jiffies;
   796 
   796 
   797         if (master->stats.timeouts) {
   797         if (master->stats.timeouts) {
   798             EC_WARN("%i datagram%s TIMED OUT!\n", master->stats.timeouts,
   798             EC_WARN("%u datagram%s TIMED OUT!\n", master->stats.timeouts,
   799                     master->stats.timeouts == 1 ? "" : "s");
   799                     master->stats.timeouts == 1 ? "" : "s");
   800             master->stats.timeouts = 0;
   800             master->stats.timeouts = 0;
   801         }
   801         }
   802         if (master->stats.corrupted) {
   802         if (master->stats.corrupted) {
   803             EC_WARN("%i frame%s CORRUPTED!\n", master->stats.corrupted,
   803             EC_WARN("%u frame%s CORRUPTED!\n", master->stats.corrupted,
   804                     master->stats.corrupted == 1 ? "" : "s");
   804                     master->stats.corrupted == 1 ? "" : "s");
   805             master->stats.corrupted = 0;
   805             master->stats.corrupted = 0;
   806         }
   806         }
   807         if (master->stats.unmatched) {
   807         if (master->stats.unmatched) {
   808             EC_WARN("%i datagram%s UNMATCHED!\n", master->stats.unmatched,
   808             EC_WARN("%u datagram%s UNMATCHED!\n", master->stats.unmatched,
   809                     master->stats.unmatched == 1 ? "" : "s");
   809                     master->stats.unmatched == 1 ? "" : "s");
   810             master->stats.unmatched = 0;
   810             master->stats.unmatched = 0;
   811         }
   811         }
   812     }
   812     }
   813 }
   813 }