static int soc_camera_platform_probe(struct platform_device *pdev) { struct soc_camera_platform_priv *priv; struct soc_camera_platform_info *p; struct soc_camera_device *icd; int ret; p = pdev->dev.platform_data; if (!p) return -EINVAL; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->info = p; platform_set_drvdata(pdev, priv); icd = &priv->icd; icd->ops = &soc_camera_platform_ops; icd->control = &pdev->dev; icd->width_min = 0; icd->width_max = priv->info->format.width; icd->height_min = 0; icd->height_max = priv->info->format.height; icd->y_skip_top = 0; icd->iface = priv->info->iface; p->icd = icd; ret = soc_camera_device_register(icd); if (ret) kfree(priv); return ret; }
static int mt9v022_probe(struct i2c_client *client, const struct i2c_device_id *did) { struct mt9v022 *mt9v022; struct soc_camera_device *icd; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct soc_camera_link *icl = client->dev.platform_data; int ret; if (!icl) { dev_err(&client->dev, "MT9V022 driver needs platform data\n"); return -EINVAL; } if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) { dev_warn(&adapter->dev, "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); return -EIO; } mt9v022 = kzalloc(sizeof(struct mt9v022), GFP_KERNEL); if (!mt9v022) return -ENOMEM; mt9v022->chip_control = MT9V022_CHIP_CONTROL_DEFAULT; mt9v022->client = client; i2c_set_clientdata(client, mt9v022); icd = &mt9v022->icd; icd->ops = &mt9v022_ops; icd->control = &client->dev; icd->x_min = 1; icd->y_min = 4; icd->x_current = 1; icd->y_current = 4; icd->width_min = 48; icd->width_max = 752; icd->height_min = 32; icd->height_max = 480; icd->y_skip_top = 1; icd->iface = icl->bus_id; ret = soc_camera_device_register(icd); if (ret) goto eisdr; return 0; eisdr: kfree(mt9v022); return ret; }