Skip to content

Commit

Permalink
Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6
Browse files Browse the repository at this point in the history
* 'next-spi' of git://git.secretlab.ca/git/linux-2.6:
  spi/amba_pl022: Fix probe and remove hook section annotations.
  spi/mpc5121: change annotations for probe and remove functions
  spi/bitbang: reinitialize transfer parameters for every message
  spi/spi-gpio: add support for controllers without MISO or MOSI pin
  spi/bitbang: add support for SPI_MASTER_NO_{TX, RX} modes
  SPI100k: Fix 8-bit and RX-only transfers
  spi/mmc_spi: mmc_spi adaptations for SPI bus locking API
  spi/mmc_spi: SPI bus locking API, using mutex

Fix trivial conflict in drivers/spi/mpc512x_psc_spi.c due to 'struct
of_device' => 'struct platform_device' rename and __init/__exit to
__devinit/__devexit fix.
  • Loading branch information
torvalds committed Aug 14, 2010
2 parents 11ac552 + b422588 commit b171aa2
Show file tree
Hide file tree
Showing 14 changed files with 353 additions and 147 deletions.
59 changes: 11 additions & 48 deletions drivers/mmc/host/mmc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mmc_spi_readbytes(struct mmc_spi_host *host, unsigned len)
host->data_dma, sizeof(*host->data),
DMA_FROM_DEVICE);

status = spi_sync(host->spi, &host->readback);
status = spi_sync_locked(host->spi, &host->readback);

if (host->dma_dev)
dma_sync_single_for_cpu(host->dma_dev,
Expand Down Expand Up @@ -541,7 +541,7 @@ mmc_spi_command_send(struct mmc_spi_host *host,
host->data_dma, sizeof(*host->data),
DMA_BIDIRECTIONAL);
}
status = spi_sync(host->spi, &host->m);
status = spi_sync_locked(host->spi, &host->m);

if (host->dma_dev)
dma_sync_single_for_cpu(host->dma_dev,
Expand Down Expand Up @@ -685,7 +685,7 @@ mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t,
host->data_dma, sizeof(*scratch),
DMA_BIDIRECTIONAL);

status = spi_sync(spi, &host->m);
status = spi_sync_locked(spi, &host->m);

if (status != 0) {
dev_dbg(&spi->dev, "write error (%d)\n", status);
Expand Down Expand Up @@ -822,7 +822,7 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t,
DMA_FROM_DEVICE);
}

status = spi_sync(spi, &host->m);
status = spi_sync_locked(spi, &host->m);

if (host->dma_dev) {
dma_sync_single_for_cpu(host->dma_dev,
Expand Down Expand Up @@ -1018,7 +1018,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
host->data_dma, sizeof(*scratch),
DMA_BIDIRECTIONAL);

tmp = spi_sync(spi, &host->m);
tmp = spi_sync_locked(spi, &host->m);

if (host->dma_dev)
dma_sync_single_for_cpu(host->dma_dev,
Expand Down Expand Up @@ -1084,6 +1084,9 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
}
#endif

/* request exclusive bus access */
spi_bus_lock(host->spi->master);

/* issue command; then optionally data and stop */
status = mmc_spi_command_send(host, mrq, mrq->cmd, mrq->data != NULL);
if (status == 0 && mrq->data) {
Expand All @@ -1094,6 +1097,9 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
mmc_cs_off(host);
}

/* release the bus */
spi_bus_unlock(host->spi->master);

mmc_request_done(host->mmc, mrq);
}

Expand Down Expand Up @@ -1290,23 +1296,6 @@ mmc_spi_detect_irq(int irq, void *mmc)
return IRQ_HANDLED;
}

struct count_children {
unsigned n;
struct bus_type *bus;
};

static int maybe_count_child(struct device *dev, void *c)
{
struct count_children *ccp = c;

if (dev->bus == ccp->bus) {
if (ccp->n)
return -EBUSY;
ccp->n++;
}
return 0;
}

static int mmc_spi_probe(struct spi_device *spi)
{
void *ones;
Expand Down Expand Up @@ -1338,32 +1327,6 @@ static int mmc_spi_probe(struct spi_device *spi)
return status;
}

/* We can use the bus safely iff nobody else will interfere with us.
* Most commands consist of one SPI message to issue a command, then
* several more to collect its response, then possibly more for data
* transfer. Clocking access to other devices during that period will
* corrupt the command execution.
*
* Until we have software primitives which guarantee non-interference,
* we'll aim for a hardware-level guarantee.
*
* REVISIT we can't guarantee another device won't be added later...
*/
if (spi->master->num_chipselect > 1) {
struct count_children cc;

cc.n = 0;
cc.bus = spi->dev.bus;
status = device_for_each_child(spi->dev.parent, &cc,
maybe_count_child);
if (status < 0) {
dev_err(&spi->dev, "can't share SPI bus\n");
return status;
}

dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n");
}

