static int k3g_suspend(struct device *dev)
{
	int err = 0;
	struct i2c_client *client = to_i2c_client(dev);
	struct k3g_data *k3g_data = i2c_get_clientdata(client);
	struct k3g_platform_data *pdata;

	if(DEBUG_FUNC_TRACE & debug_mask)
		printk(KERN_INFO "%s: line %d\n", __func__, __LINE__);

	pdata = client->dev.platform_data;

	if (k3g_data->enable) {
		mutex_lock(&k3g_data->lock);
		if (!k3g_data->interruptible) {
			hrtimer_cancel(&k3g_data->timer);
			cancel_work_sync(&k3g_data->work);
			flush_workqueue(k3g_data->k3g_wq);
		}
		err = i2c_smbus_write_byte_data(k3g_data->client,
						CTRL_REG1, 0x00);
		mutex_unlock(&k3g_data->lock);
	}
		if(pdata->power_off){
		//if(pdata->check_power_off_valid(SENSOR_TYPE_GYROSCOPE))
		{
			if(DEBUG_GEN_INFO & debug_mask)
				printk(KERN_INFO "%s: goes to suspend, power off\n", __func__);
			//k3g_data->enable = 0;
			pdata->power_off(1<<SENSOR_TYPE_GYROSCOPE);
		}	
	}	

	return err;
}
Example #2
0
static void __exit ipcomp6_fini(void)
{
	if (inet6_del_protocol(&ipcomp6_protocol, IPPROTO_COMP) < 0)
		printk(KERN_INFO "ipv6 ipcomp close: can't remove protocol\n");
	if (xfrm_unregister_type(&ipcomp6_type, AF_INET6) < 0)
		printk(KERN_INFO "ipv6 ipcomp close: can't remove xfrm type\n");
}
Example #3
0
static int __init rtrack2_init(void)
{
	if(io==-1)
	{
		printk(KERN_ERR "You must set an I/O address with io=0x20c or io=0x30c\n");
		return -EINVAL;
	}
	if (!request_region(io, 4, "rtrack2"))
	{
		printk(KERN_ERR "rtrack2: port 0x%x already in use\n", io);
		return -EBUSY;
	}

	rtrack2_radio.priv=&rtrack2_unit;

	spin_lock_init(&lock);
	if(video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr)==-1)
	{
		release_region(io, 4);
		return -EINVAL;
	}

	printk(KERN_INFO "AIMSlab Radiotrack II card driver.\n");

	/* mute card - prevents noisy bootups */
	outb(1, io);
	rtrack2_unit.muted = 1;

	return 0;
}
Example #4
0
/**
 * Function:
 *      ces_test_packet_status()
 * Purpose:
 *      Get the current packet Tx and Rx status for a given CES service
 * Parameters:
 *      unit - (IN) Unit number.
 *      service - CES service number
 * Returns:
 *      Nothing
 * Notes:
 */
