Re: [PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines ALIX.2 and ALIX.3 boards

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrew Morton
Date: Friday, August 22, 2008 - 2:31 pm

On Sat, 23 Aug 2008 02:08:15 +0500
Constantin Baranov <const@const.mimas.ru> wrote:


ug, OK, the complex expression in that for-loop is to blame.

For maintinability we should aim for code which is as simple and as
straightfroward as possible and which adheres to oft-used and
well-understood kernel idioms.

For example, this?

static int __init alix_led_probe(struct platform_device *pdev)
{
	int i;
	int ret;

	for (i = 0; i < ARRAY_SIZE(alix_leds); i++) {
		ret = led_classdev_register(&pdev->dev, &alix_leds[i].cdev);
		if (ret < 0)
			goto fail;
	}
	return 0;

fail:
	while (--i >= 0)
		led_classdev_unregister(&alix_leds[i].cdev);
	return ret;
}

(note there's no longer a need for a fake initalisation of `ret')


That's what you get for copying stuff :(
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines ALIX. ..., Constantin Baranov, (Tue Aug 19, 10:23 am)
Re: [PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines A ..., Constantin Baranov, (Fri Aug 22, 2:08 pm)
Re: [PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines A ..., Andrew Morton, (Fri Aug 22, 2:31 pm)
Re: [PATCH 2.6.27-rc3] led: driver for LEDs on PCEngines A ..., Constantin Baranov, (Sat Aug 23, 10:11 am)