[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200109155437.GA568342@kroah.com>
Date: Thu, 9 Jan 2020 16:54:37 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: "Daniel W. S. Almeida" <dwlsalmeida@...il.com>
Cc: mchehab@...nel.org, sean@...s.org, tglx@...utronix.de,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linuxfoundation.org
Subject: Re: [PATCH 1/1] media: dvb_dummy_tuner: implement driver skeleton
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
Powered by blists - more mailing lists