drivers/auxdisplay/lcd2s.c
Source file repositories/reference/linux-study-clean/drivers/auxdisplay/lcd2s.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/auxdisplay/lcd2s.c- Extension
.c- Size
- 8999 bytes
- Lines
- 383
- Domain
- Driver Families
- Bucket
- drivers/auxdisplay
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hex.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/property.hlinux/slab.hlinux/i2c.hlinux/delay.hcharlcd.h
Detected Declarations
struct lcd2s_datafunction lcd2s_wait_buf_freefunction lcd2s_i2c_master_sendfunction lcd2s_i2c_smbus_write_bytefunction lcd2s_printfunction lcd2s_gotoxyfunction lcd2s_homefunction lcd2s_init_displayfunction lcd2s_shift_cursorfunction lcd2s_shift_displayfunction lcd2s_backlightfunction lcd2s_displayfunction lcd2s_cursorfunction lcd2s_blinkfunction lcd2s_fontsizefunction lcd2s_linesfunction lcd2s_redefine_charfunction lcd2s_clear_displayfunction lcd2s_i2c_probefunction lcd2s_i2c_remove
Annotated Snippet
struct lcd2s_data {
struct i2c_client *i2c;
struct charlcd *charlcd;
};
static s32 lcd2s_wait_buf_free(const struct i2c_client *client, int count)
{
s32 status;
status = i2c_smbus_read_byte_data(client, LCD2S_CMD_READ_STATUS);
if (status < 0)
return status;
while ((status & LCD2S_STATUS_BUF_MASK) < count) {
mdelay(1);
status = i2c_smbus_read_byte_data(client,
LCD2S_CMD_READ_STATUS);
if (status < 0)
return status;
}
return 0;
}
static int lcd2s_i2c_master_send(const struct i2c_client *client,
const char *buf, int count)
{
s32 status;
status = lcd2s_wait_buf_free(client, count);
if (status < 0)
return status;
return i2c_master_send(client, buf, count);
}
static int lcd2s_i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
{
s32 status;
status = lcd2s_wait_buf_free(client, 1);
if (status < 0)
return status;
return i2c_smbus_write_byte(client, value);
}
static int lcd2s_print(struct charlcd *lcd, int c)
{
struct lcd2s_data *lcd2s = lcd->drvdata;
u8 buf[2] = { LCD2S_CMD_WRITE, c };
int ret;
ret = lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));
if (ret < 0)
return ret;
if (ret != sizeof(buf))
return -EIO;
return 0;
}
static int lcd2s_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y)
{
struct lcd2s_data *lcd2s = lcd->drvdata;
u8 buf[3] = { LCD2S_CMD_CUR_POS, y + 1, x + 1 };
int ret;
ret = lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));
if (ret < 0)
return ret;
if (ret != sizeof(buf))
return -EIO;
return 0;
}
static int lcd2s_home(struct charlcd *lcd)
{
struct lcd2s_data *lcd2s = lcd->drvdata;
lcd2s_i2c_smbus_write_byte(lcd2s->i2c, LCD2S_CMD_CUR_RESET);
return 0;
}
static int lcd2s_init_display(struct charlcd *lcd)
{
struct lcd2s_data *lcd2s = lcd->drvdata;
/* turn everything off, but display on */
lcd2s_i2c_smbus_write_byte(lcd2s->i2c, LCD2S_CMD_DISPLAY_ON);
lcd2s_i2c_smbus_write_byte(lcd2s->i2c, LCD2S_CMD_BACKLIGHT_OFF);
lcd2s_i2c_smbus_write_byte(lcd2s->i2c, LCD2S_CMD_CUR_MOVES_FWD);
Annotation
- Immediate include surface: `linux/hex.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/property.h`, `linux/slab.h`, `linux/i2c.h`, `linux/delay.h`.
- Detected declarations: `struct lcd2s_data`, `function lcd2s_wait_buf_free`, `function lcd2s_i2c_master_send`, `function lcd2s_i2c_smbus_write_byte`, `function lcd2s_print`, `function lcd2s_gotoxy`, `function lcd2s_home`, `function lcd2s_init_display`, `function lcd2s_shift_cursor`, `function lcd2s_shift_display`.
- Atlas domain: Driver Families / drivers/auxdisplay.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.