Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 131668
b: refs/heads/master
c: 7c24af4
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Feb 22, 2009
1 parent b27c6f8 commit 44741be
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 82 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5acfac5a6473b459ed38c0edf515be030f3b5874
refs/heads/master: 7c24af498f60e41b9363d3102a31f8cfa6589ca3
8 changes: 5 additions & 3 deletions trunk/Documentation/driver-model/device.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ void unlock_device(struct device * dev);
Attributes
~~~~~~~~~~
struct device_attribute {
struct attribute attr;
ssize_t (*show)(struct device * dev, char * buf, size_t count, loff_t off);
ssize_t (*store)(struct device * dev, const char * buf, size_t count, loff_t off);
struct attribute attr;
ssize_t (*show)(struct device *dev, struct device_attribute *attr,
char *buf);
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
};

Attributes of devices can be exported via drivers using a simple
Expand Down
50 changes: 28 additions & 22 deletions trunk/Documentation/filesystems/sysfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
sysfs - _The_ filesystem for exporting kernel objects.

Patrick Mochel <mochel@osdl.org>
Mike Murphy <mamurph@cs.clemson.edu>

10 January 2003
Revised: 22 February 2009
Original: 10 January 2003


What it is:
Expand Down Expand Up @@ -64,12 +66,13 @@ An attribute definition is simply:

struct attribute {
char * name;
struct module *owner;
mode_t mode;
};


int sysfs_create_file(struct kobject * kobj, struct attribute * attr);
void sysfs_remove_file(struct kobject * kobj, struct attribute * attr);
int sysfs_create_file(struct kobject * kobj, const struct attribute * attr);
void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr);


A bare attribute contains no means to read or write the value of the
Expand All @@ -80,22 +83,20 @@ a specific object type.
For example, the driver model defines struct device_attribute like:

struct device_attribute {
struct attribute attr;
ssize_t (*show)(struct device * dev, char * buf);
ssize_t (*store)(struct device * dev, const char * buf);
struct attribute attr;
ssize_t (*show)(struct device *dev, struct device_attribute *attr,
char *buf);
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
};

int device_create_file(struct device *, struct device_attribute *);
void device_remove_file(struct device *, struct device_attribute *);

It also defines this helper for defining device attributes:

#define DEVICE_ATTR(_name, _mode, _show, _store) \
struct device_attribute dev_attr_##_name = { \
.attr = {.name = __stringify(_name) , .mode = _mode }, \
.show = _show, \
.store = _store, \
};
#define DEVICE_ATTR(_name, _mode, _show, _store) \
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)

For example, declaring

Expand All @@ -107,9 +108,9 @@ static struct device_attribute dev_attr_foo = {
.attr = {
.name = "foo",
.mode = S_IWUSR | S_IRUGO,
.show = show_foo,
.store = store_foo,
},
.show = show_foo,
.store = store_foo,
};


Expand Down Expand Up @@ -161,10 +162,12 @@ To read or write attributes, show() or store() methods must be
specified when declaring the attribute. The method types should be as
simple as those defined for device attributes:

ssize_t (*show)(struct device * dev, char * buf);
ssize_t (*store)(struct device * dev, const char * buf);
ssize_t (*show)(struct device * dev, struct device_attribute * attr,
char * buf);
ssize_t (*store)(struct device * dev, struct device_attribute * attr,
const char * buf);

IOW, they should take only an object and a buffer as parameters.
IOW, they should take only an object, an attribute, and a buffer as parameters.


sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the
Expand Down Expand Up @@ -299,14 +302,16 @@ The following interface layers currently exist in sysfs:
Structure:

struct device_attribute {
struct attribute attr;
ssize_t (*show)(struct device * dev, char * buf);
ssize_t (*store)(struct device * dev, const char * buf);
struct attribute attr;
ssize_t (*show)(struct device *dev, struct device_attribute *attr,
char *buf);
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
};

Declaring:

DEVICE_ATTR(_name, _str, _mode, _show, _store);
DEVICE_ATTR(_name, _mode, _show, _store);

Creation/Removal:

Expand Down Expand Up @@ -342,7 +347,8 @@ Structure:
struct driver_attribute {
struct attribute attr;
ssize_t (*show)(struct device_driver *, char * buf);
ssize_t (*store)(struct device_driver *, const char * buf);
ssize_t (*store)(struct device_driver *, const char * buf,
size_t count);
};

Declaring:
Expand Down
16 changes: 8 additions & 8 deletions trunk/arch/m68k/atari/ataints.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ __asm__ (__ALIGN_STR "\n" \
" jbra ret_from_interrupt\n" \
: : "i" (&kstat_cpu(0).irqs[n+8]), "i" (&irq_handler[n+8]), \
"n" (PT_OFF_SR), "n" (n), \
"i" (n & 8 ? (n & 16 ? &tt_mfp.int_mk_a : &mfp.int_mk_a) \
: (n & 16 ? &tt_mfp.int_mk_b : &mfp.int_mk_b)), \
"i" (n & 8 ? (n & 16 ? &tt_mfp.int_mk_a : &st_mfp.int_mk_a) \
: (n & 16 ? &tt_mfp.int_mk_b : &st_mfp.int_mk_b)), \
"m" (preempt_count()), "di" (HARDIRQ_OFFSET) \
); \
for (;;); /* fake noreturn */ \
Expand Down Expand Up @@ -366,14 +366,14 @@ void __init atari_init_IRQ(void)
/* Initialize the MFP(s) */

#ifdef ATARI_USE_SOFTWARE_EOI
mfp.vec_adr = 0x48; /* Software EOI-Mode */
st_mfp.vec_adr = 0x48; /* Software EOI-Mode */
#else
mfp.vec_adr = 0x40; /* Automatic EOI-Mode */
st_mfp.vec_adr = 0x40; /* Automatic EOI-Mode */
#endif
mfp.int_en_a = 0x00; /* turn off MFP-Ints */
mfp.int_en_b = 0x00;
mfp.int_mk_a = 0xff; /* no Masking */
mfp.int_mk_b = 0xff;
st_mfp.int_en_a = 0x00; /* turn off MFP-Ints */
st_mfp.int_en_b = 0x00;
st_mfp.int_mk_a = 0xff; /* no Masking */
st_mfp.int_mk_b = 0xff;

if (ATARIHW_PRESENT(TT_MFP)) {
#ifdef ATARI_USE_SOFTWARE_EOI
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/m68k/atari/atakeyb.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@ int atari_keyb_init(void)
ACIA_RHTID : 0);

/* make sure the interrupt line is up */
} while ((mfp.par_dt_reg & 0x10) == 0);
} while ((st_mfp.par_dt_reg & 0x10) == 0);

/* enable ACIA Interrupts */
mfp.active_edge &= ~0x10;
st_mfp.active_edge &= ~0x10;
atari_turnon_irq(IRQ_MFP_ACIA);

ikbd_self_test = 1;
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/m68k/atari/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void __init config_atari(void)
printk("STND_SHIFTER ");
}
}
if (hwreg_present(&mfp.par_dt_reg)) {
if (hwreg_present(&st_mfp.par_dt_reg)) {
ATARIHW_SET(ST_MFP);
printk("ST_MFP ");
}
Expand Down
22 changes: 11 additions & 11 deletions trunk/arch/m68k/atari/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ static struct console atari_console_driver = {

static inline void ata_mfp_out(char c)
{
while (!(mfp.trn_stat & 0x80)) /* wait for tx buf empty */
while (!(st_mfp.trn_stat & 0x80)) /* wait for tx buf empty */
barrier();
mfp.usart_dta = c;
st_mfp.usart_dta = c;
}

static void atari_mfp_console_write(struct console *co, const char *str,
Expand Down Expand Up @@ -91,7 +91,7 @@ static int ata_par_out(char c)
/* This a some-seconds timeout in case no printer is connected */
unsigned long i = loops_per_jiffy > 1 ? loops_per_jiffy : 10000000/HZ;

while ((mfp.par_dt_reg & 1) && --i) /* wait for BUSY == L */
while ((st_mfp.par_dt_reg & 1) && --i) /* wait for BUSY == L */
;
if (!i)
return 0;
Expand Down Expand Up @@ -131,9 +131,9 @@ static void atari_par_console_write(struct console *co, const char *str,
#if 0
int atari_mfp_console_wait_key(struct console *co)
{
while (!(mfp.rcv_stat & 0x80)) /* wait for rx buf filled */
while (!(st_mfp.rcv_stat & 0x80)) /* wait for rx buf filled */
barrier();
return mfp.usart_dta;
return st_mfp.usart_dta;
}

int atari_scc_console_wait_key(struct console *co)
Expand Down Expand Up @@ -175,12 +175,12 @@ static void __init atari_init_mfp_port(int cflag)
baud = B9600; /* use default 9600bps for non-implemented rates */
baud -= B1200; /* baud_table[] starts at 1200bps */

mfp.trn_stat &= ~0x01; /* disable TX */
mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */
mfp.tim_ct_cd &= 0x70; /* stop timer D */
mfp.tim_dt_d = baud_table[baud];
mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */
mfp.trn_stat |= 0x01; /* enable TX */
st_mfp.trn_stat &= ~0x01; /* disable TX */
st_mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */
st_mfp.tim_ct_cd &= 0x70; /* stop timer D */
st_mfp.tim_dt_d = baud_table[baud];
st_mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */
st_mfp.trn_stat |= 0x01; /* enable TX */
}

#define SCC_WRITE(reg, val) \
Expand Down
8 changes: 4 additions & 4 deletions trunk/arch/m68k/atari/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void __init
atari_sched_init(irq_handler_t timer_routine)
{
/* set Timer C data Register */
mfp.tim_dt_c = INT_TICKS;
st_mfp.tim_dt_c = INT_TICKS;
/* start timer C, div = 1:100 */
mfp.tim_ct_cd = (mfp.tim_ct_cd & 15) | 0x60;
st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 15) | 0x60;
/* install interrupt service routine for MFP Timer C */
if (request_irq(IRQ_MFP_TIMC, timer_routine, IRQ_TYPE_SLOW,
"timer", timer_routine))
Expand All @@ -46,11 +46,11 @@ unsigned long atari_gettimeoffset (void)
unsigned long ticks, offset = 0;

/* read MFP timer C current value */
ticks = mfp.tim_dt_c;
ticks = st_mfp.tim_dt_c;
/* The probability of underflow is less than 2% */
if (ticks > INT_TICKS - INT_TICKS / 50)
/* Check for pending timer interrupt */
if (mfp.int_pn_b & (1 << 5))
if (st_mfp.int_pn_b & (1 << 5))
offset = TICK_SIZE;

ticks = INT_TICKS - ticks;
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/m68k/include/asm/atarihw.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extern struct atari_hw_present atari_hw_present;
* of nops on various machines. Somebody claimed that the tstb takes 600 ns.
*/
#define MFPDELAY() \
__asm__ __volatile__ ( "tstb %0" : : "m" (mfp.par_dt_reg) : "cc" );
__asm__ __volatile__ ( "tstb %0" : : "m" (st_mfp.par_dt_reg) : "cc" );

/* Do cache push/invalidate for DMA read/write. This function obeys the
* snooping on some machines (Medusa) and processors: The Medusa itself can
Expand Down Expand Up @@ -565,7 +565,7 @@ struct MFP
u_char char_dummy23;
u_char usart_dta;
};
# define mfp ((*(volatile struct MFP*)MFP_BAS))
# define st_mfp ((*(volatile struct MFP*)MFP_BAS))

/* TT's second MFP */

Expand Down
6 changes: 3 additions & 3 deletions trunk/arch/m68k/include/asm/atariints.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static inline int get_mfp_bit( unsigned irq, int type )
{ unsigned char mask, *reg;

mask = 1 << (irq & 7);
reg = (unsigned char *)&mfp.int_en_a + type*4 +
reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
((irq & 8) >> 2) + (((irq-8) & 16) << 3);
return( *reg & mask );
}
Expand All @@ -123,7 +123,7 @@ static inline void set_mfp_bit( unsigned irq, int type )
{ unsigned char mask, *reg;

mask = 1 << (irq & 7);
reg = (unsigned char *)&mfp.int_en_a + type*4 +
reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
((irq & 8) >> 2) + (((irq-8) & 16) << 3);
__asm__ __volatile__ ( "orb %0,%1"
: : "di" (mask), "m" (*reg) : "memory" );
Expand All @@ -134,7 +134,7 @@ static inline void clear_mfp_bit( unsigned irq, int type )
{ unsigned char mask, *reg;

mask = ~(1 << (irq & 7));
reg = (unsigned char *)&mfp.int_en_a + type*4 +
reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
((irq & 8) >> 2) + (((irq-8) & 16) << 3);
if (type == MFP_PENDING || type == MFP_SERVICE)
__asm__ __volatile__ ( "moveb %0,%1"
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/block/ataflop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ static int __init fd_test_drive_present( int drive )

timeout = jiffies + 2*HZ+HZ/2;
while (time_before(jiffies, timeout))
if (!(mfp.par_dt_reg & 0x20))
if (!(st_mfp.par_dt_reg & 0x20))
break;

status = FDC_READ( FDCREG_STATUS );
Expand All @@ -1747,7 +1747,7 @@ static int __init fd_test_drive_present( int drive )
/* dummy seek command to make WP bit accessible */
FDC_WRITE( FDCREG_DATA, 0 );
FDC_WRITE( FDCREG_CMD, FDCCMD_SEEK );
while( mfp.par_dt_reg & 0x20 )
while( st_mfp.par_dt_reg & 0x20 )
;
status = FDC_READ( FDCREG_STATUS );
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/char/scc.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ struct scc_port {
/* The SCC needs 3.5 PCLK cycles recovery time between to register
* accesses. PCLK runs with 8 MHz on an Atari, so this delay is 3.5 *
* 125 ns = 437.5 ns. This is too short for udelay().
* 10/16/95: A tstb mfp.par_dt_reg takes 600ns (sure?) and thus should be
* 10/16/95: A tstb st_mfp.par_dt_reg takes 600ns (sure?) and thus should be
* quite right
*/

Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/parport/parport_atari.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ parport_atari_frob_control(struct parport *p, unsigned char mask,
static unsigned char
parport_atari_read_status(struct parport *p)
{
return ((mfp.par_dt_reg & 1 ? 0 : PARPORT_STATUS_BUSY) |
return ((st_mfp.par_dt_reg & 1 ? 0 : PARPORT_STATUS_BUSY) |
PARPORT_STATUS_SELECT | PARPORT_STATUS_ERROR);
}

Expand Down Expand Up @@ -193,9 +193,9 @@ static int __init parport_atari_init(void)
sound_ym.wd_data = sound_ym.rd_data_reg_sel | (1 << 5);
local_irq_restore(flags);
/* MFP port I0 as input. */
mfp.data_dir &= ~1;
st_mfp.data_dir &= ~1;
/* MFP port I0 interrupt on high->low edge. */
mfp.active_edge &= ~1;
st_mfp.active_edge &= ~1;
p = parport_register_port((unsigned long)&sound_ym.wd_data,
IRQ_MFP_BUSY, PARPORT_DMA_NONE,
&parport_atari_ops);
Expand Down
Loading

0 comments on commit 44741be

Please sign in to comment.