cm32181.c (02cdab2a8d55c85967a4be4a084efa9641c56066) | cm32181.c (b885d0fa6790b8b2c8502dc93fed27ce85e68922) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2013 Capella Microsystems Inc. 4 * Author: Kevin Tsai <ktsai@capellamicro.com> 5 */ 6 7#include <linux/delay.h> 8#include <linux/err.h> --- 313 unchanged lines hidden (view full) --- 322static const struct iio_info cm32181_info = { 323 .read_raw = &cm32181_read_raw, 324 .write_raw = &cm32181_write_raw, 325 .attrs = &cm32181_attribute_group, 326}; 327 328static int cm32181_probe(struct i2c_client *client) 329{ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2013 Capella Microsystems Inc. 4 * Author: Kevin Tsai <ktsai@capellamicro.com> 5 */ 6 7#include <linux/delay.h> 8#include <linux/err.h> --- 313 unchanged lines hidden (view full) --- 322static const struct iio_info cm32181_info = { 323 .read_raw = &cm32181_read_raw, 324 .write_raw = &cm32181_write_raw, 325 .attrs = &cm32181_attribute_group, 326}; 327 328static int cm32181_probe(struct i2c_client *client) 329{ |
330 struct device *dev = &client->dev; |
|
330 struct cm32181_chip *cm32181; 331 struct iio_dev *indio_dev; 332 int ret; 333 | 331 struct cm32181_chip *cm32181; 332 struct iio_dev *indio_dev; 333 int ret; 334 |
334 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*cm32181)); 335 if (!indio_dev) { 336 dev_err(&client->dev, "devm_iio_device_alloc failed\n"); | 335 indio_dev = devm_iio_device_alloc(dev, sizeof(*cm32181)); 336 if (!indio_dev) |
337 return -ENOMEM; | 337 return -ENOMEM; |
338 } | |
339 340 cm32181 = iio_priv(indio_dev); | 338 339 cm32181 = iio_priv(indio_dev); |
341 i2c_set_clientdata(client, indio_dev); | |
342 cm32181->client = client; 343 344 mutex_init(&cm32181->lock); | 340 cm32181->client = client; 341 342 mutex_init(&cm32181->lock); |
345 indio_dev->dev.parent = &client->dev; | 343 indio_dev->dev.parent = dev; |
346 indio_dev->channels = cm32181_channels; 347 indio_dev->num_channels = ARRAY_SIZE(cm32181_channels); 348 indio_dev->info = &cm32181_info; | 344 indio_dev->channels = cm32181_channels; 345 indio_dev->num_channels = ARRAY_SIZE(cm32181_channels); 346 indio_dev->info = &cm32181_info; |
349 indio_dev->name = dev_name(&client->dev); | 347 indio_dev->name = dev_name(dev); |
350 indio_dev->modes = INDIO_DIRECT_MODE; 351 352 ret = cm32181_reg_init(cm32181); 353 if (ret) { | 348 indio_dev->modes = INDIO_DIRECT_MODE; 349 350 ret = cm32181_reg_init(cm32181); 351 if (ret) { |
354 dev_err(&client->dev, 355 "%s: register init failed\n", 356 __func__); | 352 dev_err(dev, "%s: register init failed\n", __func__); |
357 return ret; 358 } 359 | 353 return ret; 354 } 355 |
360 ret = devm_iio_device_register(&client->dev, indio_dev); | 356 ret = devm_iio_device_register(dev, indio_dev); |
361 if (ret) { | 357 if (ret) { |
362 dev_err(&client->dev, 363 "%s: regist device failed\n", 364 __func__); | 358 dev_err(dev, "%s: regist device failed\n", __func__); |
365 return ret; 366 } 367 368 return 0; 369} 370 371static const struct of_device_id cm32181_of_match[] = { 372 { .compatible = "capella,cm3218" }, --- 27 unchanged lines hidden --- | 359 return ret; 360 } 361 362 return 0; 363} 364 365static const struct of_device_id cm32181_of_match[] = { 366 { .compatible = "capella,cm3218" }, --- 27 unchanged lines hidden --- |