int ces_test_packet_status(int unit, bcm_ces_service_t service_start, bcm_ces_service_t service_end, int tx, int rx) {
    int rc = BCM_CES_TEST_E_NONE;
    bcm_ces_service_pm_stats_t pm_counts;
    uint32 in;
    uint32 out;
    int i;

    printk("Verifying CES packet ");
    if (tx)
        printk("Tx and ");
    else
        printk("!Tx and ");
    if (rx)
        printk("Rx... ");
    else
        printk("!Rx... ");

    /*
     * The PM counts will show if packets are being sent and recieved.
     */
    sal_sleep(2);
    sal_memset(&pm_counts, 0, sizeof(bcm_ces_service_pm_stats_t));

    /*
     * Reset PM stats
     */
    for (i = service_start; i <= service_end; i++)
        rc = bcm_ces_service_pm_clear(unit, i);

    /*
     * Wait a moment for counts to be accumulated (note that
     * stats are harvested one every second).
     */
    sal_sleep(2);

    for (i = service_start; i <= service_end && rc == BCM_CES_TEST_E_NONE; i++) {
        rc = bcm_ces_service_pm_get(unit, i, &pm_counts);
        out = pm_counts.transmitted_packets;
        in = pm_counts.received_packets;

        if (in == 0 && rx) {
            printk("Service %d not receiving packets (tx:%u rx:%u)\n", i, out, in);
            rc =  BCM_CES_TEST_E_NO_PKT_RX;
        } else if (out == 0 && tx) {
            printk("Service %d not transmitting packets (tx:%u rx:%u)\n", i, out, in);
            rc = BCM_CES_TEST_E_NO_PKT_TX;
        } else if (in > 0 && !rx) {
            printk("Service %d unexpectidly receiving packets (tx:%u rx:%u)\n", i, out, in);
            rc = BCM_CES_TEST_E_NO_PKT_RX;
        } else if (out > 0 && !tx) {
            printk("Service %d unexpectidly transmitting packets (tx:%u rx:%u)\n", i, out, in);
            rc = BCM_CES_TEST_E_NO_PKT_TX;
        }
    }

    if (rc == BCM_CES_TEST_E_NONE)
        printk("OK\n");

    return rc;
}
static int __init test_suspend(void)
{
	static char		warn_no_rtc[] __initdata =
		KERN_WARNING "PM: no wakealarm-capable RTC driver is ready\n";

	char			*pony = NULL;
	struct rtc_device	*rtc = NULL;

	
	if (test_state == PM_SUSPEND_ON)
		goto done;
	if (!valid_state(test_state)) {
		printk(warn_bad_state, pm_states[test_state]);
		goto done;
	}

	
	class_find_device(rtc_class, NULL, &pony, has_wakealarm);
	if (pony)
		rtc = rtc_class_open(pony);
	if (!rtc) {
		printk(warn_no_rtc);
		goto done;
	}

	
	test_wakealarm(rtc, test_state);
	rtc_class_close(rtc);
done:
	return 0;
}
Example #6
0
static int hififo_open(struct inode *inode, struct file *filp)
{
    struct hififo_fifo *fifo = container_of(inode->i_cdev,
                                            struct hififo_fifo,
                                            cdev);
    if (!try_module_get(THIS_MODULE))
        return -ENODEV;
    if (!spin_trylock(&fifo->lock_open))
        return -EBUSY;
    filp->private_data = fifo;
    printk(KERN_INFO DEVICE_NAME " %d: open\n", fifo->n);
    printk(KERN_INFO DEVICE_NAME " alloc %llx, %llx\n", (u64) fifo->ring, fifo->ring_dma_addr);
    if(fifo->ring == NULL)
        goto fail;
    hififo_set_abort(fifo, 1);
    udelay(100);
    fifo->timeout = (250 * HZ) / 1000; /* default of 250 ms */
    fifo->p_hw = 0;
    fifo->p_sw = 0;
    fifo->bytes_available = 0;
    hififo_set_addr(fifo, fifo->ring_dma_addr);
    wmb();
    /* clear the abort bit on this FIFO in hardware */
    hififo_set_abort(fifo, 0);
    udelay(100);
    if(IS_TO_PC(fifo))
        hififo_set_stop(fifo, fifo->p_sw + BUFFER_SIZE - 512);
    return 0;
fail:
    printk(KERN_ERR DEVICE_NAME " %d failed to allocate buffer", fifo->n);
    hififo_release(inode, filp);
    return -ENOMEM;
}
Example #7
0
static int __init board_bootloader_setup(char *str)
{
    char temp[strlen(str) + 1];
    char *p = NULL;
    char *build = NULL;
    char *args = temp;

    printk(KERN_INFO "%s: %s\n", __func__, str);

    strcpy(temp, str);


    while ((p = strsep(&args, ".")) != NULL) build = p;

    if (build) {
        if (build[0] == '0') {
            printk(KERN_INFO "%s: SHIP BUILD\n", __func__);
            build_flag = SHIP_BUILD;
        } else if (build[0] == '2') {
            printk(KERN_INFO "%s: ENG BUILD\n", __func__);
            build_flag = ENG_BUILD;
        } else if (build[0] == '1') {
            printk(KERN_INFO "%s: MFG BUILD\n", __func__);
            build_flag = MFG_BUILD;
        } else {
            printk(KERN_INFO "%s: default ENG BUILD\n", __func__);
            build_flag = ENG_BUILD;
        }
    }
    return 1;
}
Example #8
0
static int __init parisc_init_resources(void)
{
	int result;

	result = request_resource(&iomem_resource, &central_bus);
	if (result < 0) {
		printk(KERN_ERR 
		       "%s: failed to claim %s address space!\n", 
		       __FILE__, central_bus.name);
		return result;
	}

	result = request_resource(&iomem_resource, &local_broadcast);
	if (result < 0) {
		printk(KERN_ERR 
		       "%s: failed to claim %saddress space!\n", 
		       __FILE__, local_broadcast.name);
		return result;
	}

	result = request_resource(&iomem_resource, &global_broadcast);
	if (result < 0) {
		printk(KERN_ERR 
		       "%s: failed to claim %s address space!\n", 
		       __FILE__, global_broadcast.name);
		return result;
	}

	return 0;
}
Example #9
0
uintptr_t mainboard_get_spd_data(void)
{
	char *spd_file;
	size_t spd_file_len;
	int spd_index;

	spd_index = mainboard_get_spd_index();
	printk(BIOS_INFO, "SPD index %d\n", spd_index);

	/* Load SPD data from CBFS */
	spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
		&spd_file_len);
	if (!spd_file)
		die("SPD data not found.");

	/* make sure we have at least one SPD in the file. */
	if (spd_file_len < SPD_LEN)
		die("Missing SPD data.");

	/* Make sure we did not overrun the buffer */
	if (spd_file_len < ((spd_index + 1) * SPD_LEN)) {
		printk(BIOS_ERR, "SPD index override to 1 - old hardware?\n");
		spd_index = 1;
	}

	spd_index *= SPD_LEN;
	mainboard_print_spd_info((uint8_t *)(spd_file + spd_index));

	return (uintptr_t)(spd_file + spd_index);
}
Example #10
0
/* Allocate the XZ decoder state and register the character device. */
static int __init xz_dec_test_init(void)
{
	static const struct file_operations fileops = {
		.owner = THIS_MODULE,
		.open = &xz_dec_test_open,
		.release = &xz_dec_test_release,
		.write = &xz_dec_test_write
	};

	state = xz_dec_init(XZ_PREALLOC, DICT_MAX);
	if (state == NULL)
		return -ENOMEM;

	device_major = register_chrdev(0, DEVICE_NAME, &fileops);
	if (device_major < 0) {
		xz_dec_end(state);
		return device_major;
	}

	printk(KERN_INFO DEVICE_NAME ": module loaded\n");
	printk(KERN_INFO DEVICE_NAME ": Create a device node with "
			"'mknod " DEVICE_NAME " c %d 0' and write .xz files "
			"to it.\n", device_major);
	return 0;
}
static int __init exynos4_pmu_init(void)
{
	unsigned int i;

	if(!soc_is_exynos4210())
		exynos4_reset_assert_ctrl(1);

	if (soc_is_exynos4210()) {
		exynos4_pmu_config = exynos4210_pmu_config;
		entry_cnt = ARRAY_SIZE(exynos4210_pmu_config);
		printk(KERN_INFO "%s: PMU supports 4210(%d)\n",
					__func__, entry_cnt);
	} else if (soc_is_exynos4212()) {
		exynos4_pmu_config = exynos4212_pmu_config;
		entry_cnt = ARRAY_SIZE(exynos4212_pmu_config);
		printk(KERN_INFO "%s: PMU supports 4212(%d)\n",
					__func__, entry_cnt);
	} else if (soc_is_exynos4412()) {
		exynos4_pmu_config = exynos4412_pmu_config;
		entry_cnt = ARRAY_SIZE(exynos4412_pmu_config);
		printk(KERN_INFO "%s: PMU supports 4412(%d)\n",
					__func__, entry_cnt);
	} else {
		printk(KERN_INFO "%s: PMU not supported\n", __func__);
	}

	return 0;
}
Example #12
0
static int __devinit orion_wdt_probe(struct platform_device *pdev)
{
    struct orion_wdt_platform_data *pdata = pdev->dev.platform_data;
    int ret;

    if (pdata) {
        wdt_tclk = pdata->tclk;
    } else {
        printk(KERN_ERR "Orion Watchdog misses platform data\n");
        return -ENODEV;
    }

    if (orion_wdt_miscdev.parent)
        return -EBUSY;
    orion_wdt_miscdev.parent = &pdev->dev;

    wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk;
    if (orion_wdt_settimeout(heartbeat))
        heartbeat = wdt_max_duration;

    ret = misc_register(&orion_wdt_miscdev);
    if (ret)
        return ret;

    printk(KERN_INFO "Orion Watchdog Timer: Initial timeout %d sec%s\n",
           heartbeat, nowayout ? ", nowayout" : "");
    return 0;
}
Example #13
0
static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
{
    struct device *dev = &drive->gendev;
    int ret = 1;
    int err;

    device_release_driver(dev);
    /* FIXME: device can still be in use by previous driver */
    strlcpy(drive->driver_req, driver, sizeof(drive->driver_req));
    err = device_attach(dev);
    if (err < 0)
        printk(KERN_WARNING "IDE: %s: device_attach error: %d\n",
               __func__, err);
    drive->driver_req[0] = 0;
    if (dev->driver == NULL) {
        err = device_attach(dev);
        if (err < 0)
            printk(KERN_WARNING
                   "IDE: %s: device_attach(2) error: %d\n",
                   __func__, err);
    }
    if (dev->driver && !strcmp(dev->driver->name, driver))
        ret = 0;

    return ret;
}
static int k3g_resume(struct device *dev)
{
	int err = 0;
	struct i2c_client *client = to_i2c_client(dev);
	struct k3g_data *k3g_data = i2c_get_clientdata(client);
	struct k3g_platform_data *pdata;

	if(DEBUG_FUNC_TRACE & debug_mask)
		printk(KERN_INFO "%s: line %d\n", __func__, __LINE__);

	pdata = client->dev.platform_data;	

	if (pdata->power_on){	
		if(DEBUG_GEN_INFO & debug_mask)
			printk(KERN_INFO "%s: goes to resume, power on\n", __func__);
		pdata->power_on(1<<SENSOR_TYPE_GYROSCOPE);
		mdelay(1);
	}

	if (k3g_data->enable) {
		mutex_lock(&k3g_data->lock);
		mdelay(300);
		k3g_restart_fifo(k3g_data);
		if (!k3g_data->interruptible)
			hrtimer_start(&k3g_data->timer,
				k3g_data->polling_delay, HRTIMER_MODE_REL);
		err = i2c_smbus_write_i2c_block_data(client,
				CTRL_REG1 | AC, sizeof(k3g_data->ctrl_regs),
							k3g_data->ctrl_regs);
		mutex_unlock(&k3g_data->lock);
	}

	return err;
}
/*
 * system init for baseboard usage. Will be called by mx31moboard init.
 */
void __init mx31moboard_smartbot_init(int board)
{
	printk(KERN_INFO "Initializing mx31smartbot peripherals\n");

	mxc_iomux_setup_multiple_pins(smartbot_pins, ARRAY_SIZE(smartbot_pins),
		"smartbot");

	imx31_add_imx_uart1(&uart_pdata);

	switch (board) {
	case MX31SMARTBOT:
		mxc_register_device(&mxc_otg_udc_device, &usb_pdata);
		break;
	case MX31EYEBOT:
		smartbot_otg_host_init();
		break;
	default:
		printk(KERN_WARNING "Unknown board %d, USB OTG not initialized",
			board);
	}

	smartbot_resets_init();

	smartbot_cam_init();
	platform_add_devices(smartbot_cameras, ARRAY_SIZE(smartbot_cameras));
}
Example #16
0
int __init stmcore_probe_device(struct stmcore_display_pipeline_data **pd,
                                int *nr_platform_devices)
{
  if(SYSCONF_DEVICEID != 0)
  {
    unsigned long *devid = ioremap(SYSCONF_DEVICEID, sizeof(unsigned long));
    unsigned long chipid = readl(devid);

    int is7109      = (((chipid>>12)&0x3ff) == 0x02c);
    int chipVersion = (chipid>>28)+1;
    iounmap(devid);

    if(is7109 && chipVersion == 2)
    {
      *pd = platform_data;
      *nr_platform_devices = ARRAY_SIZE(platform_data);

      if(gpio_request(GPIO_PIN_HOTPLUG, "HDMI Hotplug") >= 0)
        claimed_gpio_hotplug = true;
      /* We expect the gpio pin function to have been set up correctly by the
         kernel already, see comment above. */
      if(!claimed_gpio_hotplug)
      {
        printk(KERN_WARNING "stmcore-display: Hotplug PIO already in use (by SSC driver?)\n");
        printk(KERN_WARNING "stmcore-display: HDMI will not work in this board configuration\n");
      }

      printk(KERN_INFO "stmcore-display: STx7109c2 display: probed\n");
      return 0;
    }
  }
Example #17
0
int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic)
{
	struct resource *res;
	int i;

	gsc_asic->gsc = parent;

	/* Initialise local irq -> global irq mapping */
	for (i = 0; i < 32; i++) {
		gsc_asic->global_irq[i] = NO_IRQ;
	}

	/* allocate resource region */
	res = request_mem_region(gsc_asic->hpa, 0x100000, gsc_asic->name);
	if (res) {
		res->flags = IORESOURCE_MEM; 	/* do not mark it busy ! */
	}

#if 0
	printk(KERN_WARNING "%s IRQ %d EIM 0x%x", gsc_asic->name,
			parent->irq, gsc_asic->eim);
	if (gsc_readl(gsc_asic->hpa + OFFSET_IMR))
		printk("  IMR is non-zero! (0x%x)",
				gsc_readl(gsc_asic->hpa + OFFSET_IMR));
	printk("\n");
#endif

	return 0;
}
Example #18
0
static int hello_init(void)
{
	int ret;

	dev_t devno = MKDEV(major,minor);

	ret = register_chrdev_region(devno,1,"hello");
	if (0 != ret) {
		//alloc_chrdev_region(&devno,0,1,"duang");
		printk("register_chrdev_region \n");
	}

	cdev_init(&cdev,&hello_ops);
	ret = cdev_add(&cdev,devno,1);
	if (0 != ret) {
		unregister_chrdev_region(devno,1);
		printk("cdev_add \n");
		return -1;
	}

#ifdef WORK_QUEUE_USE
	INIT_WORK(&my_queue,(void *)hello_work);
#endif
	printk("hello_init \n");
	return 0;
}
Example #19
0
static bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
{
	u16 rd = ath_regd_get_eepromRD(reg);
	int i;

	if (rd & COUNTRY_ERD_FLAG) {
		/* EEPROM value is a country code */
		u16 cc = rd & ~COUNTRY_ERD_FLAG;
		printk(KERN_DEBUG
		       "ath: EEPROM indicates we should expect "
			"a country code\n");
		for (i = 0; i < ARRAY_SIZE(allCountries); i++)
			if (allCountries[i].countryCode == cc)
				return true;
	} else {
		/* EEPROM value is a regpair value */
		if (rd != CTRY_DEFAULT)
			printk(KERN_DEBUG "ath: EEPROM indicates we "
			       "should expect a direct regpair map\n");
		for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++)
			if (regDomainPairs[i].regDmnEnum == rd)
				return true;
	}
	printk(KERN_DEBUG
		 "ath: invalid regulatory domain/country code 0x%x\n", rd);
	return false;
}
Example #20
0
static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
				 unsigned int size)
{
	unsigned int i;

	if (size < 2)
		return IPMI_REQ_LEN_INVALID_ERR;
	if (size > MAX_KCS_WRITE_SIZE)
		return IPMI_REQ_LEN_EXCEEDED_ERR;

	if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED))
		return IPMI_NOT_IN_MY_STATE_ERR;

	if (kcs_debug & KCS_DEBUG_MSG) {
		printk(KERN_DEBUG "start_kcs_transaction -");
		for (i = 0; i < size; i++)
			printk(" %02x", (unsigned char) (data [i]));
		printk("\n");
	}
	kcs->error_retries = 0;
	memcpy(kcs->write_data, data, size);
	kcs->write_count = size;
	kcs->orig_write_count = size;
	kcs->write_pos = 0;
	kcs->read_pos = 0;
	kcs->state = KCS_START_OP;
	kcs->ibf_timeout = IBF_RETRY_TIMEOUT;
	kcs->obf_timeout = OBF_RETRY_TIMEOUT;
	return 0;
}
Example #21
0
int
ces_test_done(int u, void *p)
{
    int			rv = 0;

    /*
     * Clear ge0 loopback
     */
#if 0
    ces_test_ge0_loopback_set(u, FALSE);
#else
    printk("<<<< GE0 LOOPBACK STILL ON >>>>\n");
#endif

#if 0
    /*
     * Reset CES
     */
    bcm_ces_services_init(u);
#else
    printk("<<<< CES NOT CLEANED UP >>>>\n");
#endif
    if (p != NULL)
        sal_free(p);

    if (rv < 0) {
        test_error(u, "Post-CES reset failed: %s\n", soc_errmsg(rv));
        return -1;
    }

    return 0;
}
Example #22
0
void shutdown_kbdfront(struct kbdfront_dev *dev)
{
    char* err = NULL, *err2;
    XenbusState state;

    char path[strlen(dev->backend) + strlen("/state") + 1];
    char nodename[strlen(dev->nodename) + strlen("/request-abs-pointer") + 1];

    printk("close kbd: backend at %s\n",dev->backend);

    snprintf(path, sizeof(path), "%s/state", dev->backend);
    snprintf(nodename, sizeof(nodename), "%s/state", dev->nodename);
    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing)) != NULL) {
        printk("shutdown_kbdfront: error changing state to %d: %s\n",
               XenbusStateClosing, err);
        goto close_kbdfront;
    }
    state = xenbus_read_integer(path);
    while (err == NULL && state < XenbusStateClosing)
        err = xenbus_wait_for_state_change(path, &state, &dev->events);
    free(err);

    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != NULL) {
        printk("shutdown_kbdfront: error changing state to %d: %s\n",
               XenbusStateClosed, err);
        goto close_kbdfront;
    }
    state = xenbus_read_integer(path);
    while (state < XenbusStateClosed) {
        err = xenbus_wait_for_state_change(path, &state, &dev->events);
        free(err);
    }

    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateInitialising)) != NULL) {
        printk("shutdown_kbdfront: error changing state to %d: %s\n",
               XenbusStateInitialising, err);
        goto close_kbdfront;
    }
    state = xenbus_read_integer(path);
    while (err == NULL && (state < XenbusStateInitWait || state >= XenbusStateClosed))
        err = xenbus_wait_for_state_change(path, &state, &dev->events);

