Re: [RFC PATCH] staging: rtl8192e: Rework EEPROM handling code

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

 



On Tue, Jul 28, 2015 at 11:52:42PM +0200, Mateusz Kulikowski wrote:

> diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c
> index ed54193..fe4e282 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c
> @@ -25,115 +25,72 @@
>  #include "rtl_core.h"
>  #include "rtl_eeprom.h"
>  
> -static void eprom_cs(struct net_device *dev, short bit)
> +static void _rtl92e_gpio_set(struct net_device *dev, int no, int val)

I don't like the new name very much.  I don't like the underscore.  Also
set kind of implies set vs clear.  Maybe:

static void rtl92e_gpio_write_bit(struct net_device *dev, int bit, bool val)

>  {
> -	if (bit)
> -		rtl92e_writeb(dev, EPROM_CMD,
> -			      (1 << EPROM_CS_SHIFT) |
> -			      rtl92e_readb(dev, EPROM_CMD));
> +	u8 reg = rtl92e_readb(dev, EPROM_CMD);
> +
> +	if (val)
> +		reg |= 1 << no;
>  	else
> -		rtl92e_writeb(dev, EPROM_CMD,
> -			      rtl92e_readb(dev, EPROM_CMD) &
> -			      ~(1<<EPROM_CS_SHIFT));
> +		reg &= ~(1 << no);
>  
> +	rtl92e_writeb(dev, EPROM_CMD, reg);
>  	udelay(EPROM_DELAY);
>  }
>  
> -
> -static void eprom_ck_cycle(struct net_device *dev)
> +static int _rtl92e_gpio_get(struct net_device *dev, int no)

static bool rtl92e_gpio_get_bit(struct net_device *dev, int bit)

>  {
> -	rtl92e_writeb(dev, EPROM_CMD,
> -		      (1<<EPROM_CK_SHIFT) | rtl92e_readb(dev, EPROM_CMD));
> -	udelay(EPROM_DELAY);
> -	rtl92e_writeb(dev, EPROM_CMD,
> -		      rtl92e_readb(dev, EPROM_CMD) & ~(1<<EPROM_CK_SHIFT));
> -	udelay(EPROM_DELAY);
> -}
> +	u8 reg = rtl92e_readb(dev, EPROM_CMD);
>  
> +	return (reg >> no) & 0x1;
> +}
>  
> -static void eprom_w(struct net_device *dev, short bit)
> +static void _rtl92e_eeprom_ck_cycle(struct net_device *dev)
>  {
> -	if (bit)
> -		rtl92e_writeb(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) |
> -			      rtl92e_readb(dev, EPROM_CMD));
> -	else
> -		rtl92e_writeb(dev, EPROM_CMD,
> -			      rtl92e_readb(dev, EPROM_CMD) &
> -			      ~(1<<EPROM_W_SHIFT));
> -
> -	udelay(EPROM_DELAY);
> +	_rtl92e_gpio_set(dev, EPROM_CK_BIT, 1);
> +	_rtl92e_gpio_set(dev, EPROM_CK_BIT, 0);

The old cycle function had some delays built in.  You're probably right
that they aren't needed, but why do you think so?

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux