From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Vitaly Wool <vwool@ru.mvista.com>
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, 1 Dec 2005 16:21:02 +0000 [thread overview]
Message-ID: <20051201162102.GB31551@flint.arm.linux.org.uk> (raw)
In-Reply-To: <20051201191109.40f2d04b.vwool@ru.mvista.com>
On Thu, Dec 01, 2005 at 07:11:09PM +0300, Vitaly Wool wrote:
> The main changes are:
>
> - Matching rmk's 2.6.14-git5+ changes for device_driver suspend and
> resume calls
> - Matching rmk's request to get rid of device_driver's calls to
> suspend/resume/probe/remove
Thanks. Please see comments below though.
> +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.
> +/**
> + * spi_bus_suspend - suspend all devices on the spi bus
> + *
> + * @dev: spi device to be suspended
> + * @message: PM message
> + *
> + * This function set device on SPI bus to suspended state, just like platform_bus does
> +**/
> +static int spi_bus_suspend(struct device * dev, pm_message_t message)
> +{
> + int ret = 0;
> +
> + if (dev && dev->driver && dev->driver->suspend ) {
> + ret = TO_SPI_DRIVER(dev->driver)->suspend( TO_SPI_DEV(dev), message);
> + if (ret == 0 )
> + dev->power.power_state = message;
> + }
> + return ret;
> +}
> +
> +/**
> + * spi_bus_resume - resume functioning of all devices on spi bus
> + *
> + * @dev: device to resume
> + *
> + * This function resumes device on SPI bus, just like platform_bus does
> +**/
> +static int spi_bus_resume(struct device * dev)
> +{
> + int ret = 0;
> +
> + if (dev && dev->driver && dev->driver->suspend ) {
> + ret = TO_SPI_DRIVER(dev->driver)->resume(TO_SPI_DEV(dev));
> + if (ret == 0)
> + dev->power.power_state = PMSG_ON;
> + }
> + return ret;
> +}
Ok, your bus_type suspend/resume methods call your spi_driver's suspend
and resume methods - good.
> +/*
> + * the functions below are wrappers for corresponding device_driver's methods
> + */
> +int spi_driver_probe (struct device *dev)
> +{
> + struct spi_driver *sdrv = TO_SPI_DRIVER(dev->driver);
> + struct spi_device *sdev = TO_SPI_DEV(dev);
> +
> + return sdrv && sdrv->probe ? sdrv->probe(sdev) : -EFAULT;
> +}
> +
> +int spi_driver_remove (struct device *dev)
> +{
> + struct spi_driver *sdrv = TO_SPI_DRIVER(dev->driver);
> + struct spi_device *sdev = TO_SPI_DEV(dev);
> +
> + return (sdrv && sdrv->remove) ? sdrv->remove(sdev) : -EFAULT;
> +}
These are fine, although sdrv will always be non-NULL here.
> +
> +void spi_driver_shutdown (struct device *dev)
> +{
> + struct spi_driver *sdrv = TO_SPI_DRIVER(dev->driver);
> + struct spi_device *sdev = TO_SPI_DEV(dev);
> +
> + if (sdrv && sdrv->shutdown)
> + sdrv->shutdown(sdev);
> +}
dev->driver may be NULL here. If it is NULL, sdrv will not be.
Hence you want to do:
if (dev->driver && sdrv->shutdown)
instead.
> +
> +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?
> +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.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
next prev parent reply other threads:[~2005-12-01 16:21 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-01 16:11 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 ` Russell King [this message]
2005-12-01 16:30 ` [PATCH 2.6-git] SPI core refresh Vitaly Wool
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=20051201162102.GB31551@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--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=spi-devel-general@lists.sourceforge.net \
--cc=stephen@streetfiresound.com \
--cc=vwool@ru.mvista.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®