/* We need a supply of ones to transmit. This is the only time
* the CPU touches these, so cache coherency isn't a concern.
*
Expand Down
6 changes: 3 additions & 3 deletions drivers/spi/amba-pl022.c
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ static void pl022_cleanup(struct spi_device *spi)
}


static int __init
static int __devinit
pl022_probe(struct amba_device *adev, struct amba_id *id)
{
struct device *dev = &adev->dev;
Expand Down Expand Up @@ -1838,7 +1838,7 @@ pl022_probe(struct amba_device *adev, struct amba_id *id)
return status;
}

static int __exit
static int __devexit
pl022_remove(struct amba_device *adev)
{
struct pl022 *pl022 = amba_get_drvdata(adev);
Expand Down Expand Up @@ -1970,7 +1970,7 @@ static struct amba_driver pl022_driver = {
},
.id_table = pl022_ids,
.probe = pl022_probe,
.remove = __exit_p(pl022_remove),
.remove = __devexit_p(pl022_remove),
.suspend = pl022_suspend,
.resume = pl022_resume,
};
Expand Down
16 changes: 8 additions & 8 deletions drivers/spi/mpc512x_psc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id)
}

/* bus_num is used only for the case dev->platform_data == NULL */
static int __init mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
u32 size, unsigned int irq,
s16 bus_num)
static int __devinit mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
u32 size, unsigned int irq,
s16 bus_num)
{
struct fsl_spi_platform_data *pdata = dev->platform_data;
struct mpc512x_psc_spi *mps;
Expand Down Expand Up @@ -492,7 +492,7 @@ static int __init mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
return ret;
}

static int __exit mpc512x_psc_spi_do_remove(struct device *dev)
static int __devexit mpc512x_psc_spi_do_remove(struct device *dev)
{
struct spi_master *master = dev_get_drvdata(dev);
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
Expand All @@ -507,8 +507,8 @@ static int __exit mpc512x_psc_spi_do_remove(struct device *dev)
return 0;
}

static int __init mpc512x_psc_spi_of_probe(struct platform_device *op,
const struct of_device_id *match)
static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op,
const struct of_device_id *match)
{
const u32 *regaddr_p;
u64 regaddr64, size64;
Expand Down Expand Up @@ -539,7 +539,7 @@ static int __init mpc512x_psc_spi_of_probe(struct platform_device *op,
irq_of_parse_and_map(op->dev.of_node, 0), id);
}

static int __exit mpc512x_psc_spi_of_remove(struct platform_device *op)
static int __devexit mpc512x_psc_spi_of_remove(struct platform_device *op)
{
return mpc512x_psc_spi_do_remove(&op->dev);
}
Expand All @@ -553,7 +553,7 @@ MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);

static struct of_platform_driver mpc512x_psc_spi_of_driver = {
.probe = mpc512x_psc_spi_of_probe,
.remove = __exit_p(mpc512x_psc_spi_of_remove),
.remove = __devexit_p(mpc512x_psc_spi_of_remove),
.driver = {
.name = "mpc512x-psc-spi",
.owner = THIS_MODULE,
Expand Down
23 changes: 12 additions & 11 deletions drivers/spi/omap_spi_100k.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ static void spi100k_write_data(struct spi_master *master, int len, int data)
{
struct omap1_spi100k *spi100k = spi_master_get_devdata(master);

/* write 16-bit word */
/* write 16-bit word, shifting 8-bit data if necessary */
if (len <= 8) {
data <<= 8;
len = 16;
}

spi100k_enable_clock(master);
writew( data , spi100k->base + SPI_TX_MSB);

Expand All @@ -162,6 +167,10 @@ static int spi100k_read_data(struct spi_master *master, int len)
int dataH,dataL;
struct omap1_spi100k *spi100k = spi_master_get_devdata(master);

/* Always do at least 16 bits */
if (len <= 8)
len = 16;

spi100k_enable_clock(master);
writew(SPI_CTRL_SEN(0) |
SPI_CTRL_WORD_SIZE(len) |
Expand Down Expand Up @@ -214,10 +223,6 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
c = count;
word_len = cs->word_len;

/* RX_ONLY mode needs dummy data in TX reg */
if (xfer->tx_buf == NULL)
spi100k_write_data(spi->master,word_len, 0);

if (word_len <= 8) {
u8 *rx;
const u8 *tx;
Expand All @@ -227,9 +232,9 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
do {
c-=1;
if (xfer->tx_buf != NULL)
spi100k_write_data(spi->master,word_len, *tx);
spi100k_write_data(spi->master, word_len, *tx++);
if (xfer->rx_buf != NULL)
*rx = spi100k_read_data(spi->master,word_len);
*rx++ = spi100k_read_data(spi->master, word_len);
} while(c);
} else if (word_len <= 16) {
u16 *rx;
Expand Down Expand Up @@ -380,10 +385,6 @@ static void omap1_spi100k_work(struct work_struct *work)
if (t->len) {
unsigned count;

/* RX_ONLY mode needs dummy data in TX reg */
if (t->tx_buf == NULL)
spi100k_write_data(spi->master, 8, 0);

count = omap1_spi100k_txrx_pio(spi, t);
m->actual_length += count;

Expand Down
Loading

0 comments on commit b171aa2

Please sign in to comment.