Re: [RFC PATCH 2/7] include/linux: add headers for drivers/zio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 26, 2011 at 06:30:31PM +0100, Alessandro Rubini wrote:
> +/*
> + * We use the same functions to deal with attributes, but the structures
> + * we act on may be different (dev, cset, channel). Thus, all structures
> + * begin with the type identifier, and zio_obj_head is used in container_of
> + */

Because you are using container_of, you don't have to have the structure
at the beginning of the structure it is included in, right?

> +enum zio_object_type {
> +	ZNONE = 0,	/* reserved for non zio object */
> +	ZDEV, ZCSET, ZCHAN,
> +	ZTRIG, ZTI,	/* trigger and trigger instance */
> +	ZBUF, ZBI,	/* buffer and buffer instance */
> +};
> +
> +/* zio_obj_head is for internal use only, as explained above */
> +struct zio_obj_head {
> +	struct kobject		kobj;
> +	enum zio_object_type	zobj_type;
> +	char			name[ZIO_NAME_LEN];
> +};
> +#define to_zio_head(_kobj) container_of(_kobj, struct zio_obj_head, kobj)
> +#define to_zio_dev(_kobj) container_of(_kobj, struct zio_device, head.kobj)
> +#define to_zio_cset(_kobj) container_of(_kobj, struct zio_cset, head.kobj)
> +#define to_zio_chan(_kobj) container_of(_kobj, struct zio_channel, head.kobj)

Why are you using a "raw" kobject and not 'struct device' instead?  If
you use a kobject, you loose all of the device tree information that a
real struct device provides to userspace, and can only cause confusion
in the long run.

This also will provide you the "type" and name that you are needing
here, as well as lots of other good things (properly formatted logging
messages, uevents, etc.)

Please consider moving to that instead.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux