Esempio n. 1
0
static unsigned long shmedia_alloc_io(unsigned long phys, unsigned long size,
				      const char *name)
{
        static int printed_full = 0;
        struct xresource *xres;
        struct resource *res;
        char *tack;
        int tlen;

        if (name == NULL) name = "???";

        if ((xres = xres_alloc()) != 0) {
                tack = xres->xname;
                res = &xres->xres;
        } else {
                if (!printed_full) {
                        printk("%s: done with statics, switching to kmalloc\n",
			       __func__);
                        printed_full = 1;
                }
                tlen = strlen(name);
                tack = kmalloc(sizeof (struct resource) + tlen + 1, GFP_KERNEL);
                if (!tack)
			return -ENOMEM;
                memset(tack, 0, sizeof(struct resource));
                res = (struct resource *) tack;
                tack += sizeof (struct resource);
        }

        strncpy(tack, name, XNMLN);
        tack[XNMLN] = 0;
        res->name = tack;

        return shmedia_ioremap(res, phys, size);
}
Esempio n. 2
0
static void __iomem *shmedia_alloc_io(unsigned long phys, unsigned long size,
				      const char *name, unsigned long flags)
{
	struct xresource *xres;
	struct resource *res;
	char *tack;
	int tlen;

	if (name == NULL)
		name = "???";

	xres = xres_alloc();
	if (xres != 0) {
		tack = xres->xname;
		res = &xres->xres;
	} else {
		printk_once(KERN_NOTICE "%s: done with statics, "
			       "switching to kmalloc\n", __func__);
		tlen = strlen(name);
		tack = kmalloc(sizeof(struct resource) + tlen + 1, GFP_KERNEL);
		if (!tack)
			return NULL;
		memset(tack, 0, sizeof(struct resource));
		res = (struct resource *) tack;
		tack += sizeof(struct resource);
	}

	strncpy(tack, name, XNMLN);
	tack[XNMLN] = 0;
	res->name = tack;

	return shmedia_ioremap(res, phys, size, flags);
}