Re: [PATCH 1/1] media: dvb_dummy_tuner: implement driver skeleton

Greg KH
2020-01-09T15:54:41Z

On Thu, Jan 09, 2020 at 12:24:08PM -0300, Daniel W. S. Almeida wrote:
> +static int dvb_dummy_tuner_i2c_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
> +{
> + int ret = 0;
> + struct dvb_dummy_tuner_config *config = client->dev.platform_data;
> + struct dvb_frontend *fe = config->fe;
> + struct dvb_dummy_tuner_dev *tuner_dev = NULL;
> +
> + tuner_dev = kzalloc(sizeof(*tuner_dev), GFP_KERNEL);
> + if (!tuner_dev) {
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + i2c_set_clientdata(client, tuner_dev);
> + tuner_dev->fe = config->fe;
> +
> + memcpy(&fe->ops.tuner_ops,
> + &dvb_dummy_tuner_ops,
> + sizeof(struct dvb_tuner_ops));
> +
> + fe->tuner_priv = client;
> +
> + pr_debug("%s: Successfully probed %s\n", __func__, client->name);

As you are a driver, you should never need to call any pr_* calls,
instead use dev_*(). For this, you can use dev_dbg(), but really, why
is that even needed except for your debugging bringup. And for that,
you can use ftrace, right? So no need for any printing of anything
here.

> + return ret;
> +
> +err:
> + pr_err("%s: failed\n", __func__);

Again, dev_err() would be proper, but there's no need for any error
message here.

Don't you need to register the tuner ops with something in this
function?

> + return ret;
> +}
> +
> +static int dvb_dummy_tuner_i2c_remove(struct i2c_client *client)
> +{
> + struct dvb_dummy_tuner_dev *tuner_dev = i2c_get_clientdata(client);
> + struct dvb_frontend *fe = tuner_dev->fe;
> +
> + memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
> + fe->tuner_priv = NULL;
> + kfree(tuner_dev);
> +

Don't you need to unregister the tuner ops in here?

thanks,

greg k-h