All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Wool <vwool@ru.mvista.com>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, david-b@pacbell.net,
	dpervushin@gmail.com, akpm@osdl.org, greg@kroah.com,
	basicmark@yahoo.com, komal_shah802003@yahoo.com,
	stephen@streetfiresound.com,
	spi-devel-general@lists.sourceforge.net, Joachim_Jaeger@digi.com
Subject: Re: [PATCH 2.6-git] SPI core refresh
Date: Thu, 01 Dec 2005 19:30:54 +0300	[thread overview]
Message-ID: <438F253E.20303@ru.mvista.com> (raw)
In-Reply-To: <20051201162102.GB31551@flint.arm.linux.org.uk>

Russell King wrote:

>>+iii. struct spi_driver
>>+~~~~~~~~~~~~~~~~~~~~~~
>>+
>>+struct spi_driver {
>>+    	void* (*alloc)( size_t, int );
>>+    	void  (*free)( const void* );
>>+    	unsigned char* (*get_buffer)( struct spi_device*, void* );
>>+    	void (*release_buffer)( struct spi_device*, unsigned char*);
>>+    	void (*control)( struct spi_device*, int mode, u32 ctl );
>>+        struct device_driver driver;
>>+};
>>    
>>
>
>This doesn't appear to have been updated.
>
>  
>
>>+formed spi_driver structure:
>>+	extern struct bus_type spi_bus;
>>+	static struct spi_driver pnx4008_eeprom_driver = {
>>+        	.driver = {
>>+                   	.bus = &spi_bus,
>>+                   	.name = "pnx4008-eeprom",
>>+                   	.probe = pnx4008_spiee_probe,
>>+                   	.remove = pnx4008_spiee_remove,
>>+                   	.suspend = pnx4008_spiee_suspend,
>>+                   	.resume = pnx4008_spiee_resume,
>>+               	},
>>+};
>>    
>>
>
>Ditto.
>
>  
>
>>+iv. struct spi_bus_driver
>>+~~~~~~~~~~~~~~~~~~~~~~~~~
>>+To handle transactions over the SPI bus, the spi_bus_driver structure must
>>+be prepared and registered with core. Any transactions, either synchronous
>>+or asynchronous, go through spi_bus_driver->xfer function.
>>+
>>+struct spi_bus_driver
>>+{
>>+        int (*xfer)( struct spi_msg* msgs );
>>+        void (*select) ( struct spi_device* arg );
>>+        void (*deselect)( struct spi_device* arg );
>>+
>>+	struct spi_msg *(*retrieve)( struct spi_bus_driver *this, struct spi_bus_data *bd);
>>+	void (*reset)( struct spi_bus_driver *this, u32 context);
>>+
>>+        struct device_driver driver;
>>+};
>>    
>>
>
>Does this need updating as well?
>
>  
>
>>+spi_bus_driver structure:
>>+	static struct spi_bus_driver spipnx_driver = {
>>+        .driver = {
>>+                   .bus = &platform_bus_type,
>>+                   .name = "spipnx",
>>+                   .probe = spipnx_probe,
>>+                   .remove = spipnx_remove,
>>+                   .suspend = spipnx_suspend,
>>+                   .resume = spipnx_resume,
>>+                   },
>>+        .xfer = spipnx_xfer,
>>+};
>>    
>>
>
>From this it looks like it does.
>
>  
>
Yep, thanks for pointing that out. The Documentation part needs to be 
updated. Will do soon.

>  
>
>>+
>>+int spi_driver_suspend (struct device *dev, pm_message_t pm)
>>+{
>>+	struct spi_driver *sdrv = TO_SPI_DRIVER(dev->driver);
>>+	struct spi_device *sdev = TO_SPI_DEV(dev);
>>+
>>+	return (sdrv && sdrv->suspend) ?  sdrv->suspend(sdev, pm) : -EFAULT;
>>+}
>>+
>>+int spi_driver_resume (struct device *dev)
>>+{
>>+	struct spi_driver *sdrv = TO_SPI_DRIVER(dev->driver);
>>+	struct spi_device *sdev = TO_SPI_DEV(dev);
>>+
>>+	return (sdrv && sdrv->resume) ? sdrv->resume(sdev) : -EFAULT;
>>+}
>>    
>>
>
>If the bus_type does not call the device_driver suspend/resume methods,
>these are not necessary.
>
>Another oddity I notice is that if there isn't a driver or method, you're
>returning -EFAULT - seems odd since if there isn't a driver do you really
>want to prevent suspend/resume?
>  
>
Yep, I must admit here that it's really better to do something like
if (!dev->driver)
return 0;
else if (sdrv->suspend)
return sdrv->suspend(...)

Does that sound better to you?

>  
>
>>+static inline int spi_driver_add(struct spi_driver *drv)
>>+{
>>+	drv->driver.bus = &spi_bus;
>>+	drv->driver.probe = spi_driver_probe;
>>+	drv->driver.remove = spi_driver_remove;
>>+	drv->driver.shutdown = spi_driver_shutdown;
>>    
>>
>
>  
>
>>+	drv->driver.suspend = spi_driver_suspend;
>>+	drv->driver.resume = spi_driver_resume;
>>    
>>
>
>As a result of the comment above, you don't need these two initialisers.
>
>  
>
Yup. Thanks.

Vitaly


  reply	other threads:[~2005-12-01 16:30 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-01 16:11 [PATCH 2.6-git] SPI core refresh Vitaly Wool
2005-12-01 16:18 ` [PATCH 2.6-git] MTD/SPI dataflash driver Vitaly Wool
2005-12-01 18:33   ` David Brownell
2005-12-02  6:01     ` Vitaly Wool
2005-12-02 22:07       ` David Brownell
2005-12-01 16:21 ` [PATCH 2.6-git] SPI core refresh Russell King
2005-12-01 16:30   ` Vitaly Wool [this message]
2005-12-01 18:04 ` Stephen Street
2005-12-01 18:22 ` Greg KH
2005-12-02  6:06   ` Vitaly Wool
2005-12-02 18:50     ` Mark Underwood
2005-12-02 20:13     ` Greg KH
2005-12-05 18:01 ` Vitaly Wool
2005-12-08  1:59   ` David Brownell
2005-12-08  6:33     ` Vitaly Wool
2005-12-09 22:55       ` David Brownell
2005-12-10 11:15         ` Vitaly Wool
2005-12-11 12:36         ` Vitaly Wool
2005-12-11 17:03           ` [spi-devel-general] " Vitaly Wool
2005-12-11 20:17             ` David Brownell
2005-12-11 22:13               ` Vitaly Wool
2005-12-11 23:54                 ` David Brownell
2005-12-12  7:09                   ` Vitaly Wool
2005-12-11 22:15               ` Vitaly Wool
2005-12-11 22:18               ` Vitaly Wool
  -- strict thread matches above, loose matches on Subject: below --
2005-12-03 11:49 vitalhome
2005-12-03 17:10 ` Mark Underwood
2005-12-03 23:50   ` David Brownell
2005-12-03 11:44 vitalhome
2005-11-30 16:50 Vitaly Wool
2005-11-30 19:17 ` Russell King
2005-11-30 19:54 ` Greg KH
2005-11-30 20:29 ` Mark Underwood
2005-12-01  7:17   ` Vitaly Wool
2005-12-01 18:31     ` David Brownell
2005-12-02  5:48       ` Vitaly Wool
2005-12-02 18:37         ` Mark Underwood
2005-11-30 21:26 ` David Brownell
2005-11-30 21:27 ` David Brownell
2005-12-12 16:57   ` Vitaly Wool
2005-12-13 22:16     ` David Brownell
2005-11-30 21:36 ` David Brownell
2005-11-30 21:59   ` Stephen Street
2005-12-01  7:31     ` Vitaly Wool
2005-12-01  7:24   ` Vitaly Wool

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=438F253E.20303@ru.mvista.com \
    --to=vwool@ru.mvista.com \
    --cc=Joachim_Jaeger@digi.com \
    --cc=akpm@osdl.org \
    --cc=basicmark@yahoo.com \
    --cc=david-b@pacbell.net \
    --cc=dpervushin@gmail.com \
    --cc=greg@kroah.com \
    --cc=komal_shah802003@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    --cc=spi-devel-general@lists.sourceforge.net \
    --cc=stephen@streetfiresound.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.