[patch 07/10] firedtv: fix initialization of dvb_frontend.ops

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <devel@...>
Date: Monday, September 29, 2008 - 1:20 pm

There was a NULL pointer reference if no dvb_frontend_info was found.

Also, don't directly assign struct typed values to struct typed
variables. Instead write out assignments to individual strcut members.
This reduces module size by about 1 kB.

Signed-off-by: Stefan Richter
---
drivers/media/dvb/firesat/firesat.h | 34 ++--
drivers/media/dvb/firesat/firesat_dvb.c | 3
drivers/media/dvb/firesat/firesat_fe.c | 167 ++++++++++--------------
3 files changed, 91 insertions(+), 113 deletions(-)

Index: linux/drivers/media/dvb/firesat/firesat.h
===================================================================
--- linux.orig/drivers/media/dvb/firesat/firesat.h
+++ linux/drivers/media/dvb/firesat/firesat.h
@@ -132,25 +132,21 @@ struct hpsb_iso;
struct unit_directory;

struct firesat {
- struct dvb_demux dvb_demux;
-
- /* DVB bits */
- struct dvb_adapter adapter;
- struct dmxdev dmxdev;
- struct dvb_demux demux;
- struct dmx_frontend frontend;
- struct dvb_net dvbnet;
- struct dvb_frontend_info *frontend_info;
- struct dvb_frontend fe;
-
- struct dvb_device *cadev;
- int ca_last_command;
- int ca_time_interval;
-
- struct mutex avc_mutex;
- wait_queue_head_t avc_wait;
- bool avc_reply_received;
- struct work_struct remote_ctrl_work;
+ struct dvb_adapter adapter;
+ struct dmxdev dmxdev;
+ struct dvb_demux demux;
+ struct dmx_frontend frontend;
+ struct dvb_net dvbnet;
+ struct dvb_frontend fe;
+
+ struct dvb_device *cadev;
+ int ca_last_command;
+ int ca_time_interval;
+
+ struct mutex avc_mutex;
+ wait_queue_head_t avc_wait;
+ bool avc_reply_received;
+ struct work_struct remote_ctrl_work;

struct firesat_channel {
struct firesat *firesat;
Index: linux/drivers/media/dvb/firesat/firesat_fe.c
===================================================================
--- linux.orig/drivers/media/dvb/firesat/firesat_fe.c
+++ linux/drivers/media/dvb/firesat/firesat_fe.c
@@ -12,6 +12,7 @@

#include
#include
+#include
#include

#include
@@ -22,17 +23,18 @@

static int firesat_dvb_init(struct dvb_frontend *fe)
{
- int result;
struct firesat *firesat = fe->sec_priv;
+ int err;

/* FIXME - allocate free channel at IRM */
firesat->isochannel = firesat->adapter.num;

- result = try_CMPEstablishPPconnection(firesat, firesat->subunit, firesat->isochannel);
- if (result != 0) {
+ err = try_CMPEstablishPPconnection(firesat, firesat->subunit,
+ firesat->isochannel);
+ if (err) {
printk(KERN_ERR "Could not establish point to point "
"connection.\n");
- return -1;
+ return err;
}

return setup_iso_channel(firesat);
@@ -168,105 +170,86 @@ static int firesat_get_frontend(struct d
return -EOPNOTSUPP;
}

-static struct dvb_frontend_info firesat_S_frontend_info;
-static struct dvb_frontend_info firesat_C_frontend_info;
-static struct dvb_frontend_info firesat_T_frontend_info;
-
-static struct dvb_frontend_ops firesat_ops = {
-
- .init = firesat_dvb_init,
- .sleep = firesat_sleep,
-
- .set_frontend = firesat_set_frontend,
- .get_frontend = firesat_get_frontend,
-
- .read_status = firesat_read_status,
- .read_ber = firesat_read_ber,
- .read_signal_strength = firesat_read_signal_strength,
- .read_snr = firesat_read_snr,
- .read_ucblocks = firesat_read_uncorrected_blocks,
-
- .diseqc_send_master_cmd = firesat_diseqc_send_master_cmd,
- .diseqc_send_burst = firesat_diseqc_send_burst,
- .set_tone = firesat_set_tone,
- .set_voltage = firesat_set_voltage,
-};
-
void firesat_frontend_init(struct firesat *firesat)
{
+ struct dvb_frontend_ops *ops = &firesat->fe.ops;
+ struct dvb_frontend_info *fi = &ops->info;
+
+ ops->init = firesat_dvb_init;
+ ops->sleep = firesat_sleep;
+
+ ops->set_frontend = firesat_set_frontend;
+ ops->get_frontend = firesat_get_frontend;
+
+ ops->read_status = firesat_read_status;
+ ops->read_ber = firesat_read_ber;
+ ops->read_signal_strength = firesat_read_signal_strength;
+ ops->read_snr = firesat_read_snr;
+ ops->read_ucblocks = firesat_read_uncorrected_blocks;
+
+ ops->diseqc_send_master_cmd = firesat_diseqc_send_master_cmd;
+ ops->diseqc_send_burst = firesat_diseqc_send_burst;
+ ops->set_tone = firesat_set_tone;
+ ops->set_voltage = firesat_set_voltage;
+
switch (firesat->type) {
case FireSAT_DVB_S:
- firesat->frontend_info = &firesat_S_frontend_info;
+ fi->type = FE_QPSK;
+
+ fi->frequency_min = 950000;
+ fi->frequency_max = 2150000;
+ fi->frequency_stepsize = 125;
+ fi->symbol_rate_min = 1000000;
+ fi->symbol_rate_max = 40000000;
+
+ fi->caps = FE_CAN_INVERSION_AUTO |
+ FE_CAN_FEC_1_2 |
+ FE_CAN_FEC_2_3 |
+ FE_CAN_FEC_3_4 |
+ FE_CAN_FEC_5_6 |
+ FE_CAN_FEC_7_8 |
+ FE_CAN_FEC_AUTO |
+ FE_CAN_QPSK;
break;
+
case FireSAT_DVB_C:
- firesat->frontend_info = &firesat_C_frontend_info;
+ fi->type = FE_QAM;
+
+ fi->frequency_min = 47000000;
+ fi->frequency_max = 866000000;
+ fi->frequency_stepsize = 62500;
+ fi->symbol_rate_min = 870000;
+ fi->symbol_rate_max = 6900000;
+
+ fi->caps = FE_CAN_INVERSION_AUTO |
+ FE_CAN_QAM_16 |
+ FE_CAN_QAM_32 |
+ FE_CAN_QAM_64 |
+ FE_CAN_QAM_128 |
+ FE_CAN_QAM_256 |
+ FE_CAN_QAM_AUTO;
break;
+
case FireSAT_DVB_T:
- firesat->frontend_info = &firesat_T_frontend_info;
+ fi->type = FE_OFDM;
+
+ fi->frequency_min = 49000000;
+ fi->frequency_max = 861000000;
+ fi->frequency_stepsize = 62500;
+
+ fi->caps = FE_CAN_INVERSION_AUTO |
+ FE_CAN_FEC_2_3 |
+ FE_CAN_TRANSMISSION_MODE_AUTO |
+ FE_CAN_GUARD_INTERVAL_AUTO |
+ FE_CAN_HIERARCHY_AUTO;
break;
+
default:
- printk(KERN_ERR "firedtv: no frontend for model type 0x%x\n",
+ printk(KERN_ERR "FireDTV: no frontend for model type %d\n",
firesat->type);
- firesat->frontend_info = NULL;
}
- firesat->fe.ops = firesat_ops;
- firesat->fe.ops.info = *(firesat->frontend_info);
+ strcpy(fi->name, firedtv_model_names[firesat->type]);
+
firesat->fe.dvb = &firesat->adapter;
+ firesat->fe.sec_priv = firesat;
}
-
-static struct dvb_frontend_info firesat_S_frontend_info = {
-
- .name = "FireDTV DVB-S Frontend",
- .type = FE_QPSK,
-
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 125,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 40000000,
-
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 |
- FE_CAN_FEC_2_3 |
- FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 |
- FE_CAN_FEC_7_8 |
- FE_CAN_FEC_AUTO |
- FE_CAN_QPSK,
-};
-
-static struct dvb_frontend_info firesat_C_frontend_info = {
-
- .name = "FireDTV DVB-C Frontend",
- .type = FE_QAM,
-
- .frequency_min = 47000000,
- .frequency_max = 866000000,
- .frequency_stepsize = 62500,
- .symbol_rate_min = 870000,
- .symbol_rate_max = 6900000,
-
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_QAM_16 |
- FE_CAN_QAM_32 |
- FE_CAN_QAM_64 |
- FE_CAN_QAM_128 |
- FE_CAN_QAM_256 |
- FE_CAN_QAM_AUTO,
-};
-
-static struct dvb_frontend_info firesat_T_frontend_info = {
-
- .name = "FireDTV DVB-T Frontend",
- .type = FE_OFDM,
-
- .frequency_min = 49000000,
- .frequency_max = 861000000,
- .frequency_stepsize = 62500,
-
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_2_3 |
- FE_CAN_TRANSMISSION_MODE_AUTO |
- FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO,
-};
Index: linux/drivers/media/dvb/firesat/firesat_dvb.c
===================================================================
--- linux.orig/drivers/media/dvb/firesat/firesat_dvb.c
+++ linux/drivers/media/dvb/firesat/firesat_dvb.c
@@ -251,9 +251,8 @@ int firesat_dvbdev_init(struct firesat *
goto fail_rem_frontend;

dvb_net_init(&firesat->adapter, &firesat->dvbnet, &firesat->demux.dmx);
- firesat_frontend_init(firesat);

- firesat->fe.sec_priv = firesat;
+ firesat_frontend_init(firesat);
err = dvb_register_frontend(&firesat->adapter, &firesat->fe);
if (err)
goto fail_net_release;

--
Stefan Richter
-=====-==--- =--= ===-=
http://arcgraph.de/sr/

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Gettinng started with Linux drivers, Amit Uttamchandani, (Fri Apr 10, 6:04 pm)
broken mailing list, try 47..., Greg KH, (Fri Jan 11, 3:12 pm)
Mailing Lists, Tomasz Grzegurzko, (Fri Feb 8, 8:22 pm)
what is the status of this initiative ?, JoJo jojo, (Thu Mar 13, 3:20 am)
A tablet driver question, Steven Hunt, (Wed May 20, 12:49 am)
Dearest Beloved,, Mr. Kunio Uematsu, (Tue Mar 16, 3:52 pm)
[patch 00/10] firedtv: a few more updates, Stefan Richter, (Mon Sep 29, 1:15 pm)
Re: A tablet driver question, Greg KH, (Wed May 20, 1:12 am)
Re: A tablet driver question, Steven Hunt, (Wed May 20, 2:16 am)
Re: A tablet driver question, Jiri Slaby, (Wed May 20, 3:19 am)
Re: A tablet driver question, Steven Hunt, (Wed May 20, 11:58 am)
Re: A tablet driver question, Jiri Slaby, (Wed May 20, 12:24 pm)
Re: A tablet driver question, Mohamed Ikbel Boulabiar, (Wed May 20, 12:50 pm)
Re: A tablet driver question, Jiri Kosina, (Thu May 21, 4:33 am)
Re: Gettinng started with Linux drivers, Stefan Richter, (Sat Apr 11, 6:00 am)
Re: Gettinng started with Linux drivers, Amit Uttamchandani, (Sun Apr 12, 9:08 pm)
Re: Gettinng started with Linux drivers, Stefan Richter, (Mon Apr 13, 3:39 am)
Re: [patch 00/10] firedtv: a few more updates, Stefan Richter, (Mon Sep 29, 1:46 pm)
[patch 08/10] firedtv: remove unused struct members, Stefan Richter, (Mon Sep 29, 1:21 pm)
[patch 07/10] firedtv: fix initialization of dvb_frontend.ops, Stefan Richter, (Mon Sep 29, 1:20 pm)
Re: what is the status of this initiative ?, Greg KH, (Thu Mar 13, 10:51 am)
Re: what is the status of this initiative ?, Javi Roman, (Thu Mar 13, 1:13 pm)
Re: what is the status of this initiative ?, Greg KH, (Thu Mar 13, 1:36 pm)
Re: what is the status of this initiative ?, Davide Madrisan, (Thu Mar 13, 1:30 pm)
Re: broken mailing list, try 47..., Steven Le Roux, (Sat Jan 12, 2:10 pm)
Re: broken mailing list, try 47..., stuart, (Sat Jan 12, 6:56 pm)
Kick off the Linux Driver Project (again, this time for real), Peter W. Morreale, (Thu Sep 27, 9:21 am)
Kick off the Linux Driver Project (again, this time for real), Peter W. Morreale, (Thu Sep 27, 9:55 am)
Kick off the Linux Driver Project (again, this time for real), Peter W. Morreale, (Thu Sep 27, 10:58 am)
Kick off the Linux Driver Project (again, this time for real), Tomasz Grzegurzko, (Thu Sep 27, 9:40 pm)