+static int spi_test_probe(struct device *dev)What if pdev->dev.platform_data is NULL?
+{
+ struct spi_adapter *sadap;
+ struct platform_device *pdev = to_platform_device(dev);
+ int stat;
+
+ printk("spi_test_probe\n");
+
+ sadap = kmalloc(sizeof(struct spi_adapter), GFP_KERNEL);
+ if(!sadap)
+ {
+ return -ENOMEM;
+ }
+ memset(sadap, 0, sizeof(struct spi_adapter));
+
+ sadap->spi_adap_cs = NULL;
+ sadap->cs_table = ((struct spi_platform_data*) (pdev->dev.platform_data))->cs_table;
+ sadap->max_cs = ((struct spi_platform_data*) (pdev->dev.platform_data))->max_cs;
diff -uprN -X dontdiff linux-2.6.10.orig/drivers/spi/chips/spi-bar.c linux-2.6.10/drivers/spi/chips/spi-bar.cI'm afraid the example provided can not give any idea on the intended usage.
--- linux-2.6.10.orig/drivers/spi/chips/spi-bar.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.10/drivers/spi/chips/spi-bar.c 2005-09-02 17:29:16.000000000 +0100
diff -uprN -X dontdiff linux-2.6.10.orig/drivers/spi/spi-core.c linux-2.6.10/drivers/spi/spi-core.cShouldn't those be static?
--- linux-2.6.10.orig/drivers/spi/spi-core.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.10/drivers/spi/spi-core.c 2005-09-02 17:29:50.000000000 +0100
@@ -0,0 +1,613 @@
+/*
+ * linux/driver/spi/spi-core.c - The spi subsystem core layer
+ *
+ * Copyright (C) 2005 Philips Semicondutors, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Authors:
+ * Mark Underwood
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/spi.h>
+#include <linux/idr.h>
+
+#define SPI_CORE_NONE 0
+#define SPI_CORE_BUS 1
+#define SPI_CORE_DRIVER 2
+#define SPI_CORE_CLASS 3
+#define SPI_CORE_DONE 4
+
+static DEFINE_IDR(spi_adapter_idr);
+
+void __spi_device_unregister(struct spi_device * sdev);
+int __spi_device_register(struct spi_device * sdev);
+Spaces after semicolon please.
+ memset(new_device,0,sizeof(struct spi_device));
+fail1:Spaces again. How about using lindent?
+ for (j=0;j<(i-1);j++)
+ flush_workqueue(adap->work_queue);Indentation/tabs.
+static int spi_suspend(struct device * dev, u32 state)Oh my God. It will be called 3 times for each child entry, isn't it?!
+{
+ struct device *child;
+ int ret = 0;
+
+ /* First suspend all the children */
+ list_for_each_entry(child, &dev->children, node) {
+ if (child->driver && child->driver->suspend) {
+ ret = child->driver->suspend(child, state, SUSPEND_DISABLE);
+ if (ret == 0)
+ ret = child->driver->suspend(child, state, SUSPEND_SAVE_STATE);
+ if (ret == 0)
+ ret = child->driver->suspend(child, state, SUSPEND_POWER_DOWN);
+ }
+ }
+Can you please clarify what is 'adapter' here: is it a bus or what?
+ if (ret)
+ return ret;
+
+ /* Then the adapter */
+ if (dev->driver && dev->driver->suspend) {
+ ret = dev->driver->suspend(dev, state, SUSPEND_DISABLE);
+ if (ret == 0)
+ ret = dev->driver->suspend(dev, state, SUSPEND_SAVE_STATE);
+ if (ret == 0)
+ ret = dev->driver->suspend(dev, state, SUSPEND_POWER_DOWN);
+ }
+
+ return ret;
+}
+Same as for suspend.
+static int spi_resume(struct device * dev)
+{
+ int ret = 0;
+ struct device *child;
+
+ /* First resume the adapter */
+ if (dev->driver && dev->driver->resume) {
+ ret = dev->driver->resume(dev, RESUME_POWER_ON);
+ if (ret == 0)
+ ret = dev->driver->resume(dev, RESUME_RESTORE_STATE);
+ if (ret == 0)
+ ret = dev->driver->resume(dev, RESUME_ENABLE);
+ }
+
+ if (ret)
+ return ret;
+
+ /* Then all the children */
+ list_for_each_entry(child, &dev->children, node) {
+ if (child->driver && child->driver->resume) {
+ ret = child->driver->resume(child, RESUME_POWER_ON);
+ if (ret == 0)
+ ret = child->driver->resume(child, RESUME_RESTORE_STATE);
+ if (ret == 0)
+ ret = child->driver->resume(child, RESUME_ENABLE);
+ if (ret)
+ break;
+ }
+ }
+