static int __devinit adxl34x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adxl34x *ac; int error; error = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); if (!error) { dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); return -EIO; } ac = adxl34x_probe(&client->dev, client->irq, false, i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK) ? &adxl34x_smbus_bops : &adxl34x_i2c_bops); if (IS_ERR(ac)) return PTR_ERR(ac); i2c_set_clientdata(client, ac); #ifdef CONFIG_HAS_EARLYSUSPEND esii.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; esii.suspend = adxl34x_early_suspend; esii.resume = adxl34x_late_resume; register_early_suspend(&esii); #endif acii = i2c_get_clientdata(client); return 0; }
static int adxl34x_spi_probe(struct spi_device *spi) { struct adxl34x *ac; /* don't exceed max specified SPI CLK frequency */ if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) { dev_err(&spi->dev, "SPI CLK %d Hz too fast\n", spi->max_speed_hz); return -EINVAL; } ac = adxl34x_probe(&spi->dev, spi->irq, spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY, &adxl34x_spi_bops); if (IS_ERR(ac)) return PTR_ERR(ac); spi_set_drvdata(spi, ac); return 0; }
static int adxl34x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adxl34x *ac; int error; error = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA); if (!error) { dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); return -EIO; } ac = adxl34x_probe(&client->dev, client->irq, false, i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK) ? &adxl34x_smbus_bops : &adxl34x_i2c_bops); if (IS_ERR(ac)) return PTR_ERR(ac); i2c_set_clientdata(client, ac); return 0; }