RE: [PATCH v1 2/3] OMAP4: Ethernet: KS8851 Board Support

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

 



Manjunath,

> > > > > > > +
> > > > > > > +static void omap_ethernet_init(void)
> > > > > > > +{
> > > > > > > +	gpio_request(ETHERNET_KS8851_POWER_ENABLE, "ethernet");
> > > > > > > +	gpio_direction_output(ETHERNET_KS8851_POWER_ENABLE, 1);
> > > > > > > +	gpio_request(ETHERNET_KS8851_QUART, "quart");
> > > > > > > +	gpio_direction_output(ETHERNET_KS8851_QUART, 1);
> > > > > > > +	gpio_request(ETHERNET_KS8851_IRQ, "ks8851");
> > > > > >
> > > > > > Any reason for not checking return value of gpio_request()?
> > > > > >

[snip]

> Minor changes:
> if (gpio_request(x))
> 	return status;
> if (gpio_request(y))
> 	goto err1;
> if (gpio_request(z))
> 	goto err2;
> ...
> 	return 0;
> 
> err2:
> 	free(y);
> 
> err1:
> 	free(x);
> 	return status;

How about this patch?

Note. I am thinking in spi_register_board_info registration:

1. to be done if ethernet fails, other spi dev can be added in future
2. not to be done if ethernet fails, no other dev in spi bus 1 for now

What is the best approach? Is it to keep #2?

---

#define ETH_KS8851_IRQ			34
#define ETH_KS8851_POWER_ON		48
#define ETH_KS8851_QUART		138

static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
	{
		.modalias               = "ks8851",
		.bus_num                = 1,
		.chip_select            = 0,
		.max_speed_hz           = 24000000,
		.irq                    = ETH_KS8851_IRQ,
	},
};

static int omap_ethernet_init(void)
{
	int status;

	status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
	if (status < 0) {
		pr_warning("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
		return status;
	}

	status = gpio_request(ETH_KS8851_QUART, "quart");
	if (status < 0) {
		pr_warning("Cannot request GPIO %d\n", ETH_KS8851_QUART);
		goto err1;
	}

	status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
	if (status < 0) {
		pr_warning("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
		goto err2;
	}

	gpio_direction_output(ETH_KS8851_POWER_ON, 1);
	gpio_direction_output(ETH_KS8851_QUART, 1);
	gpio_direction_input(ETH_KS8851_IRQ);

	return status;

err2:
	gpio_free(ETH_KS8851_QUART);
err1:
	gpio_free(ETH_KS8851_POWER_ON);
	return status;

}


[...]


 	/* FIXME: allow multi-omap to boot until musb is updated for omap4 */
 	if (!cpu_is_omap44xx())
 		usb_musb_init(&musb_board_data);

	status = omap_ethernet_init();
	if (status)
		pr_warning("Ethernet initialization failed: %d\n", status);
	else
		sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);

	spi_register_board_info(sdp4430_spi_board_info,
			ARRAY_SIZE(sdp4430_spi_board_info));


Best Regards
Abraham
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux