Re: [PATCH v2 1/2] iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver

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

 



> > > +		break;
> > > +	}
> > > +	case IIO_CHAN_INFO_SCALE:
> > > +		vref_uv = regulator_get_voltage(data->vref_reg);
> > > +		if (vref_uv < 0) {
> > > +			/* dummy regulator "get_voltage" returns -EINVAL */
> > > +			ret = -EINVAL;  
> > 			return -EINVAL;  
> > > +		} else {
> > > +			*val =  vref_uv / 1000; /* Convert reg voltage to mV */
> > > +			*val2 = ADS7924_BITS;
> > > +			ret = IIO_VAL_FRACTIONAL_LOG2;  
> > 			return IIO_VAL_FR...
> >   
> > > +		}
> > > +		break;
> > > +	default:
> > > +		ret = -EINVAL;  
> > 		return -EINVAL;  
> > > +		break;
> > > +	}
> > > +
> > > +	return ret;
> > > +}  
> 
> Done. With these changes, I propose to also remove last "return ret" (like in rcar-gyroadc.c). Then, maybe also remove break statements?

Definitely to both. I was just being lazy whilst commenting ;)  No breaks after returns, and as you
have noted, the last return ret is unreachable.

> > > +
> > > +	if (num_channels > 0) {
> > > +		dev_dbg(dev, "found %d ADC channels\n", num_channels);
> > > +		return 0;
> > > +	} else {  
> > 
> > As per other review.  Give us what we expect which is error paths
> > as out of line.  
> 
> Already done as suggested by Christophe:
> 
>     if (num_channels <= 0)
>         return -EINVAL;

This is an out of line error path because it's indented more than the normal
flow.

> 
>     dev_dbg(dev, "found %d ADC channels\n", num_channels);
>     return 0;
> 
> Although I do not fully understand what you mean by "...error paths as out of line"? Do you mean to drop the debug message?
See above.

> 
> >   
> > > +		return -EINVAL;
> > > +	}
> > > +}  



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux