/* show/store functions for DIMM Label attributes */ static ssize_t channel_dimm_label_show(struct device *dev, struct device_attribute *mattr, char *data) { struct csrow_info *csrow = to_csrow(dev); unsigned chan = to_channel(mattr); struct rank_info *rank = csrow->channels[chan]; /* if field has not been initialized, there is nothing to send */ if (!rank->dimm->label[0]) return 0; return snprintf(data, sizeof(rank->dimm->label) + 1, "%s\n", rank->dimm->label); }
bool spec_auth(CHAR_DATA * ch) { CHAR_DATA *victim; CHAR_DATA *v_next; char buf[MAX_STRING_LENGTH]; OBJ_INDEX_DATA *pObjIndex; OBJ_DATA *obj; bool hasdiploma; for (victim = ch->in_room->first_person; victim; victim = v_next) { v_next = victim->next_in_room; if (!IS_NPC(victim) && (pObjIndex = get_obj_index(OBJ_VNUM_SCHOOL_DIPLOMA)) != NULL) { hasdiploma = FALSE; for (obj = victim->last_carrying; obj; obj = obj->prev_content) if (obj->pIndexData == get_obj_index(OBJ_VNUM_SCHOOL_DIPLOMA)) hasdiploma = TRUE; if (!hasdiploma) { obj = create_object(pObjIndex, 1); obj = obj_to_char(obj, victim); send_to_char ("&cThe schoolmaster gives you a diploma, and shakes your hand.\n\r&w", victim); } } if (IS_NPC(victim) || !IS_SET(victim->pcdata->flags, PCFLAG_UNAUTHED)) continue; victim->pcdata->auth_state = 3; REMOVE_BIT(victim->pcdata->flags, PCFLAG_UNAUTHED); if (victim->pcdata->authed_by) STRFREE(victim->pcdata->authed_by); victim->pcdata->authed_by = QUICKLINK(ch->name); sprintf(buf, "%s authorized %s", ch->name, victim->name); to_channel(buf, CHANNEL_MONITOR, "Monitor", ch->top_level); } return FALSE; }
/* * Initializes the block layer interfaces. */ static int sd_init_blk_dev(struct sd_host *host) { struct gendisk *disk; struct request_queue *queue; int channel; int retval; channel = to_channel(exi_get_exi_channel(host->exi_device)); /* queue */ retval = -ENOMEM; spin_lock_init(&host->queue_lock); queue = blk_init_queue(sd_request_func, &host->queue_lock); if (!queue) { sd_printk(KERN_ERR, "error initializing queue\n"); goto err_blk_init_queue; } blk_queue_dma_alignment(queue, EXI_DMA_ALIGN); blk_queue_max_segments(queue, 1); blk_queue_max_hw_sectors(queue, 8); queue_flag_set_unlocked(QUEUE_FLAG_NONROT, queue); queue->queuedata = host; host->queue = queue; /* disk */ disk = alloc_disk(1 << MMC_SHIFT); if (!disk) { sd_printk(KERN_ERR, "error allocating disk\n"); goto err_alloc_disk; } disk->major = SD_MAJOR; disk->first_minor = channel << MMC_SHIFT; disk->fops = &sd_fops; sprintf(disk->disk_name, "%s%c", SD_NAME, 'a' + channel); disk->private_data = host; disk->queue = host->queue; host->disk = disk; retval = 0; goto out; err_alloc_disk: blk_cleanup_queue(host->queue); host->queue = NULL; err_blk_init_queue: out: return retval; }
static ssize_t channel_dimm_label_store(struct device *dev, struct device_attribute *mattr, const char *data, size_t count) { struct csrow_info *csrow = to_csrow(dev); unsigned chan = to_channel(mattr); struct rank_info *rank = csrow->channels[chan]; ssize_t max_size = 0; max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1); strncpy(rank->dimm->label, data, max_size); rank->dimm->label[max_size] = '\0'; return max_size; }
/* * Initializes and launches the IO thread. */ static int sd_init_io_thread(struct sd_host *host) { int channel; int result = 0; channel = to_channel(exi_get_exi_channel(host->exi_device)); mutex_init(&host->io_mutex); host->io_thread = kthread_run(sd_io_thread, host, "ksdiod/%c", 'a' + channel); if (IS_ERR(host->io_thread)) { sd_printk(KERN_ERR, "error creating io thread\n"); result = PTR_ERR(host->io_thread); } return result; }
static ssize_t channel_dimm_label_store(struct device *dev, struct device_attribute *mattr, const char *data, size_t count) { struct csrow_info *csrow = to_csrow(dev); unsigned chan = to_channel(mattr); struct rank_info *rank = csrow->channels[chan]; size_t copy_count = count; if (count == 0) return -EINVAL; if (data[count - 1] == '\0' || data[count - 1] == '\n') copy_count -= 1; if (copy_count == 0 || copy_count >= sizeof(rank->dimm->label)) return -EINVAL; strncpy(rank->dimm->label, data, copy_count); rank->dimm->label[copy_count] = '\0'; return count; }