public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: David Airlie <airlied@linux.ie>,
	dri-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm: remove drm_calloc()
Date: Mon, 4 Jul 2005 16:33:05 +1000	[thread overview]
Message-ID: <21d7e99705070323334a194b47@mail.gmail.com> (raw)
In-Reply-To: <200507041026.52631.adobriyan@gmail.com>

The DRM has wrappers for these function due to it being used on other
OS'es (BSD mainly)

However I will accept that the drm_calloc function should now just
called the kernel kcalloc function and this could probably be moved to
an inline in drm_memory.h

I'll code up something and put it my queue..

Thanks,
Dave.

On 7/4/05, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
> 
>  drivers/char/drm/drmP.h       |    1 -
>  drivers/char/drm/drm_drv.c    |    3 +--
>  drivers/char/drm/drm_memory.c |   13 -------------
>  drivers/char/drm/drm_stub.c   |    2 +-
>  drivers/char/drm/sis_ds.c     |    8 +++-----
>  drivers/char/drm/sis_mm.c     |    8 ++++----
>  6 files changed, 9 insertions(+), 26 deletions(-)
> 
> diff -uprN linux-vanilla/drivers/char/drm/drmP.h linux-drm_calloc/drivers/char/drm/drmP.h
> --- linux-vanilla/drivers/char/drm/drmP.h       2005-06-30 02:44:22.000000000 +0400
> +++ linux-drm_calloc/drivers/char/drm/drmP.h    2005-07-04 10:15:24.000000000 +0400
> @@ -806,7 +806,6 @@ extern ssize_t       drm_read(struct fil
>  extern void         drm_mem_init(void);
>  extern int          drm_mem_info(char *buf, char **start, off_t offset,
>                                    int request, int *eof, void *data);
> -extern void         *drm_calloc(size_t nmemb, size_t size, int area);
>  extern void         *drm_realloc(void *oldpt, size_t oldsize, size_t size,
>                                    int area);
>  extern unsigned long drm_alloc_pages(int order, int area);
> diff -uprN linux-vanilla/drivers/char/drm/drm_drv.c linux-drm_calloc/drivers/char/drm/drm_drv.c
> --- linux-vanilla/drivers/char/drm/drm_drv.c    2005-06-30 02:44:22.000000000 +0400
> +++ linux-drm_calloc/drivers/char/drm/drm_drv.c 2005-07-04 10:14:56.000000000 +0400
> @@ -385,8 +385,7 @@ static int __init drm_core_init(void)
>         int ret = -ENOMEM;
> 
>         drm_cards_limit = (drm_cards_limit < DRM_MAX_MINOR + 1 ? drm_cards_limit : DRM_MAX_MINOR + 1);
> -       drm_heads = drm_calloc(drm_cards_limit,
> -                               sizeof(*drm_heads), DRM_MEM_STUB);
> +       drm_heads = kcalloc(drm_cards_limit, sizeof(*drm_heads), GFP_KERNEL);
>         if(!drm_heads)
>                 goto err_p1;
> 
> diff -uprN linux-vanilla/drivers/char/drm/drm_memory.c linux-drm_calloc/drivers/char/drm/drm_memory.c
> --- linux-vanilla/drivers/char/drm/drm_memory.c 2005-06-30 02:44:22.000000000 +0400
> +++ linux-drm_calloc/drivers/char/drm/drm_memory.c      2005-07-04 10:15:14.000000000 +0400
> @@ -65,19 +65,6 @@ int drm_mem_info(char *buf, char **start
>         return 0;
>  }
> 
> -/** Wrapper around kmalloc() */
> -void *drm_calloc(size_t nmemb, size_t size, int area)
> -{
> -       void *addr;
> -
> -       addr = kmalloc(size * nmemb, GFP_KERNEL);
> -       if (addr != NULL)
> -               memset((void *)addr, 0, size * nmemb);
> -
> -       return addr;
> -}
> -EXPORT_SYMBOL(drm_calloc);
> -
>  /** Wrapper around kmalloc() and kfree() */
>  void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
>  {
> diff -uprN linux-vanilla/drivers/char/drm/drm_stub.c linux-drm_calloc/drivers/char/drm/drm_stub.c
> --- linux-vanilla/drivers/char/drm/drm_stub.c   2005-06-30 02:44:23.000000000 +0400
> +++ linux-drm_calloc/drivers/char/drm/drm_stub.c        2005-07-04 10:11:18.000000000 +0400
> @@ -177,7 +177,7 @@ int drm_get_dev(struct pci_dev *pdev, co
> 
>         DRM_DEBUG("\n");
> 
> -       dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB);
> +       dev = kcalloc(1, sizeof(*dev), GFP_KERNEL);
>         if (!dev)
>                 return -ENOMEM;
> 
> diff -uprN linux-vanilla/drivers/char/drm/sis_ds.c linux-drm_calloc/drivers/char/drm/sis_ds.c
> --- linux-vanilla/drivers/char/drm/sis_ds.c     2005-06-30 02:44:24.000000000 +0400
> +++ linux-drm_calloc/drivers/char/drm/sis_ds.c  2005-07-04 10:13:48.000000000 +0400
> @@ -166,7 +166,7 @@ memHeap_t *mmInit(int ofs,
>         if (size <= 0)
>                 return NULL;
> 
> -       blocks = (TMemBlock *)drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
> +       blocks = (TMemBlock *)kcalloc(1, sizeof(TMemBlock), GFP_KERNEL);
>         if (blocks != NULL) {
>                 blocks->ofs = ofs;
>                 blocks->size = size;
> @@ -202,8 +202,7 @@ static TMemBlock* SliceBlock(TMemBlock *
> 
>         /* break left */
>         if (startofs > p->ofs) {
> -               newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
> -                   DRM_MEM_DRIVER);
> +               newblock = kcalloc(1, sizeof(TMemBlock), GFP_KERNEL);
>                 newblock->ofs = startofs;
>                 newblock->size = p->size - (startofs - p->ofs);
>                 newblock->free = 1;
> @@ -215,8 +214,7 @@ static TMemBlock* SliceBlock(TMemBlock *
> 
>         /* break right */
>         if (size < p->size) {
> -               newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
> -                   DRM_MEM_DRIVER);
> +               newblock = kcalloc(1, sizeof(TMemBlock), GFP_KERNEL);
>                 newblock->ofs = startofs + size;
>                 newblock->size = p->size - size;
>                 newblock->free = 1;
> diff -uprN linux-vanilla/drivers/char/drm/sis_mm.c linux-drm_calloc/drivers/char/drm/sis_mm.c
> --- linux-vanilla/drivers/char/drm/sis_mm.c     2005-06-30 02:44:24.000000000 +0400
> +++ linux-drm_calloc/drivers/char/drm/sis_mm.c  2005-07-04 10:14:28.000000000 +0400
> @@ -158,8 +158,8 @@ static int sis_fb_init( DRM_IOCTL_ARGS )
>         DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *)data, sizeof(fb));
> 
>         if (dev_priv == NULL) {
> -               dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
> -                   DRM_MEM_DRIVER);
> +               dev->dev_private = kcalloc(1, sizeof(drm_sis_private_t),
> +                   GFP_KERNEL);
>                 dev_priv = dev->dev_private;
>                 if (dev_priv == NULL)
>                         return ENOMEM;
> @@ -246,8 +246,8 @@ static int sis_ioctl_agp_init( DRM_IOCTL
>         drm_sis_agp_t agp;
> 
>         if (dev_priv == NULL) {
> -               dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
> -                   DRM_MEM_DRIVER);
> +               dev->dev_private = kcalloc(1, sizeof(drm_sis_private_t),
> +                   GFP_KERNEL);
>                 dev_priv = dev->dev_private;
>                 if (dev_priv == NULL)
>                         return ENOMEM;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

  reply	other threads:[~2005-07-04  6:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-04  6:26 [PATCH] drm: remove drm_calloc() Alexey Dobriyan
2005-07-04  6:33 ` Dave Airlie [this message]
2005-07-04  7:12   ` Arjan van de Ven
2005-07-06 11:15     ` Dave Airlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21d7e99705070323334a194b47@mail.gmail.com \
    --to=airlied@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox