UPSTREAM: media: rc: Remove init_ir_raw_event and DEFINE_IR_RAW_EVENT macros
This can be done with c99 initializers, which makes the code cleaner
and more transparent. It does require gcc 4.6, because of this bug
in earlier versions:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676
Since commit cafa0010cd ("Raise the minimum required gcc version to
4.6"), this is the case.
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit 183e19f5b9ee18fc7bc4b3983a91b5d0dd6c7871)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
Conflicts:
drivers/media/pci/cx88/cx88-input.c
drivers/media/rc/imon_raw.c
drivers/media/rc/mceusb.c
drivers/media/rc/meson-ir.c
drivers/media/rc/mtk-cir.c
drivers/media/rc/redrat3.c
drivers/media/rc/sir_ir.c
drivers/media/rc/st_rc.c
This commit is contained in:
@ -45,7 +45,7 @@ int picolcd_raw_cir(struct picolcd_data *data,
|
||||
{
|
||||
unsigned long flags;
|
||||
int i, w, sz;
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
|
||||
/* ignore if rc_dev is NULL or status is shunned */
|
||||
spin_lock_irqsave(&data->lock, flags);
|
||||
@ -67,7 +67,6 @@ int picolcd_raw_cir(struct picolcd_data *data,
|
||||
*/
|
||||
sz = size > 0 ? min((int)raw_data[0], size-1) : 0;
|
||||
for (i = 0; i+1 < sz; i += 2) {
|
||||
init_ir_raw_event(&rawir);
|
||||
w = (raw_data[i] << 8) | (raw_data[i+1]);
|
||||
rawir.pulse = !!(w & 0x8000);
|
||||
rawir.duration = US_TO_NS(rawir.pulse ? (65536 - w) : w);
|
||||
|
||||
@ -41,10 +41,10 @@ void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len)
|
||||
const s32 *samples = (const void *)buf;
|
||||
|
||||
for (i = 0; i < len >> 2; i++) {
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
|
||||
ev.duration = abs(samples[i]) * 1000; /* Convert to ns */
|
||||
ev.pulse = (samples[i] > 0) ? false : true;
|
||||
struct ir_raw_event ev = {
|
||||
.duration = abs(samples[i]) * 1000, /* Convert to ns */
|
||||
.pulse = (samples[i] > 0) ? false : true
|
||||
};
|
||||
|
||||
ir_raw_event_store(coredev->ir.dev, &ev);
|
||||
}
|
||||
|
||||
@ -706,10 +706,8 @@ static int cx25840_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count,
|
||||
if (v > IR_MAX_DURATION)
|
||||
v = IR_MAX_DURATION;
|
||||
|
||||
init_ir_raw_event(&p->ir_core_data);
|
||||
p->ir_core_data.pulse = u;
|
||||
p->ir_core_data.duration = v;
|
||||
p->ir_core_data.timeout = w;
|
||||
p->ir_core_data = (struct ir_raw_event)
|
||||
{ .pulse = u, .duration = v, .timeout = w };
|
||||
|
||||
v4l2_dbg(2, ir_debug, sd, "rx read: %10u ns %s %s\n",
|
||||
v, u ? "mark" : "space", w ? "(timed out)" : "");
|
||||
|
||||
@ -696,10 +696,8 @@ static int cx23888_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count,
|
||||
if (v > IR_MAX_DURATION)
|
||||
v = IR_MAX_DURATION;
|
||||
|
||||
init_ir_raw_event(&p->ir_core_data);
|
||||
p->ir_core_data.pulse = u;
|
||||
p->ir_core_data.duration = v;
|
||||
p->ir_core_data.timeout = w;
|
||||
p->ir_core_data = (struct ir_raw_event)
|
||||
{ .pulse = u, .duration = v, .timeout = w };
|
||||
|
||||
v4l2_dbg(2, ir_888_debug, sd, "rx read: %10u ns %s %s\n",
|
||||
v, u ? "mark" : "space", w ? "(timed out)" : "");
|
||||
|
||||
@ -331,8 +331,6 @@ static int ene_rx_get_sample_reg(struct ene_device *dev)
|
||||
/* Sense current received carrier */
|
||||
static void ene_rx_sense_carrier(struct ene_device *dev)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
|
||||
int carrier, duty_cycle;
|
||||
int period = ene_read_reg(dev, ENE_CIRCAR_PRD);
|
||||
int hperiod = ene_read_reg(dev, ENE_CIRCAR_HPRD);
|
||||
@ -353,9 +351,11 @@ static void ene_rx_sense_carrier(struct ene_device *dev)
|
||||
dbg("RX: sensed carrier = %d Hz, duty cycle %d%%",
|
||||
carrier, duty_cycle);
|
||||
if (dev->carrier_detect_enabled) {
|
||||
ev.carrier_report = true;
|
||||
ev.carrier = carrier;
|
||||
ev.duty_cycle = duty_cycle;
|
||||
struct ir_raw_event ev = {
|
||||
.carrier_report = true,
|
||||
.carrier = carrier,
|
||||
.duty_cycle = duty_cycle
|
||||
};
|
||||
ir_raw_event_store(dev->rdev, &ev);
|
||||
}
|
||||
}
|
||||
@ -738,7 +738,7 @@ static irqreturn_t ene_isr(int irq, void *data)
|
||||
unsigned long flags;
|
||||
irqreturn_t retval = IRQ_NONE;
|
||||
struct ene_device *dev = (struct ene_device *)data;
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
struct ir_raw_event ev = {};
|
||||
|
||||
spin_lock_irqsave(&dev->hw_lock, flags);
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ static int fintek_cmdsize(u8 cmd, u8 subcmd)
|
||||
/* process ir data stored in driver buffer */
|
||||
static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
u8 sample;
|
||||
bool event = false;
|
||||
int i;
|
||||
@ -323,7 +323,6 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
|
||||
break;
|
||||
case PARSE_IRDATA:
|
||||
fintek->rem--;
|
||||
init_ir_raw_event(&rawir);
|
||||
rawir.pulse = ((sample & BUF_PULSE_BIT) != 0);
|
||||
rawir.duration = US_TO_NS((sample & BUF_SAMPLE_MASK)
|
||||
* CIR_SAMPLE_PERIOD);
|
||||
|
||||
@ -56,7 +56,7 @@ static void igorplugusb_cmd(struct igorplugusb *ir, int cmd);
|
||||
|
||||
static void igorplugusb_irdata(struct igorplugusb *ir, unsigned len)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
unsigned i, start, overflow;
|
||||
|
||||
dev_dbg(ir->dev, "irdata: %*ph (len=%u)", len, ir->buf_in, len);
|
||||
|
||||
@ -132,12 +132,10 @@ static void process_ir_data(struct iguanair *ir, unsigned len)
|
||||
break;
|
||||
}
|
||||
} else if (len >= 7) {
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
unsigned i;
|
||||
bool event = false;
|
||||
|
||||
init_ir_raw_event(&rawir);
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
if (ir->buf_in[i] == 0x80) {
|
||||
rawir.pulse = false;
|
||||
|
||||
@ -157,7 +157,7 @@ static irqreturn_t hix5hd2_ir_rx_interrupt(int irq, void *data)
|
||||
}
|
||||
|
||||
if ((irq_sr & INTMS_SYMBRCV) || (irq_sr & INTMS_TIMEOUT)) {
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
struct ir_raw_event ev = {};
|
||||
|
||||
symb_num = readl_relaxed(priv->base + IR_DATAH);
|
||||
for (i = 0; i < symb_num; i++) {
|
||||
|
||||
@ -178,7 +178,7 @@ static void ite_decode_bytes(struct ite_dev *dev, const u8 * data, int
|
||||
u32 sample_period;
|
||||
unsigned long *ldata;
|
||||
unsigned int next_one, next_zero, size;
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
struct ir_raw_event ev = {};
|
||||
|
||||
if (length == 0)
|
||||
return;
|
||||
@ -1512,9 +1512,6 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
|
||||
/* initialize spinlocks */
|
||||
spin_lock_init(&itdev->lock);
|
||||
|
||||
/* initialize raw event */
|
||||
init_ir_raw_event(&itdev->rawir);
|
||||
|
||||
/* set driver data into the pnp device */
|
||||
pnp_set_drvdata(pdev, itdev);
|
||||
itdev->pdev = pdev;
|
||||
|
||||
@ -615,7 +615,7 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt)
|
||||
*/
|
||||
static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
u8 sample;
|
||||
int i;
|
||||
|
||||
|
||||
@ -180,9 +180,10 @@ static inline void init_ir_raw_event_duration(struct ir_raw_event *ev,
|
||||
unsigned int pulse,
|
||||
u32 duration)
|
||||
{
|
||||
init_ir_raw_event(ev);
|
||||
ev->duration = duration;
|
||||
ev->pulse = pulse;
|
||||
*ev = (struct ir_raw_event) {
|
||||
.duration = duration,
|
||||
.pulse = pulse
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -111,7 +111,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store);
|
||||
int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
|
||||
{
|
||||
ktime_t now;
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
struct ir_raw_event ev = {};
|
||||
|
||||
if (!dev->raw)
|
||||
return -EINVAL;
|
||||
@ -219,7 +219,7 @@ void ir_raw_event_set_idle(struct rc_dev *dev, bool idle)
|
||||
if (idle) {
|
||||
dev->raw->this_ev.timeout = true;
|
||||
ir_raw_event_store(dev, &dev->raw->this_ev);
|
||||
init_ir_raw_event(&dev->raw->this_ev);
|
||||
dev->raw->this_ev = (struct ir_raw_event) {};
|
||||
}
|
||||
|
||||
if (dev->s_idle)
|
||||
@ -571,10 +571,10 @@ static void ir_raw_edge_handle(struct timer_list *t)
|
||||
spin_lock_irqsave(&dev->raw->edge_spinlock, flags);
|
||||
interval = ktime_sub(ktime_get(), dev->raw->last_event);
|
||||
if (ktime_to_ns(interval) >= dev->timeout) {
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
|
||||
ev.timeout = true;
|
||||
ev.duration = ktime_to_ns(interval);
|
||||
struct ir_raw_event ev = {
|
||||
.timeout = true,
|
||||
.duration = ktime_to_ns(interval)
|
||||
};
|
||||
|
||||
ir_raw_event_store(dev, &ev);
|
||||
} else {
|
||||
|
||||
@ -107,7 +107,7 @@ static int loop_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
|
||||
struct loopback_dev *lodev = dev->priv;
|
||||
u32 rxmask;
|
||||
unsigned i;
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
|
||||
if (lodev->txcarrier < lodev->rxcarriermin ||
|
||||
lodev->txcarrier > lodev->rxcarriermax) {
|
||||
|
||||
@ -273,7 +273,7 @@ static void frbwrite(unsigned int l, bool is_pulse)
|
||||
{
|
||||
/* simple noise filter */
|
||||
static unsigned int ptr, pulse, space;
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
struct ir_raw_event ev = {};
|
||||
|
||||
if (ptr > 0 && is_pulse) {
|
||||
pulse += l;
|
||||
@ -472,10 +472,10 @@ static int hardware_init_port(void)
|
||||
|
||||
static void serial_ir_timeout(unsigned long arg)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
|
||||
ev.timeout = true;
|
||||
ev.duration = serial_ir.rcdev->timeout;
|
||||
struct ir_raw_event ev = {
|
||||
.timeout = true,
|
||||
.duration = serial_ir.rcdev->timeout
|
||||
};
|
||||
ir_raw_event_store_with_filter(serial_ir.rcdev, &ev);
|
||||
ir_raw_event_handle(serial_ir.rcdev);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir)
|
||||
static void sz_push_full_pulse(struct streamzap_ir *sz,
|
||||
unsigned char value)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
|
||||
if (sz->idle) {
|
||||
long deltv;
|
||||
@ -180,7 +180,7 @@ static void sz_push_half_pulse(struct streamzap_ir *sz,
|
||||
static void sz_push_full_space(struct streamzap_ir *sz,
|
||||
unsigned char value)
|
||||
{
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
|
||||
rawir.pulse = false;
|
||||
rawir.duration = ((int) value) * SZ_RESOLUTION;
|
||||
@ -254,10 +254,10 @@ static void streamzap_callback(struct urb *urb)
|
||||
break;
|
||||
case FullSpace:
|
||||
if (sz->buf_in[i] == SZ_TIMEOUT) {
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
|
||||
rawir.pulse = false;
|
||||
rawir.duration = sz->rdev->timeout;
|
||||
struct ir_raw_event rawir = {
|
||||
.pulse = false,
|
||||
.duration = sz->rdev->timeout
|
||||
};
|
||||
sz->idle = true;
|
||||
if (sz->timeout_enabled)
|
||||
sz_push(sz, rawir);
|
||||
|
||||
@ -103,7 +103,7 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id)
|
||||
unsigned char dt;
|
||||
unsigned int cnt, rc;
|
||||
struct sunxi_ir *ir = dev_id;
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
|
||||
spin_lock(&ir->ir_lock);
|
||||
|
||||
|
||||
@ -121,12 +121,10 @@ static void ttusbir_bulk_complete(struct urb *urb)
|
||||
*/
|
||||
static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)
|
||||
{
|
||||
struct ir_raw_event rawir;
|
||||
struct ir_raw_event rawir = {};
|
||||
unsigned i, v, b;
|
||||
bool event = false;
|
||||
|
||||
init_ir_raw_event(&rawir);
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
v = buf[i] & 0xfe;
|
||||
switch (v) {
|
||||
|
||||
@ -340,11 +340,11 @@ wbcir_carrier_report(struct wbcir_data *data)
|
||||
inb(data->ebase + WBCIR_REG_ECEIR_CNT_HI) << 8;
|
||||
|
||||
if (counter > 0 && counter < 0xffff) {
|
||||
DEFINE_IR_RAW_EVENT(ev);
|
||||
|
||||
ev.carrier_report = 1;
|
||||
ev.carrier = DIV_ROUND_CLOSEST(counter * 1000000u,
|
||||
data->pulse_duration);
|
||||
struct ir_raw_event ev = {
|
||||
.carrier_report = 1,
|
||||
.carrier = DIV_ROUND_CLOSEST(counter * 1000000u,
|
||||
data->pulse_duration)
|
||||
};
|
||||
|
||||
ir_raw_event_store(data->dev, &ev);
|
||||
}
|
||||
@ -380,7 +380,7 @@ static void
|
||||
wbcir_irq_rx(struct wbcir_data *data, struct pnp_dev *device)
|
||||
{
|
||||
u8 irdata;
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
unsigned duration;
|
||||
|
||||
/* Since RXHDLEV is set, at least 8 bytes are in the FIFO */
|
||||
|
||||
@ -124,7 +124,7 @@ static int au8522_rc_andor(struct au0828_rc *ir, u16 reg, u8 mask, u8 value)
|
||||
static int au0828_get_key_au8522(struct au0828_rc *ir)
|
||||
{
|
||||
unsigned char buf[40];
|
||||
DEFINE_IR_RAW_EVENT(rawir);
|
||||
struct ir_raw_event rawir = {};
|
||||
int i, j, rc;
|
||||
int prv_bit, bit, width;
|
||||
bool first = true;
|
||||
@ -178,7 +178,6 @@ static int au0828_get_key_au8522(struct au0828_rc *ir)
|
||||
if (first) {
|
||||
first = false;
|
||||
|
||||
init_ir_raw_event(&rawir);
|
||||
rawir.pulse = true;
|
||||
if (width > NEC_START_SPACE - 2 &&
|
||||
width < NEC_START_SPACE + 2) {
|
||||
@ -197,7 +196,6 @@ static int au0828_get_key_au8522(struct au0828_rc *ir)
|
||||
ir_raw_event_store(ir->rc, &rawir);
|
||||
}
|
||||
|
||||
init_ir_raw_event(&rawir);
|
||||
rawir.pulse = prv_bit ? false : true;
|
||||
rawir.duration = AU8522_UNIT * width;
|
||||
dprintk(16, "Storing %s with duration %d",
|
||||
@ -210,7 +208,6 @@ static int au0828_get_key_au8522(struct au0828_rc *ir)
|
||||
}
|
||||
}
|
||||
|
||||
init_ir_raw_event(&rawir);
|
||||
rawir.pulse = prv_bit ? false : true;
|
||||
rawir.duration = AU8522_UNIT * width;
|
||||
dprintk(16, "Storing end %s with duration %d",
|
||||
|
||||
@ -1674,7 +1674,7 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d)
|
||||
{
|
||||
int ret, i, len;
|
||||
struct rtl28xxu_dev *dev = d->priv;
|
||||
struct ir_raw_event ev;
|
||||
struct ir_raw_event ev = {};
|
||||
u8 buf[128];
|
||||
static const struct rtl28xxu_reg_val_mask refresh_tab[] = {
|
||||
{IR_RX_IF, 0x03, 0xff},
|
||||
@ -1740,8 +1740,6 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d)
|
||||
}
|
||||
|
||||
/* pass data to Kernel IR decoder */
|
||||
init_ir_raw_event(&ev);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
ev.pulse = buf[i] >> 7;
|
||||
ev.duration = 50800 * (buf[i] & 0x7f);
|
||||
|
||||
@ -331,13 +331,6 @@ struct ir_raw_event {
|
||||
unsigned carrier_report:1;
|
||||
};
|
||||
|
||||
#define DEFINE_IR_RAW_EVENT(event) struct ir_raw_event event = {}
|
||||
|
||||
static inline void init_ir_raw_event(struct ir_raw_event *ev)
|
||||
{
|
||||
memset(ev, 0, sizeof(*ev));
|
||||
}
|
||||
|
||||
#define IR_DEFAULT_TIMEOUT MS_TO_NS(125)
|
||||
#define IR_MAX_DURATION 500000000 /* 500 ms */
|
||||
#define US_TO_NS(usec) ((usec) * 1000)
|
||||
@ -358,9 +351,7 @@ int ir_raw_encode_carrier(enum rc_proto protocol);
|
||||
|
||||
static inline void ir_raw_event_reset(struct rc_dev *dev)
|
||||
{
|
||||
struct ir_raw_event ev = { .reset = true };
|
||||
|
||||
ir_raw_event_store(dev, &ev);
|
||||
ir_raw_event_store(dev, &((struct ir_raw_event) { .reset = true }));
|
||||
dev->idle = true;
|
||||
ir_raw_event_handle(dev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user