Lines Matching +full:odd +full:- +full:parity

1 // SPDX-License-Identifier: GPL-2.0-only
10 * The Amstrad Delta keyboard (aka mailboard) uses normal PC-AT style serial
17 * However, when used with the E3 mailboard that producecs non-standard
21 #include <linux/platform_data/ams-delta-fiq.h>
28 #define DRIVER_NAME "ams-delta-serio"
42 int i, parity = 0; in check_data() local
46 dev_warn(&serio->dev, "invalid stop bit, data=0x%X\n", data); in check_data()
49 /* calculate the parity */ in check_data()
52 parity++; in check_data()
54 /* it should be odd */ in check_data()
55 if (!(parity & 0x01)) { in check_data()
56 dev_warn(&serio->dev, in check_data()
57 "parity check failed, data=0x%X parity=0x%X\n", data, in check_data()
58 parity); in check_data()
67 int *circ_buff = &priv->fiq_buffer[FIQ_CIRC_BUFF]; in ams_delta_serio_interrupt()
71 priv->fiq_buffer[FIQ_IRQ_PEND] = 0; in ams_delta_serio_interrupt()
77 while (priv->fiq_buffer[FIQ_KEYS_CNT] > 0) { in ams_delta_serio_interrupt()
79 data = circ_buff[priv->fiq_buffer[FIQ_HEAD_OFFSET]++]; in ams_delta_serio_interrupt()
80 priv->fiq_buffer[FIQ_KEYS_CNT]--; in ams_delta_serio_interrupt()
81 if (priv->fiq_buffer[FIQ_HEAD_OFFSET] == in ams_delta_serio_interrupt()
82 priv->fiq_buffer[FIQ_BUF_LEN]) in ams_delta_serio_interrupt()
83 priv->fiq_buffer[FIQ_HEAD_OFFSET] = 0; in ams_delta_serio_interrupt()
85 dfl = check_data(priv->serio, data); in ams_delta_serio_interrupt()
87 serio_interrupt(priv->serio, scancode, dfl); in ams_delta_serio_interrupt()
94 struct ams_delta_serio *priv = serio->port_data; in ams_delta_serio_open()
97 return regulator_enable(priv->vcc); in ams_delta_serio_open()
102 struct ams_delta_serio *priv = serio->port_data; in ams_delta_serio_close()
105 regulator_disable(priv->vcc); in ams_delta_serio_close()
114 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in ams_delta_serio_init()
116 return -ENOMEM; in ams_delta_serio_init()
118 priv->fiq_buffer = pdev->dev.platform_data; in ams_delta_serio_init()
119 if (!priv->fiq_buffer) in ams_delta_serio_init()
120 return -EINVAL; in ams_delta_serio_init()
122 priv->vcc = devm_regulator_get(&pdev->dev, "vcc"); in ams_delta_serio_init()
123 if (IS_ERR(priv->vcc)) { in ams_delta_serio_init()
124 err = PTR_ERR(priv->vcc); in ams_delta_serio_init()
125 dev_err(&pdev->dev, "regulator request failed (%d)\n", err); in ams_delta_serio_init()
127 * When running on a non-dt platform and requested regulator in ams_delta_serio_init()
129 * -EPROBE_DEFER as it is not able to justify if the regulator in ams_delta_serio_init()
133 * if sufficient. Hence, if we get -ENODEV here, let's convert in ams_delta_serio_init()
134 * it to -EPROBE_DEFER and wait for the board to decide or in ams_delta_serio_init()
137 if (err == -ENODEV) in ams_delta_serio_init()
138 err = -EPROBE_DEFER; in ams_delta_serio_init()
144 return -ENXIO; in ams_delta_serio_init()
146 err = devm_request_irq(&pdev->dev, irq, ams_delta_serio_interrupt, in ams_delta_serio_init()
149 dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); in ams_delta_serio_init()
155 return -ENOMEM; in ams_delta_serio_init()
157 priv->serio = serio; in ams_delta_serio_init()
159 serio->id.type = SERIO_8042; in ams_delta_serio_init()
160 serio->open = ams_delta_serio_open; in ams_delta_serio_init()
161 serio->close = ams_delta_serio_close; in ams_delta_serio_init()
162 strscpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name)); in ams_delta_serio_init()
163 strscpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); in ams_delta_serio_init()
164 serio->dev.parent = &pdev->dev; in ams_delta_serio_init()
165 serio->port_data = priv; in ams_delta_serio_init()
171 dev_info(&serio->dev, "%s\n", serio->name); in ams_delta_serio_init()
180 serio_unregister_port(priv->serio); in ams_delta_serio_exit()