Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbdCCQqE (ORCPT ); Fri, 3 Mar 2017 11:46:04 -0500 Received: from mail-qk0-f180.google.com ([209.85.220.180]:33856 "EHLO mail-qk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751742AbdCCQo3 (ORCPT ); Fri, 3 Mar 2017 11:44:29 -0500 MIME-Version: 1.0 In-Reply-To: References: From: Andy Shevchenko Date: Fri, 3 Mar 2017 18:44:27 +0200 Message-ID: Subject: Re: [PATCH v5 2/4] iio: accel: adxl345: Use I2C regmap instead of direct I2C access To: Eva Rachel Retuya Cc: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Dmitry Torokhov , Michael Hennerich , Daniel Baluta , Alison Schofield , Florian Vaussard , "linux-kernel@vger.kernel.org" , Rob Herring , Mark Rutland , devicetree Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1705 Lines: 54 On Tue, Feb 28, 2017 at 4:37 AM, Eva Rachel Retuya wrote: > Convert the driver to use regmap instead of I2C-specific functions. This > is done in preparation for splitting this driver into core and > I2C-specific code as well as introduction of SPI driver. > > Signed-off-by: Eva Rachel Retuya > Reviewed-by: Andy Shevchenko Okay, my another set of comments. > @@ -70,6 +76,7 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, > { > struct adxl345_data *data = iio_priv(indio_dev); > int ret; > + __le16 regval; Reverse tree order, please. __le16 regval; int ret; > @@ -104,37 +112,50 @@ static int adxl345_probe(struct i2c_client *client, > { > struct adxl345_data *data; > struct iio_dev *indio_dev; > + struct device *dev; > + struct regmap *regmap; > int ret; > + u32 regval; Ditto. > + > + regmap = devm_regmap_init_i2c(client, &adxl345_regmap_config); > + if (IS_ERR(regmap)) { > + dev_err(&client->dev, "Error initializing regmap: %d\n", > + (int)PTR_ERR(regmap)); I don't like explicit casting in such cases at all. Why not to use %ld? Same for the similar places in the series. > - if (ret != ADXL345_DEVID) { > - dev_err(&client->dev, "Invalid device ID: %d\n", ret); > + if (regval != ADXL345_DEVID) { > + dev_err(dev, "Invalid device ID: %x, expected %x\n", > + regval, ADXL345_DEVID); So, originally it was in decimal form. Does hex looks better or what is behind the change? -- With Best Regards, Andy Shevchenko