Re: [PATCH 3/6] drivers:misc: sources for ST core

Alan Cox
2010-03-23T15:20:45Z

> +/* all debug macros go in here */
> +#define ST_DRV_ERR(fmt, arg...) printk(KERN_ERR "(stc):"fmt"\n" , ## arg)
> +#if defined(DEBUG) /* limited debug messages */
> +#define ST_DRV_DBG(fmt, arg...) printk(KERN_INFO "(stc):"fmt"\n" , ## arg)
> +#define ST_DRV_VER(fmt, arg...)
> +#elif defined(VERBOSE) /* very verbose */
> +#define ST_DRV_DBG(fmt, arg...) printk(KERN_INFO "(stc):"fmt"\n" , ## arg)
> +#define ST_DRV_VER(fmt, arg...) printk(KERN_INFO "(stc):"fmt"\n" , ## arg)
> +#else /* error msgs only */
> +#define ST_DRV_DBG(fmt, arg...)
> +#define ST_DRV_VER(fmt, arg...)
> +#endif

Use the existing debug macros

> +/* function pointer pointing to either,
> + * st_kim_recv during registration to receive fw download responses
> + * st_int_recv after registration to receive proto stack responses
> + */
> +void (*st_recv) (const unsigned char *data, long count);

What if you have multiple devices at once one in each state ?
Why is this global ?

> + if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {

Again shouldn't be using globals and needs to support multiple devices.
See the tty_struct - there is a field for an ldisc pointer, stuff
st_gdata in there at open time and pass tty around ?

> + ST_DRV_ERR("tty unavailable to perform write");
> + return ST_ERR_FAILURE;
> + }
> + tty = st_gdata->tty;

Explain the locking on this NULL test - what stops it becoming NULL
between the if and the assignment ?

I think this code needs a fair bit of work at this point - locking,
supporting multiple devices at once etc.

Staging perhaps ?