Re: [PATCH v4 4/6] iio: light: stk3310: use dev_err_probe where possible

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

 



On Mon, Nov 04, 2024 at 10:40:16AM +0200, Andy Shevchenko wrote:
> On Sat, Nov 02, 2024 at 03:50:41PM -0400, Aren Moynihan wrote:
> > Using dev_err_probe instead of dev_err and return makes the errors
> > easier to understand by including the error name, and saves a little
> > code.
> 
> ...
> 
> >  #define STK3310_REGFIELD(name)						    \
> >  	do {								    \
> >  		data->reg_##name =					    \
> > -			devm_regmap_field_alloc(&client->dev, regmap,	    \
> > +			devm_regmap_field_alloc(dev, regmap,		    \
> >  				stk3310_reg_field_##name);		    \
> > -		if (IS_ERR(data->reg_##name)) {				    \
> > -			dev_err(&client->dev, "reg field alloc failed.\n"); \
> > -			return PTR_ERR(data->reg_##name);		    \
> > -		}							    \
> > +		if (IS_ERR(data->reg_##name))				    \
> 
> > +			return dev_err_probe(dev,			    \
> > +				PTR_ERR(data->reg_##name),		    \
> 
> AFAICS these two can be put on one.

This doesn't leave room for whitespace between the end of line and "\",
replacing "do { } while (0)" with "({ })" and deindenting could make
enough room to clean this up the formatting of this macro though.

> > +				"reg field alloc failed.\n");		    \
> >  	} while (0)
> 
> 
> ...
> 
> > @@ -654,12 +652,11 @@ static int stk3310_probe(struct i2c_client *client)
> >  	int ret;
> >  	struct iio_dev *indio_dev;
> >  	struct stk3310_data *data;
> > +	struct device *dev = &client->dev;
> 
> This should has been done a few patches earlier...

Moving it there now

 - Aren




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux