static int __init mb705_display_probe(struct platform_device *pdev)
{
        struct device *dev = &pdev->dev;
	int res;
	struct display_data *dd;
	int i;
	char string[17];
	int string_len;

	dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL);
	if (dd == NULL)
		return -ENOMEM;

	spin_lock_init(&dd->lock);

	platform_set_drvdata(pdev, dd);

	res = device_create_file(dev, &dev_attr_text);
	if (res)
		return res;

	for (i=0; i<16; i++) {
		if (device_create_file(dev, &dev_attr_udef[i])) {
			dev_warn(dev, "%s: failed to create udef sysfs entry\n",
				 __func__);
		}
	}

	/* notFL signal is controlled by DisplayCtrlReg[0] */
	epld_write(1, EPLD_TS_DISPLAY_CTRL_REG);

	string_len = scnprintf(string, sizeof(string), "MB705%c", mb705_rev);
	store_text(dev, NULL, string, string_len);

	return 0;
}
Beispiel #2
0
int add_subcmd(char *command_string, struct subcmd **cmdsp, int *numscp)
{
    char *p;
    struct subcmd *newsc;
    int  addrno, cmd_idx, negflag;

    if ( (newsc = (struct subcmd *)malloc(sizeof(struct subcmd))) == NULL)
      {
        myerror(ERROR_NOT_ENOUGH_MEMORY, "malloc", "add_subcmd");
        return(BAIL_OUT);
      }

    addrno = 0;
    newsc->saddr[0].type    = newsc->saddr[1].type    = NO_ADDRESS;
    newsc->saddr[0].val.pch = newsc->saddr[1].val.pch = NULL;
    newsc->args[0] = newsc->args[1] = newsc->args[2] = NULL;
    p = command_string;
    p = skipwhite(p);
    if (isdigit(*p))          /* address is present, and it's a line number */
      p = get_lineno_address(p, newsc, &addrno);
    else
      if ( (cmd_idx = find_command_idx(*p)) == -1)
          if ( (p = get_context_address(p, newsc, &addrno)) == NULL)
            return(BAIL_OUT);

/* We're past the first address, if any; next is command or another address */
    p = skipwhite(p);
    if (addrno && *p == ',')   /* it is another address */
      {
        p = skipwhite(++p);
        if (isdigit(*p))
          p = get_lineno_address(p, newsc, &addrno);
        else
          if ( (cmd_idx = find_command_idx(*p)) == -1)
            if ( (p = get_context_address(p, newsc, &addrno)) == NULL)
              return(BAIL_OUT);
      }
                             /* if it's not a command, we're in trouble */
    p = skipwhite(p);
    if (*p == NEGATION)     /* exclamation is a prefix operator */
      {
        negflag = -1;
        skipwhite(++p);
      }
    else
        negflag = 1;

    if (*p == BEGIN_SUBGROUP)  /* left brace is also prefix, but right brace */
                                       /* goes on its own line! */
      {
        newsc->cmd_idx = find_command_idx(BEGIN_SUBGROUP) * negflag;
        newsc->status = READY;
        cmdsp[*numscp] = newsc;
        *numscp += 1;
        if ( (newsc = (struct subcmd *)malloc(sizeof(struct subcmd))) == NULL)
          {
            myerror(ERROR_NOT_ENOUGH_MEMORY, "malloc", "add_subcmd");
            return(BAIL_OUT);
          }
        newsc->saddr[0].type    = newsc->saddr[1].type    = NO_ADDRESS;
        newsc->saddr[0].val.pch = newsc->saddr[1].val.pch = NULL;
        newsc->args[0] = newsc->args[1] = newsc->args[2] = NULL;
        addrno = 0;
        skipwhite(++p);
      }

    if ( (cmd_idx = find_command_idx(*p)) == -1)
      {
        fprintf(stderr, "sed: invalid script line: %s\n", command_string);
        return(BAIL_OUT);
      }
                             /* see if the number of addresses is appropriate */
    if (cmd_table[cmd_idx].max_addr < addrno)
      {
        fprintf(stderr,
                "sed: too many addresses for %c command in script line\n%s\n",
                cmd_table[cmd_idx].cmd_tag, command_string);
        return(BAIL_OUT);
      }

    newsc->cmd_idx = cmd_idx * negflag;
    newsc->status = READY;

    switch (*p)
    {
       case UNCONDITIONAL_BRANCH:
       case CONDITIONAL_BRANCH:
       case PUT_TEXT_FROM_FILE:
       case APPEND_PATTERN_TO_FILE:
       case LABEL_MARK:        p = store_next_string(p, &newsc->args[0]);
       break;

       case PUT_TEXT:
       case IPUT_TEXT:
       case REPLACE:           p = store_text(p, &newsc->args[0]);
       break;

       case CHARACTER_REPLACE: p = store_to_from(p, &newsc->args[0], NOCREP);
                               if (strlen(newsc->args[0])
                                           !=
                                                strlen(newsc->args[1]))
                                 {
                                   printf("sed: bad y command: %s\n",
                                                                command_string);
                                   return(BAIL_OUT);
                                 }
       break;

       case CHANGE:            if (p = store_to_from(p, &newsc->args[0], CREP))
                                 p = store_flags(p, &newsc->args[2]);
       break;
    }
    if (p == NULL)
      return(BAIL_OUT);
    cmdsp[*numscp] = newsc;
    return(OK);
}