Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Torvalds committed Feb 8, 2006
2 parents b4669d6 + 276e0c7 commit 92118c7
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 172 deletions.
23 changes: 17 additions & 6 deletions Documentation/spi/butterfly
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ You can make this adapter from an old printer cable and solder things
directly to the Butterfly. Or (if you have the parts and skills) you
can come up with something fancier, providing ciruit protection to the
Butterfly and the printer port, or with a better power supply than two
signal pins from the printer port.
signal pins from the printer port. Or for that matter, you can use
similar cables to talk to many AVR boards, even a breadboard.

This is more powerful than "ISP programming" cables since it lets kernel
SPI protocol drivers interact with the AVR, and could even let the AVR
issue interrupts to them. Later, your protocol driver should work
easily with a "real SPI controller", instead of this bitbanger.


The first cable connections will hook Linux up to one SPI bus, with the
AVR and a DataFlash chip; and to the AVR reset line. This is all you
need to reflash the firmware, and the pins are the standard Atmel "ISP"
connector pins (used also on non-Butterfly AVR boards).
connector pins (used also on non-Butterfly AVR boards). On the parport
side this is like "sp12" programming cables.

Signal Butterfly Parport (DB-25)
------ --------- ---------------
Expand All @@ -40,10 +47,14 @@ by clearing PORTB.[0-3]); (b) configure the mtd_dataflash driver; and
SELECT = J400.PB0/nSS = pin 17/C3,nSELECT
GND = J400.GND = pin 24/GND

The "USI" controller, using J405, can be used for a second SPI bus. That
would let you talk to the AVR over SPI, running firmware that makes it act
as an SPI slave, while letting either Linux or the AVR use the DataFlash.
There are plenty of spare parport pins to wire this one up, such as:
Or you could flash firmware making the AVR into an SPI slave (keeping the
DataFlash in reset) and tweak the spi_butterfly driver to make it bind to
the driver for your custom SPI-based protocol.

The "USI" controller, using J405, can also be used for a second SPI bus.
That would let you talk to the AVR using custom SPI-with-USI firmware,
while letting either Linux or the AVR use the DataFlash. There are plenty
of spare parport pins to wire this one up, such as:

Signal Butterfly Parport (DB-25)
------ --------- ---------------
Expand Down
4 changes: 4 additions & 0 deletions drivers/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ extern void bus_remove_driver(struct device_driver *);
extern void driver_detach(struct device_driver * drv);
extern int driver_probe_device(struct device_driver *, struct device *);

extern void sysdev_shutdown(void);
extern int sysdev_suspend(pm_message_t state);
extern int sysdev_resume(void);

static inline struct class_device *to_class_dev(struct kobject *obj)
{
return container_of(obj, struct class_device, kobj);
Expand Down
3 changes: 1 addition & 2 deletions drivers/base/power/resume.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
*/

#include <linux/device.h>
#include "../base.h"
#include "power.h"

extern int sysdev_resume(void);


/**
* resume_device - Restore state for one device.
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/power/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/device.h>
#include <asm/semaphore.h>

#include "../base.h"
#include "power.h"

#define to_dev(node) container_of(node, struct device, kobj.entry)
Expand All @@ -28,7 +29,6 @@ extern struct subsystem devices_subsys;
* they only get one called once when interrupts are disabled.
*/

extern int sysdev_shutdown(void);

/**
* device_shutdown - call ->shutdown() on each device to shutdown.
Expand Down
3 changes: 1 addition & 2 deletions drivers/base/power/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
*/

#include <linux/device.h>
#include "../base.h"
#include "power.h"

extern int sysdev_suspend(pm_message_t state);

/*
* The entries in the dpm_active list are in a depth first order, simply
* because children are guaranteed to be discovered after parents, and
Expand Down
24 changes: 16 additions & 8 deletions drivers/base/power/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,30 @@

static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
{
return sprintf(buf, "%u\n", dev->power.power_state.event);
if (dev->power.power_state.event)
return sprintf(buf, "2\n");
else
return sprintf(buf, "0\n");
}

static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
{
pm_message_t state;
char * rest;
int error = 0;
int error = -EINVAL;

state.event = simple_strtoul(buf, &rest, 10);
if (*rest)
return -EINVAL;
if (state.event)
state.event = PM_EVENT_SUSPEND;
/* Older apps expected to write "3" here - confused with PCI D3 */
if ((n == 1) && !strcmp(buf, "3"))
error = dpm_runtime_suspend(dev, state);
else

if ((n == 1) && !strcmp(buf, "2"))
error = dpm_runtime_suspend(dev, state);

if ((n == 1) && !strcmp(buf, "0")) {
dpm_runtime_resume(dev);
error = 0;
}

return error ? error : n;
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/base/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/pm.h>
#include <linux/device.h>
#include <asm/semaphore.h>

#include "base.h"

extern struct subsystem devices_subsys;

#define to_sysdev(k) container_of(k, struct sys_device, kobj)
Expand Down
10 changes: 4 additions & 6 deletions drivers/char/drm/drmP.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ extern int drm_put_head(drm_head_t * head);
extern unsigned int drm_debug;
extern unsigned int drm_cards_limit;
extern drm_head_t **drm_heads;
extern struct drm_sysfs_class *drm_class;
extern struct class *drm_class;
extern struct proc_dir_entry *drm_proc_root;

/* Proc support (drm_proc.h) */
Expand Down Expand Up @@ -1011,11 +1011,9 @@ extern void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah);
extern void drm_pci_free(drm_device_t * dev, drm_dma_handle_t * dmah);

/* sysfs support (drm_sysfs.c) */
struct drm_sysfs_class;
extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner,
char *name);
extern void drm_sysfs_destroy(struct drm_sysfs_class *cs);
extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
extern struct class *drm_sysfs_create(struct module *owner, char *name);
extern void drm_sysfs_destroy(struct class *cs);
extern struct class_device *drm_sysfs_device_add(struct class *cs,
drm_head_t *head);
extern void drm_sysfs_device_remove(struct class_device *class_dev);

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module_param_named(cards_limit, drm_cards_limit, int, 0444);
module_param_named(debug, drm_debug, int, 0600);

drm_head_t **drm_heads;
struct drm_sysfs_class *drm_class;
struct class *drm_class;
struct proc_dir_entry *drm_proc_root;

static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
Expand Down
131 changes: 30 additions & 101 deletions drivers/char/drm/drm_sysfs.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* drm_sysfs.c - Modifications to drm_sysfs_class.c to support
* extra sysfs attribute from DRM. Normal drm_sysfs_class
Expand All @@ -19,36 +20,6 @@
#include "drm_core.h"
#include "drmP.h"

struct drm_sysfs_class {
struct class_device_attribute attr;
struct class class;
};
#define to_drm_sysfs_class(d) container_of(d, struct drm_sysfs_class, class)

struct simple_dev {
dev_t dev;
struct class_device class_dev;
};
#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)

static void release_simple_dev(struct class_device *class_dev)
{
struct simple_dev *s_dev = to_simple_dev(class_dev);
kfree(s_dev);
}

static ssize_t show_dev(struct class_device *class_dev, char *buf)
{
struct simple_dev *s_dev = to_simple_dev(class_dev);
return print_dev_t(buf, s_dev->dev);
}

static void drm_sysfs_class_release(struct class *class)
{
struct drm_sysfs_class *cs = to_drm_sysfs_class(class);
kfree(cs);
}

/* Display the version of drm_core. This doesn't work right in current design */
static ssize_t version_show(struct class *dev, char *buf)
{
Expand All @@ -69,38 +40,16 @@ static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
* Note, the pointer created here is to be destroyed when finished by making a
* call to drm_sysfs_destroy().
*/
struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name)
struct class *drm_sysfs_create(struct module *owner, char *name)
{
struct drm_sysfs_class *cs;
int retval;

cs = kmalloc(sizeof(*cs), GFP_KERNEL);
if (!cs) {
retval = -ENOMEM;
goto error;
}
memset(cs, 0x00, sizeof(*cs));

cs->class.name = name;
cs->class.class_release = drm_sysfs_class_release;
cs->class.release = release_simple_dev;

cs->attr.attr.name = "dev";
cs->attr.attr.mode = S_IRUGO;
cs->attr.attr.owner = owner;
cs->attr.show = show_dev;
cs->attr.store = NULL;

retval = class_register(&cs->class);
if (retval)
goto error;
class_create_file(&cs->class, &class_attr_version);

return cs;

error:
kfree(cs);
return ERR_PTR(retval);
struct class *class;

class = class_create(owner, name);
if (!class)
return class;

class_create_file(class, &class_attr_version);
return class;
}

/**
Expand All @@ -110,12 +59,13 @@ struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name)
* Note, the pointer to be destroyed must have been created with a call to
* drm_sysfs_create().
*/
void drm_sysfs_destroy(struct drm_sysfs_class *cs)
void drm_sysfs_destroy(struct class *class)
{
if ((cs == NULL) || (IS_ERR(cs)))
if ((class == NULL) || (IS_ERR(class)))
return;

class_unregister(&cs->class);
class_remove_file(class, &class_attr_version);
class_destroy(class);
}

static ssize_t show_dri(struct class_device *class_device, char *buf)
Expand All @@ -132,7 +82,7 @@ static struct class_device_attribute class_device_attrs[] = {

/**
* drm_sysfs_device_add - adds a class device to sysfs for a character driver
* @cs: pointer to the struct drm_sysfs_class that this device should be registered to.
* @cs: pointer to the struct class that this device should be registered to.
* @dev: the dev_t for the device to be added.
* @device: a pointer to a struct device that is assiociated with this class device.
* @fmt: string for the class device's name
Expand All @@ -141,46 +91,26 @@ static struct class_device_attribute class_device_attrs[] = {
* class. A "dev" file will be created, showing the dev_t for the device. The
* pointer to the struct class_device will be returned from the call. Any further
* sysfs files that might be required can be created using this pointer.
* Note: the struct drm_sysfs_class passed to this function must have previously been
* Note: the struct class passed to this function must have previously been
* created with a call to drm_sysfs_create().
*/
struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
drm_head_t *head)
struct class_device *drm_sysfs_device_add(struct class *cs, drm_head_t *head)
{
struct simple_dev *s_dev = NULL;
int i, retval;

if ((cs == NULL) || (IS_ERR(cs))) {
retval = -ENODEV;
goto error;
}

s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
if (!s_dev) {
retval = -ENOMEM;
goto error;
}
memset(s_dev, 0x00, sizeof(*s_dev));

s_dev->dev = MKDEV(DRM_MAJOR, head->minor);
s_dev->class_dev.dev = &(head->dev->pdev)->dev;
s_dev->class_dev.class = &cs->class;
struct class_device *class_dev;
int i;

snprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, "card%d", head->minor);
retval = class_device_register(&s_dev->class_dev);
if (retval)
goto error;
class_dev = class_device_create(cs, NULL,
MKDEV(DRM_MAJOR, head->minor),
&(head->dev->pdev)->dev,
"card%d", head->minor);
if (!class_dev)
return NULL;

class_device_create_file(&s_dev->class_dev, &cs->attr);
class_set_devdata(&s_dev->class_dev, head);
class_set_devdata(class_dev, head);

for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]);
return &s_dev->class_dev;

error:
kfree(s_dev);
return ERR_PTR(retval);
class_device_create_file(class_dev, &class_device_attrs[i]);
return class_dev;
}

/**
Expand All @@ -192,10 +122,9 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
*/
void drm_sysfs_device_remove(struct class_device *class_dev)
{
struct simple_dev *s_dev = to_simple_dev(class_dev);
int i;

for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_remove_file(&s_dev->class_dev, &class_device_attrs[i]);
class_device_unregister(&s_dev->class_dev);
class_device_remove_file(class_dev, &class_device_attrs[i]);
class_device_unregister(class_dev);
}
13 changes: 1 addition & 12 deletions drivers/infiniband/core/ucm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,15 +1319,6 @@ static struct class ucm_class = {
.release = ib_ucm_release_class_dev
};

static ssize_t show_dev(struct class_device *class_dev, char *buf)
{
struct ib_ucm_device *dev;

dev = container_of(class_dev, struct ib_ucm_device, class_dev);
return print_dev_t(buf, dev->dev.dev);
}
static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);

static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
{
struct ib_ucm_device *dev;
Expand Down Expand Up @@ -1364,14 +1355,12 @@ static void ib_ucm_add_one(struct ib_device *device)

ucm_dev->class_dev.class = &ucm_class;
ucm_dev->class_dev.dev = device->dma_device;
ucm_dev->class_dev.devt = ucm_dev->dev.dev;
snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d",
ucm_dev->devnum);
if (class_device_register(&ucm_dev->class_dev))
goto err_cdev;

if (class_device_create_file(&ucm_dev->class_dev,
&class_device_attr_dev))
goto err_class;
if (class_device_create_file(&ucm_dev->class_dev,
&class_device_attr_ibdev))
goto err_class;
Expand Down
Loading

0 comments on commit 92118c7

Please sign in to comment.