Re: [PATCH V2] CS89x0 : Use ioread16/iowrite16 on all platforms

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

Jaccon Bastiaansen <jaccon.bastiaansen@xxxxxxxxx> :
[...]
> diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c
> index b9406cb..8081ad5 100644
> --- a/drivers/net/ethernet/cirrus/cs89x0.c
> +++ b/drivers/net/ethernet/cirrus/cs89x0.c
[...]
> -static int cs89x0_probe1(struct net_device *dev, unsigned long ioaddr, int modular);
> +static int cs89x0_probe1(struct net_device *dev,
> +			 void __iomem *ioaddr,
> +			 int modular);
> +static int cs89x0_probe1(struct net_device *dev, void __iomem *ioaddr,
> +			 int modular);

s/int/bool/ maybe.

You may skip the name of the parameters.

[...]
> +static int __init
> +cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular)
> +{
> +	struct net_local *lp = netdev_priv(dev);
> +	int ret;
> +	void __iomem *io_mem;
> +
> +	if (!lp)
> +		return -ENOMEM;
> +
> +	dev->base_addr = ioport;

(your changes should reduce the use of netdev.base_addr, nice)

[...]
> +	if (ioport & 1) {
> +		if (net_debug > 1)
> +			printk(KERN_INFO "%s: odd ioaddr 0x%lx\n",
> +			       dev->name,
> +			       ioport);
> +		if ((ioport & 2) != 2)
		if ((ioport & 2) != 2) {

> +			if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) !=
> +			    ADD_SIG) {
> +				printk(KERN_ERR "%s: bad signature 0x%x\n",
> +					dev->name,
> +					ioread16(io_mem + ADD_PORT));

			u16 blah = ioread16(io_mem + ADD_PORT);

			if ((blah & ADD_MASK) != ADD_SIG) {
				printk(KERN_ERR "%s: bad signature 0x%x\n",
					dev->name, blah);

[...]
>  static void
> -readwords(unsigned long base_addr, int portno, void *buf, int length)
> +readwords(void __iomem *base_addr, int portno, void *buf, int length)

You may try the shorter and (arguably) type safer :

static void readwords(struct net_local *lp, int portno, void *buf, int length)

> -writewords(unsigned long base_addr, int portno, void *buf, int length)
> +writewords(void __iomem *base_addr, int portno, void *buf, int length)

Same thing.

[...]
> -	/* Grab the region so we can find another board if autoIRQ fails. */
> -	/* WTF is going on here? */
> -	if (!request_region(ioaddr & ~3, NETCARD_IO_EXTENT, DRV_NAME)) {
> -		printk(KERN_ERR "%s: request_region(0x%lx, 0x%x) failed\n",
> -				DRV_NAME, ioaddr, NETCARD_IO_EXTENT);
> -		retval = -EBUSY;
> -		goto out1;
> -	}
> +	printk(KERN_DEBUG "PP_addr at %p[%x]: 0x%x\n",
> +			ioaddr, ADD_PORT, ioread16(ioaddr + ADD_PORT));

Please use spaces after tabs so that ioaddr lines up nicely with KERN_DEBUG.

[...]
> @@ -1114,7 +1137,10 @@ send_test_pkt(struct net_device *dev)
>  		return 0;	/* this shouldn't happen */
>  
>  	/* Write the contents of the packet */
> -	writewords(dev->base_addr, TX_FRAME_PORT,test_packet,(ETH_ZLEN+1) >>1);
> +	writewords(lp->virt_addr,
> +		   TX_FRAME_PORT,
> +		   test_packet,
> +		   (ETH_ZLEN+1) >> 1);

	writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN + 1) >> 1);

[...]
> @@ -1631,9 +1656,12 @@ net_rx(struct net_device *dev)
>  	}
>  	skb_reserve(skb, 2);	/* longword align L3 header */
>  
> -	readwords(ioaddr, RX_FRAME_PORT, skb_put(skb, length), length >> 1);
> +	readwords(lp->virt_addr,
> +		  RX_FRAME_PORT,
> +		  skb_put(skb, length),
> +		  length >> 1);

	readwords(lp, RX_FRAME_PORT, skb_put(skb, length), length >> 1);

[...]
> @@ -1928,22 +1960,22 @@ static int __init cs89x0_platform_probe(struct platform_device *pdev)
>  		goto free;
>  	}
>  
> -	lp->phys_addr = mem_res->start;
> +	dev->base_addr = mem_res->start;

You may work directly with mem_res->start in this function at the price
of an extra platform_get_resource() in cs89x0_platform_remove().

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


[Linux Kernel Discussion]     [Ethernet Bridging]     [Linux Wireless Networking]     [Linux Bluetooth Networking]     [Linux Networking Users]     [VLAN]     [Git]     [IETF Annouce]     [Linux Assembly]     [Security]     [Bugtraq]     [Photo]     [Singles Social Networking]     [Yosemite Information]     [MIPS Linux]     [ARM Linux Kernel]     [ARM Linux]     [Linux Virtualization]     [Linux Security]     [Linux IDE]     [Linux RAID]     [Linux SCSI]     [Free Dating]

Add to Google Powered by Linux