All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Mike Werner <werner@sgi.com>, davej@codemonkey.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC][AGPGART] Allow multiple backends to be initialized
Date: Sun, 14 Nov 2004 10:44:18 +0100	[thread overview]
Message-ID: <20041114094418.GA31154@lst.de> (raw)
In-Reply-To: <200411131826.31770.werner@sgi.com>

Last time I checked Dave Jones (davej@codemonkey.org.uk) was agpgart
maintainer, not Rusty or me.  So please resend to Dave and the
linux-kernel list so other people (like me can comment).

Comments on the patch format:  Please don't send output of bk export
over multiple changesets - while you can use that to generate the
patch please strip the bk checkin comments and write a single patch
description that explains your overall changes, aka what you did
and if it's not obvious why.

If you patch does multiple things at once split it into one patch per
problem or feature.


> -struct agp_bridge_data agp_bridge_dummy = { .type = NOT_SUPPORTED };
> -struct agp_bridge_data *agp_bridge = &agp_bridge_dummy;
> +struct agp_bridge_data *agp_bridge = NULL;

there's no need to initialize global variables to NULL - the C standard
guarantees that gets done implicitly - and letting the compile do that
decreases the size of the kernel image.

> -/* XXX Kludge alert: agpgart isn't ready for multiple bridges yet */
>  struct agp_bridge_data *agp_alloc_bridge(void)
>  {
> -	return agp_bridge;
> +	struct  agp_bridge_data *bridge = kmalloc(sizeof(struct agp_bridge_data), 
> GFP_KERNEL);
> +	if(!agp_count) agp_bridge = bridge;
> +	return bridge;
>  }

Some style problems here - never create lines longer than 80
charactersm, and follow Documentation/CodingStyle indentation (or just
look at the other agpgart code).

Also you should check the kmalloc return value;

It should look like:

struct agp_bridge_data *agp_alloc_bridge(void)
{
	struct agp_bridge_data *bridge;

	bridge = kmalloc(sizeof(*bridge), GFP_KERNEL);
	if (!bridge)
		return NULL;

	/* cludge for the transition to passing the agp_bridge around */
	if (!agp_count)
		agp_bridge = bridge;

	return bridge;
}

Also where do you free the kmalloced bridges again?

> +	if(!agp_count) {

	if (!agp_count) {

> +	if(!agp_count) {

Dito.

>  	memset(info, 0, sizeof(struct agp_kern_info));
> -	if (!agp_bridge || agp_bridge->type == NOT_SUPPORTED ||
> -	    !agp_bridge->version) {
> +	if ((agp_bridge == NULL) || (agp_bridge->type == NOT_SUPPORTED)) {

Why do you drop the version check here?


       reply	other threads:[~2004-11-14  9:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200411131826.31770.werner@sgi.com>
2004-11-14  9:44 ` Christoph Hellwig [this message]
2004-12-07  1:40 [RFC][AGPGART]Allow multiple backends to be initialized Mike Werner
2004-12-07  9:02 ` Christoph Hellwig
2004-12-07 18:17   ` Mike Werner
2004-12-08 17:59   ` Mike Werner
2004-12-09 20:10   ` Mike Werner
2004-12-10  5:02   ` Mike Werner

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=20041114094418.GA31154@lst.de \
    --to=hch@lst.de \
    --cc=davej@codemonkey.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=werner@sgi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.