리눅스 디바이스 드라이버의 call back 함수의 매개변수는 어떻게 결정되냐요?

rlatjrdnjs의 이미지

hardkernel의 odroid xu3의 커널 코드를 분석하고 있습니다.

ina231이라는 sensor의 디바이스 드라이버 코드를 보고있는데 궁금한점이 있어 질문드립니다.

static int 	ina231_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    int     rc = 0;
    struct  ina231_sensor   *sensor;
 
	if(!(sensor = devm_kzalloc(&client->dev, sizeof(struct ina231_sensor), GFP_KERNEL)))	{
		dev_err(&client->dev, "INA231 Sensor struct malloc error!\n");
		return	-ENOMEM;
	}
    // mutex init	
	mutex_init(&sensor->mutex);
 
	sensor->client	= client;
 
    if (client->dev.of_node)    {
        if(ina231_i2c_dt_parse(client, sensor) < 0)    goto     out;
    }
    else    {
        sensor->pd = client->dev.platform_data;
    }
 
	i2c_set_clientdata(client, sensor);
 
    // Calculate current lsb value
    sensor->cur_lsb_uA  = sensor->pd->max_A * 1000000 / 32768;
    // Calculate register value
    sensor->reg_calibration = 5120000 / (sensor->cur_lsb_uA * sensor->pd->shunt_R_mohm);
 
    if((rc = ina231_i2c_write(sensor->client, REG_CONFIG,      sensor->pd->config))        < 0) goto out;
    if((rc = ina231_i2c_write(sensor->client, REG_CALIBRATION, sensor->reg_calibration))   < 0) goto out;
    if((rc = ina231_i2c_write(sensor->client, REG_ALERT_EN,    0x0000))  < 0)                   goto out;
    if((rc = ina231_i2c_write(sensor->client, REG_ALERT_LIMIT, 0x0000))  < 0)                   goto out;
 
    if((rc = ina231_i2c_read(sensor->client, REG_CONFIG      )) != sensor->pd->config      )    goto out;
    if((rc = ina231_i2c_read(sensor->client, REG_CALIBRATION )) != sensor->reg_calibration )    goto out;
    if((rc = ina231_i2c_read(sensor->client, REG_ALERT_EN    )) != 0x0000)                      goto out;
    if((rc = ina231_i2c_read(sensor->client, REG_ALERT_LIMIT )) != 0x0000)                      goto out;
 
    // misc driver probe
    if(ina231_misc_probe(sensor) < 0)           goto out;
 
    // sysfs probe
    if(ina231_sysfs_create(&client->dev) < 0)   goto out;
 
    // timer run for sensor data receive
    INIT_WORK(&sensor->work, ina231_work);
    if((sensor->wq = create_singlethread_workqueue("ina231_wq")) == NULL)	goto out;
 
    hrtimer_init(&sensor->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    sensor->timer_sec  = sensor->pd->update_period / 1000000;
    sensor->timer_nsec = sensor->pd->update_period % 1000000;
    sensor->timer_nsec = sensor->timer_nsec * 1000;
    sensor->timer.function = ina231_timer;
 
    if(sensor->pd->enable)  ina231_i2c_enable(sensor);
 
    // display register message
    rc = 0;
    dev_info(&client->dev, "============= Probe INA231 : %s ============= \n", sensor->pd->name);
    dev_info(&client->dev, "SENSOR ENABLE   : %s\n"     , sensor->pd->enable ? "true" : "false");
    dev_info(&client->dev, "REG CONFIG      : 0x%04X\n" , sensor->pd->config        );
    dev_info(&client->dev, "REG CALIBRATION : 0x%04X\n" , sensor->reg_calibration   );
    dev_info(&client->dev, "SHUNT Resister  : %d mOhm\n", sensor->pd->shunt_R_mohm  );
    dev_info(&client->dev, "MAX Current     : %d A\n"   , sensor->pd->max_A         );
    dev_info(&client->dev, "Current LSB uA  : %d uA\n"  , sensor->cur_lsb_uA        );
    dev_info(&client->dev, "Conversion Time : %d us\n"  , sensor->pd->update_period );
    dev_info(&client->dev, "=====================================================\n");
 
    return  0;
out:
    dev_err(&client->dev, "============= Probe INA231 Fail! : %s (0x%04X) ============= \n", sensor->pd->name, rc); 
 
	return rc;
}

static struct i2c_driver ina231_i2c_driver = {
	.driver = {
		.name	= INA231_I2C_NAME,
		.owner	= THIS_MODULE,
	},
	.probe		= ina231_i2c_probe,
	.remove		= ina231_i2c_remove,
	.suspend	= ina231_i2c_suspend,
	.resume		= ina231_i2c_resume,
	.id_table	= ina231_id,
};

이와같이 i2c_driver 구조체의 probe 에 연결돼있습니다.

공부를 하여 probe는 binding 될 때 callback 해준다는 것 까지는 알았는데 이 함수가 call될때 매개변수로 어떤 값을 갖는지 도저히 찾을 수 없어 질문드립니다.

고수분들의 답변 부탁드립니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.