static int apds9702_do_sensing(struct apds9702data *data, int enable) { int err; struct apds9702_platform_data *pdata = data->client->dev.platform_data; dev_dbg(&data->client->dev, "%s: enable = %d\n", __func__, enable); if (enable) { pdata->hw_config(&data->client->dev, 1); err = apds9702_write_byte(data->client, data->ctl_reg & 0xFF, data->ctl_reg >> 8); if (err) goto err_exit; data->active = 1; apds9702_report(data); return 0; } err = apds9702_write_byte(data->client, 0, 0); data->active = 0; err_exit: pdata->hw_config(&data->client->dev, 0); if (err) dev_err(&data->client->dev, "%s. I2C write error = %d\n", __func__, err); return err; }
{ int err = 0; struct apds9702_platform_data *pdata = data->client->dev.platform_data; dev_dbg(&data->client->dev, "%s: enable = %d\n", __func__, enable); if (enable) { pdata->hw_config(1); err = apds9702_write_byte(data->client, data->ctl_reg & 0xFF, data->ctl_reg >> 8); if (err) pdata->hw_config(0); else data->active = 1; } else { err = apds9702_write_byte(data->client, 0, 0); pdata->hw_config(0); data->active = 0; } if (err) dev_err(&data->client->dev, "%s. I2C write error = %d\n", __func__, err); return err; } static irqreturn_t apds9702_work(int irq, void *handle) { struct apds9702data *data = handle; struct apds9702_platform_data *pdata = data->client->dev.platform_data; dev_dbg(&data->client->dev, "%s\n", __func__);