Re: [lm-sensors] [PATCH 2.6.12-rc4 15/15] drivers/i2c/chips/adm1026.c: use dynamic sysfs callbacks

From: Greg KH
Date: Thu May 19 2005 - 15:48:53 EST


On Thu, May 19, 2005 at 10:02:35PM +0200, Jean Delvare wrote:
> If we are into code refactoring and driver size shrinking, you may want
> to take a look at the following patch, which makes it87 even smaller
> (from 18976 bytes down to 16992 bytes on my system) and IMHO more
> cleaner.

But this doesn't reduce the binary size of the module, right?

> /* Register sysfs hooks */
> - device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
> - device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
> - device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
> - device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);

<snip>

You know, we do have arrays of attributes that can be registered with a
single call...

I'd recommend using that over this mess anyday :)

> +#define SENSOR_DEVICE_ATTR_ARRAY_HEAD(_name,_size) \
> +struct sensor_device_attribute sensor_dev_attr_##_name[_size] = {
> +
> +#define SENSOR_DEVICE_ATTR_ARRAY_ITEM(_name,_mode,_show,_store,_index) \
> + { .dev_attr=__ATTR(_name,_mode,_show,_store), \
> + .index=_index, },
> +
> +#define SENSOR_DEVICE_ATTR_ARRAY_TAIL \
> +}

No, I hate HEAD and TAIL macros. This really isn't buying you much code
savings, you could do it yourself with the __ATTR() macro yourself with
the same ammount of code I bet...

Or use the new macro that Yani created, that will make it even smaller
:)

thanks,

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