public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: dpervushin@ru.mvista.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] SPI core -- revisited
Date: Mon, 27 Jun 2005 00:49:10 +0400	[thread overview]
Message-ID: <200506270049.10970.adobriyan@gmail.com> (raw)
In-Reply-To: <20050626193621.8B8E44C4D1@abc.pervushin.pp.ru>

On Sunday 26 June 2005 23:36, dpervushin@ru.mvista.com wrote:
> Here is the sample of usage of our SPI core; this is the driver of atmel
> chip connected to the pnx spi bus; 

> --- /dev/null
> +++ linux-2.6.10/drivers/spi/spi-pnx010x.c

> +#define DBG(args...)	pr_debug(args)

Just use pr_debug()

> +static void		*phys_spi_data_reg = 0;

NULL for pointers.

> +void spipnx_select_chip (void)
> +{
> +	unsigned reg = gpio_read_reg (PADMUX1_MODE0);
> +	gpio_write_reg ((reg & ~GPIO_PIN_SPI_CE), PADMUX1_MODE0); }

Closing brackets on the separate line, _please_.

> +static void spipnx_spi_init (void *algo_data) {

As well as opening ones.

> --- /dev/null
> +++ linux-2.6.10/drivers/spi/spi-pnx010x_atmel.c

> +#define DBG(args...)	pr_debug(args)

> +static struct spi_algorithm spipnx_algorithm = {
> +	name:		ALGORITHM_NAME,
> +	xfer:		spipnx_xfer,

	.name = ALGORITHM_NAME,
	.xfer = ...

> +static spi_pnx0105_algo_data_t spi_pnx_algo_data = {
> +	cb_data:		NULL,
> +	chip_cs_callback:	NULL,
> +};

> +static struct spi_adapter spipnx_adapter = {
> +	name:		ADAPTER_NAME,
> +	algo:		&spipnx_algorithm,
> +	algo_data:	(void *) &spi_pnx_algo_data,
> +	owner:		THIS_MODULE,
> +	alloc:		NULL,
> +	free:		NULL,
> +	copy_from_user:	NULL,
> +	copy_to_user:	NULL,
> +};

> +void *pnx_memory_alloc(size_t size, int base) {
> +	spi_pnx_msg_buff_t *buff;
> +
> +	buff = (spi_pnx_msg_buff_t *) kmalloc(sizeof(spi_pnx_msg_buff_t),

Useless cast.

> base);
> +	buff->size = size;
> +	buff->io_buffer = dma_alloc_coherent (NULL, size, &buff->dma_buffer,
> 
> +base);
> +	
> +	DBG("%s:allocated memory(%x) for io_buffer = %x dma_buffer = %x\n",
> +		__FUNCTION__, buff, buff->io_buffer,buff->dma_buffer );
> +
> +	return (void *) buff;
> +}

No error path. You're an optimist.

> +void pnx_memory_free(const void *data)
> +{
> +	spi_pnx_msg_buff_t *buff;
> +
> +	buff = (spi_pnx_msg_buff_t *) data;
> +	DBG("%s:deleted memory(%x) for io_buffer = %x dma_buffer = %x\n",
> +		__FUNCTION__, buff, buff->io_buffer,buff->dma_buffer );

%p was invented for pointers.

> +unsigned long pnx_copy_from_user(void *to, const void *from_user, 

const void __user *from, I believe.

> +unsigned long pnx_copy_to_user(void *to_user, const void *from,

const void __user *to.

  reply	other threads:[~2005-06-26 20:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-26 19:36 [RFC] SPI core -- revisited dpervushin
2005-06-26 20:49 ` Alexey Dobriyan [this message]
2005-06-26 20:59   ` Arjan van de Ven
2005-06-27  3:37     ` Vitaly Wool
2005-06-27  8:28       ` Arjan van de Ven
2005-06-27  9:13         ` Vitaly Wool
2005-06-27  9:20           ` Russell King
2005-06-27 10:20             ` Vitaly Wool
2005-06-28 16:49               ` Greg KH
2005-06-27  3:39   ` Vitaly Wool
  -- strict thread matches above, loose matches on Subject: below --
2005-06-23 12:18 dmitry pervushin
2005-06-23 15:50 ` Jamey Hicks
2005-06-23 16:43   ` Russell King
2005-06-24 12:56     ` Jamey Hicks
2005-06-23 21:59 ` Jean Delvare
2005-06-24  0:35 ` Greg KH

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=200506270049.10970.adobriyan@gmail.com \
    --to=adobriyan@gmail.com \
    --cc=dpervushin@ru.mvista.com \
    --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