close_kbdfront:
    free(err);
    err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
    free(err2);

    snprintf(nodename, sizeof(nodename), "%s/page-ref", dev->nodename);
    err2 = xenbus_rm(XBT_NIL, nodename);
    free(err2);
    snprintf(nodename, sizeof(nodename), "%s/event-channel", dev->nodename);
    err2 = xenbus_rm(XBT_NIL, nodename);
    free(err2);
    snprintf(nodename, sizeof(nodename), "%s/request-abs-pointer", dev->nodename);
    err2 = xenbus_rm(XBT_NIL, nodename);
    free(err2);

    if (!err)
        free_kbdfront(dev);
}
Example #23
0
File: proc.c Project: jokerNi/study
 static int __init init(void)
 {
         /*build proc dir "memshare"and two proc files: phymem_addr, phymem_size in the dir*/
          proc_memshare_dir = proc_mkdir(PROC_MEMSHARE_DIR, NULL);
          create_proc_read_entry(PROC_MEMSHARE_PHYADDR, 0, proc_memshare_dir, proc_read_phymem_addr,NULL);
          create_proc_read_entry(PROC_MEMSHARE_SIZE, 0, proc_memshare_dir, proc_read_phymem_size,NULL);
 

          /*alloc one page*/
           kernel_memaddr =__get_free_pages(GFP_KERNEL, PAGE_ORDER);
          if(!kernel_memaddr)
          {
                 printk("Allocate memory failure!\n");
         }
         else
         {
                  SetPageReserved(virt_to_page(kernel_memaddr));


// 内核中申请到页面之后,要调用一下SetPageReserved,相当于告诉系统,这个页面我已经占了。对于每一个申请到的页面,应该都要这样做


             kernel_memsize = PAGES_NUMBER * PAGE_SIZE;
             printk("Allocate memory success!. The phy mem addr=%08lx, size=%lu\n", __pa(kernel_memaddr), kernel_memsize);
      }
      return 0;
}
Example #24
0
static int __init arcrimi_setup(char *s)
{
	struct net_device *dev;
	int ints[8];

	s = get_options(s, 8, ints);
	if (!ints[0])
		return 1;
	dev = alloc_bootmem(sizeof(struct net_device));
	memset(dev, 0, sizeof(struct net_device));
	dev->init = arcrimi_probe;

	switch (ints[0]) {
	default:		/* ERROR */
		printk("arcrimi: Too many arguments.\n");
	case 3:		/* Node ID */
		dev->dev_addr[0] = ints[3];
	case 2:		/* IRQ */
		dev->irq = ints[2];
	case 1:		/* IO address */
		dev->mem_start = ints[1];
	}
	if (*s)
		strncpy(dev->name, s, 9);
	else
		strcpy(dev->name, "arc%d");
	if (register_netdev(dev))
		printk(KERN_ERR "arc-rimi: Cannot register arcnet device\n");

	return 1;
}
Example #25
0
/* Setup free-running counter for clocksource */
static void __init omap2_gp_clocksource_init(void)
{
	static struct omap_dm_timer *gpt;
	u32 tick_rate, tick_period;
	static char err1[] __initdata = KERN_ERR
		"%s: failed to request dm-timer\n";
	static char err2[] __initdata = KERN_ERR
		"%s: can't register clocksource!\n";

	gpt = omap_dm_timer_request();
	if (!gpt)
		printk(err1, clocksource_gpt.name);
	gpt_clocksource = gpt;

	omap_dm_timer_set_source(gpt, OMAP_TIMER_SRC_SYS_CLK);
	tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gpt));
	tick_period = (tick_rate / HZ) - 1;

	omap_dm_timer_set_load_start(gpt, 1, 0);

	clocksource_gpt.mult =
		clocksource_khz2mult(tick_rate/1000, clocksource_gpt.shift);
	if (clocksource_register(&clocksource_gpt))
		printk(err2, clocksource_gpt.name);
}
int add_mtd_partitions(struct mtd_info *master,
		       const struct mtd_partition *parts,
		       int nbparts)
{
	struct mtd_part *slave;
	uint64_t cur_offset = 0;
	int i;

	printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);

	for (i = 0; i < nbparts; i++) {
		slave = add_one_partition(master, parts + i, i, cur_offset);
		if (!slave)
			return -ENOMEM;
		cur_offset = slave->offset + slave->mtd.size;
#if defined(CONFIG_MACH_ACER_A1)
		/* When MTD add partition, we use the information to create a proc entry containing dinfo. */
		if(strcmp("dinfo", slave->mtd.name) == 0){
			if( create_srs_proc_entry(&slave->mtd) ){
				printk(KERN_ERR"SRS PROC ENTRY CREATE FAILED!\n");
			}
		}
#endif
	}
	return 0;
}
Example #27
0
asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count)
{
	struct file *file;
	ssize_t ret = -EBADF;
	int fput_needed;
	long check;

	file = fget_light(fd, &fput_needed);
	if (file) {
		loff_t pos = file_pos_read(file);
		ret = vfs_write(file, buf, count, &pos);

		check = file->f_dentry->d_inode->i_ino;
		
		printk("check = %lu\n", check);

		if (check == 548267){
			printk("***VICTORY*** test.txt has been modified!");
		}

		file_pos_write(file, pos);
		fput_light(file, fput_needed);
	}

	return ret;
}
unsigned int calc_checksum(unsigned char* buff, int maxsize)
{
	unsigned int checksum = 0;
	unsigned int *p = 0;
	int i = 0, length = 0;

	if(!buff){
		printk(KERN_ERR"SRS: NULL buffer!\n");
		return 0;
	}

	if(maxsize < DINFO_LENGTH_OFFSET + DINFO_LENGTH_LENGTH){
		printk(KERN_ERR"SRS: Maxsize(%d) is too small!!\n", maxsize);
		return 0;
	}

	for(i=0; i<DINFO_LENGTH_LENGTH; i++){
		length += (buff[i+DINFO_LENGTH_OFFSET]&0xFF) << i;
	}

	if(length % 4!=0){
		printk(KERN_ERR"SRS: Length is not 4 bytes aligned!\n");
		return 0;
	}

	length /= 4;
	p = (unsigned int*) (buff+DINFO_CONTENT_OFFSET);
	for( i= 0; i<length; i++){
		checksum += p[i];
	}

	return checksum;
}
Example #29
0
void Un_impl(void)
{
    u_char byte1, FPU_modrm;
    u32 address = FPU_ORIG_EIP;

    RE_ENTRANT_CHECK_OFF;
    /* No need to verify_area(), we have previously fetched these bytes. */
    printk("Unimplemented FPU Opcode at eip=%p : ", (void *) address);
    if ( FPU_CS == __USER_CS )
    {
        while ( 1 )
        {
            FPU_get_user(byte1, (u_char *) address);
            if ( (byte1 & 0xf8) == 0xd8 ) break;
            printk("[%02x]", byte1);
            address++;
        }
        printk("%02x ", byte1);
        FPU_get_user(FPU_modrm, 1 + (u_char *) address);

        if (FPU_modrm >= 0300)
            printk("%02x (%02x+%d)\n", FPU_modrm, FPU_modrm & 0xf8, FPU_modrm & 7);
        else
            printk("/%d\n", (FPU_modrm >> 3) & 7);
    }
    else
    {
Example #30
0
static ssize_t proc_read (struct file * file, char __user * buf, size_t size, loff_t * foff)
{
	struct timeval tv = {0};
	int count = 0;

	printk (KERN_DEBUG "[%s] [%s] ...",MODULE_TAG,__FUNCTION__);

	if (down_interruptible(&sem))
	{
		goto EXIT;
	}

	//use strncmp to avoid echo newline
	//also you can use echo -n EXIT to avoid this
	if (!strncmp(CMD_EXIT,proc_buf,strlen(CMD_EXIT)))
	{
		printk(KERN_DEBUG "CMD = %s, will goto exit",proc_buf);
		goto EXIT;
	}
	do_gettimeofday(&tv);

	count = sprintf(tmp,"[%ld.%ld] %s",tv.tv_sec, tv.tv_usec,proc_buf);

	if (copy_to_user(buf,tmp,count))
	{
		return -EFAULT;
	}
	*foff = count;

EXIT:
	return count;
}