mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: mathieu.poirier@linaro.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, ohad@wizery.com,
	lee.jones@linaro.org, patches@linaro.org,
	linus.walleij@stericsson.com
Subject: Re: [PATCH 1/2] ux500: Adding support for u8500 Hsem functionality V2
Date: Tue, 12 Apr 2011 19:46:01 +0200	[thread overview]
Message-ID: <201104121946.01618.arnd@arndb.de> (raw)
In-Reply-To: <1302535464-12294-1-git-send-email-mathieu.poirier@linaro.org>

On Monday 11 April 2011, mathieu.poirier@linaro.org wrote:
> From: Mathieu J. Poirier <mathieu.poirier@linaro.org>
> 
> This is the second spin on STE's Hsem driver that is implemented
> through the hwspinlock scheme.  More specifically:
> 
>  More comments have been added in the code.
>  Cleanup of included header files.
>  One of the original contributor's name corrected.
>  Calls to 'pm_runtime_disable'restored.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Looks very nice overall, just a few small details I noticed:

> +
> +#define HSEM_REGISTER_OFFSET		0x08
> +
> +#define HSEM_CTRL_REG			0x00
> +#define HSEM_ICRALL			0x90
> +#define HSEM_PROTOCOL_1			0x01
> +
> +#define to_u8500_hsem(lock)	\
> +	container_of(lock, struct u8500_hsem, lock)
> +
> +struct u8500_hsem {
> +	struct hwspinlock lock;
> +	void __iomem *addr;
> +};

It seems inconsistent to name it sem instead of spinlock.

> +struct u8500_hsem_state {
> +	void __iomem *io_base;		/* Mapped base address */
> +};

If you make that one data structure, you only need a single allocation:

struct u8500_hsem_state {
	void __iomem *io_base;
	struct u8500_hsem hsem[U8500_MAX_SEMAPHORE];
}

> +
> +	for (i = 0; i < U8500_MAX_SEMAPHORE; i++) {
> +		u8500_lock = kzalloc(sizeof(*u8500_lock), GFP_KERNEL);
> +		if (!u8500_lock) {
> +			ret = -ENOMEM;
> +			goto free_locks;
> +		}
> +
> +		u8500_lock->lock.dev = &pdev->dev;
> +		u8500_lock->lock.owner = THIS_MODULE;
> +		u8500_lock->lock.id = i;
> +		u8500_lock->lock.ops = &u8500_hwspinlock_ops;
> +		u8500_lock->addr = io_base + offset + sizeof(u32) * i;
> +
> +		ret = hwspin_lock_register(&u8500_lock->lock);
> +		if (ret) {
> +			kfree(u8500_lock);
> +			goto free_locks;
> +		}
> +	}

When you do that, this can be a single allocation.

Thinking about it some more, it may actually be worthwhile to still improve
the API here: I think the owner field should be part of the operations structure,
because it is constant. It would also be nice to have a "private" pointer
in struct hwspinlock, so you don't need to wrap it if you don't want to.

Finally, the hwspin_lock_register could take the specific values as arguments
instead of requiring you to fill it out first.

	Arnd

  parent reply	other threads:[~2011-04-12 17:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 15:24 mathieu.poirier
2011-04-12 13:44 ` Ohad Ben-Cohen
2011-04-12 16:53   ` Mathieu Poirier
2011-04-12 17:46 ` Arnd Bergmann [this message]
2011-04-12 19:13   ` Mathieu Poirier
2011-04-13  8:45     ` Ohad Ben-Cohen
2011-04-17 20:39     ` Arnd Bergmann
2011-04-19 16:06       ` Mathieu Poirier
2011-04-19 16:10         ` Arnd Bergmann
2011-09-05 21:09           ` Ohad Ben-Cohen
2011-09-06  7:15             ` Linus Walleij
2011-09-06  7:27               ` Ohad Ben-Cohen
2011-04-13  8:16   ` Ohad Ben-Cohen

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=201104121946.01618.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=ohad@wizery.com \
    --cc=patches@linaro.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

Powered by JetHome