From patchwork Sun Nov 21 10:46:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ionut Nicu X-Patchwork-Id: 345491 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oALAkuQ3024296 for ; Sun, 21 Nov 2010 10:46:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171Ab0KUKq4 (ORCPT ); Sun, 21 Nov 2010 05:46:56 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:43575 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751384Ab0KUKqz (ORCPT ); Sun, 21 Nov 2010 05:46:55 -0500 Received: by fxm13 with SMTP id 13so1867561fxm.19 for ; Sun, 21 Nov 2010 02:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=ZqsbjJZF/r+QXLygbo8veeDxgiUEX1AmjW+OQpkvXSY=; b=cqz8A4y6AQreJVQNehUX3Hp1qYkvTiXm6UvvJVrojFJRZ+/0iXAdhTKROk48qovzeD n+cx+Zses0yGJMBRomGMvlxBkWn+kwCZX/y/7YKMCc5bags8EJwv8/bGh7xqhsygOhvb ov7kj4RikfwxJlDyohfnBE0nzl+VlJp7a0Gvw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=M8L+lRXDHiRNcBEwoH+GR85MaczkBNYZJEMiMw2Xl1FtCYjzAxvmoUNT01kKco5g5o rtKgYRFEtOH1ZKeIkVPBkSVQtoVKbnIsKtXikoFenFL2wg+4NjdgfBIe5nAGd2AYg4Sr Str04EwFLh0id1SnxArXSrUSnoCqyMsOZpKEM= Received: by 10.223.100.4 with SMTP id w4mr3964854fan.26.1290336413632; Sun, 21 Nov 2010 02:46:53 -0800 (PST) Received: from localhost.localdomain (196-98-odb-svnet.titannet.ro [77.81.196.98]) by mx.google.com with ESMTPS id e6sm1012936fav.32.2010.11.21.02.46.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Nov 2010 02:46:52 -0800 (PST) From: Ionut Nicu To: Omar Ramirez Luna Cc: Greg Kroah-Hartman , Sapiens Rene , Andy Shevchenko , Fernando Guzman Lugo , Felipe Contreras , linux-omap , Ionut Nicu Subject: [PATCH v3 01/12] staging: tidspbridge: remove gs memory allocator Date: Sun, 21 Nov 2010 12:46:19 +0200 Message-Id: <1290336390-2581-2-git-send-email-ionut.nicu@mindbit.ro> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1290336390-2581-1-git-send-email-ionut.nicu@mindbit.ro> References: <1290336390-2581-1-git-send-email-ionut.nicu@mindbit.ro> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 21 Nov 2010 10:46:59 +0000 (UTC) diff --git a/drivers/staging/tidspbridge/Makefile b/drivers/staging/tidspbridge/Makefile index 41c644c..648e392 100644 --- a/drivers/staging/tidspbridge/Makefile +++ b/drivers/staging/tidspbridge/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_TIDSPBRIDGE) += bridgedriver.o -libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o +libgen = gen/gb.o gen/gh.o gen/uuidutil.o libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \ core/tiomap3430_pwr.o core/tiomap_io.o \ core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o diff --git a/drivers/staging/tidspbridge/gen/gb.c b/drivers/staging/tidspbridge/gen/gb.c index 9f59023..3c0e04c 100644 --- a/drivers/staging/tidspbridge/gen/gb.c +++ b/drivers/staging/tidspbridge/gen/gb.c @@ -19,7 +19,6 @@ /* ----------------------------------- DSP/BIOS Bridge */ #include /* ----------------------------------- This */ -#include #include struct gb_t_map { @@ -52,17 +51,17 @@ struct gb_t_map *gb_create(u32 len) { struct gb_t_map *map; u32 i; - map = (struct gb_t_map *)gs_alloc(sizeof(struct gb_t_map)); + map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL); if (map != NULL) { map->len = len; map->wcnt = len / BITS_PER_LONG + 1; - map->words = (u32 *) gs_alloc(map->wcnt * sizeof(u32)); + map->words = kzalloc(map->wcnt * sizeof(u32), GFP_KERNEL); if (map->words != NULL) { for (i = 0; i < map->wcnt; i++) map->words[i] = 0L; } else { - gs_frees(map, sizeof(struct gb_t_map)); + kfree(map); map = NULL; } } @@ -78,8 +77,8 @@ struct gb_t_map *gb_create(u32 len) void gb_delete(struct gb_t_map *map) { - gs_frees(map->words, map->wcnt * sizeof(u32)); - gs_frees(map, sizeof(struct gb_t_map)); + kfree(map->words); + kfree(map); } /* diff --git a/drivers/staging/tidspbridge/gen/gh.c b/drivers/staging/tidspbridge/gen/gh.c index f72d943..cd72503 100644 --- a/drivers/staging/tidspbridge/gen/gh.c +++ b/drivers/staging/tidspbridge/gen/gh.c @@ -17,9 +17,6 @@ #include #include - -#include - #include struct element { @@ -37,8 +34,6 @@ struct gh_t_hash_tab { }; static void noop(void *p); -static s32 cur_init; -static void myfree(void *ptr, s32 size); /* * ======== gh_create ======== @@ -51,8 +46,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size, { struct gh_t_hash_tab *hash_tab; u16 i; - hash_tab = - (struct gh_t_hash_tab *)gs_alloc(sizeof(struct gh_t_hash_tab)); + hash_tab = kzalloc(sizeof(struct gh_t_hash_tab), GFP_KERNEL); if (hash_tab == NULL) return NULL; hash_tab->max_bucket = max_bucket; @@ -62,7 +56,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size, hash_tab->delete = delete == NULL ? noop : delete; hash_tab->buckets = (struct element **) - gs_alloc(sizeof(struct element *) * max_bucket); + kzalloc(sizeof(struct element *) * max_bucket, GFP_KERNEL); if (hash_tab->buckets == NULL) { gh_delete(hash_tab); return NULL; @@ -89,17 +83,14 @@ void gh_delete(struct gh_t_hash_tab *hash_tab) elem = next) { next = elem->next; (*hash_tab->delete) (elem->data); - myfree(elem, - sizeof(struct element) - 1 + - hash_tab->val_size); + kfree(elem); } } - myfree(hash_tab->buckets, sizeof(struct element *) - * hash_tab->max_bucket); + kfree(hash_tab->buckets); } - myfree(hash_tab, sizeof(struct gh_t_hash_tab)); + kfree(hash_tab); } } @@ -109,9 +100,7 @@ void gh_delete(struct gh_t_hash_tab *hash_tab) void gh_exit(void) { - if (cur_init-- == 1) - gs_exit(); - + /* Do nothing */ } /* @@ -138,8 +127,7 @@ void *gh_find(struct gh_t_hash_tab *hash_tab, void *key) void gh_init(void) { - if (cur_init++ == 0) - gs_init(); + /* Do nothing */ } /* @@ -152,8 +140,8 @@ void *gh_insert(struct gh_t_hash_tab *hash_tab, void *key, void *value) u16 i; char *src, *dst; - elem = (struct element *)gs_alloc(sizeof(struct element) - 1 + - hash_tab->val_size); + elem = kzalloc(sizeof(struct element) - 1 + hash_tab->val_size, + GFP_KERNEL); if (elem != NULL) { dst = (char *)elem->data; @@ -180,14 +168,6 @@ static void noop(void *p) p = p; /* stifle compiler warning */ } -/* - * ======== myfree ======== - */ -static void myfree(void *ptr, s32 size) -{ - gs_free(ptr); -} - #ifdef CONFIG_TIDSPBRIDGE_BACKTRACE /** * gh_iterate() - This function goes through all the elements in the hash table diff --git a/drivers/staging/tidspbridge/gen/gs.c b/drivers/staging/tidspbridge/gen/gs.c deleted file mode 100644 index 8335bf5..0000000 --- a/drivers/staging/tidspbridge/gen/gs.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * gs.c - * - * DSP-BIOS Bridge driver support functions for TI OMAP processors. - * - * General storage memory allocator services. - * - * Copyright (C) 2005-2006 Texas Instruments, Inc. - * - * This package is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#include -/* ----------------------------------- DSP/BIOS Bridge */ -#include - -/* ----------------------------------- This */ -#include - -#include - -/* ----------------------------------- Globals */ -static u32 cumsize; - -/* - * ======== gs_alloc ======== - * purpose: - * Allocates memory of the specified size. - */ -void *gs_alloc(u32 size) -{ - void *p; - - p = kzalloc(size, GFP_KERNEL); - if (p == NULL) - return NULL; - cumsize += size; - return p; -} - -/* - * ======== gs_exit ======== - * purpose: - * Discontinue the usage of the GS module. - */ -void gs_exit(void) -{ - /* Do nothing */ -} - -/* - * ======== gs_free ======== - * purpose: - * Frees the memory. - */ -void gs_free(void *ptr) -{ - kfree(ptr); - /* ack! no size info */ - /* cumsize -= size; */ -} - -/* - * ======== gs_frees ======== - * purpose: - * Frees the memory. - */ -void gs_frees(void *ptr, u32 size) -{ - kfree(ptr); - cumsize -= size; -} - -/* - * ======== gs_init ======== - * purpose: - * Initializes the GS module. - */ -void gs_init(void) -{ - /* Do nothing */ -} diff --git a/drivers/staging/tidspbridge/include/dspbridge/gs.h b/drivers/staging/tidspbridge/include/dspbridge/gs.h deleted file mode 100644 index f32d8d9..0000000 --- a/drivers/staging/tidspbridge/include/dspbridge/gs.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * gs.h - * - * DSP-BIOS Bridge driver support functions for TI OMAP processors. - * - * Memory allocation/release wrappers. This module allows clients to - * avoid OS spacific issues related to memory allocation. It also provides - * simple diagnostic capabilities to assist in the detection of memory - * leaks. - * - * Copyright (C) 2005-2006 Texas Instruments, Inc. - * - * This package is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef GS_ -#define GS_ - -/* - * ======== gs_alloc ======== - * Alloc size bytes of space. Returns pointer to space - * allocated, otherwise NULL. - */ -extern void *gs_alloc(u32 size); - -/* - * ======== gs_exit ======== - * Module exit. Do not change to "#define gs_init()"; in - * some environments this operation must actually do some work! - */ -extern void gs_exit(void); - -/* - * ======== gs_free ======== - * Free space allocated by gs_alloc() or GS_calloc(). - */ -extern void gs_free(void *ptr); - -/* - * ======== gs_frees ======== - * Free space allocated by gs_alloc() or GS_calloc() and assert that - * the size of the allocation is size bytes. - */ -extern void gs_frees(void *ptr, u32 size); - -/* - * ======== gs_init ======== - * Module initialization. Do not change to "#define gs_init()"; in - * some environments this operation must actually do some work! - */ -extern void gs_init(void); - -#endif /*GS_ */