cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

wm8731-i2c.c (1492B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/*
      3 * wm8731-i2c.c  --  WM8731 ALSA SoC Audio driver I2C code
      4 *
      5 * Copyright 2005 Openedhand Ltd.
      6 * Copyright 2006-12 Wolfson Microelectronics, plc
      7 *
      8 * Author: Richard Purdie <richard@openedhand.com>
      9 *
     10 * Based on wm8753.c by Liam Girdwood
     11 */
     12
     13#include <linux/i2c.h>
     14#include <linux/module.h>
     15#include <linux/of_device.h>
     16
     17#include "wm8731.h"
     18
     19
     20static const struct of_device_id wm8731_of_match[] = {
     21	{ .compatible = "wlf,wm8731", },
     22	{ }
     23};
     24MODULE_DEVICE_TABLE(of, wm8731_of_match);
     25
     26static int wm8731_i2c_probe(struct i2c_client *i2c)
     27{
     28	struct wm8731_priv *wm8731;
     29	int ret;
     30
     31	wm8731 = devm_kzalloc(&i2c->dev, sizeof(struct wm8731_priv),
     32			      GFP_KERNEL);
     33	if (wm8731 == NULL)
     34		return -ENOMEM;
     35
     36	i2c_set_clientdata(i2c, wm8731);
     37
     38	wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
     39	if (IS_ERR(wm8731->regmap)) {
     40		ret = PTR_ERR(wm8731->regmap);
     41		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
     42			ret);
     43		return ret;
     44	}
     45
     46	return wm8731_init(&i2c->dev, wm8731);
     47}
     48
     49static const struct i2c_device_id wm8731_i2c_id[] = {
     50	{ "wm8731", 0 },
     51	{ }
     52};
     53MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
     54
     55static struct i2c_driver wm8731_i2c_driver = {
     56	.driver = {
     57		.name = "wm8731",
     58		.of_match_table = wm8731_of_match,
     59	},
     60	.probe_new = wm8731_i2c_probe,
     61	.id_table = wm8731_i2c_id,
     62};
     63
     64module_i2c_driver(wm8731_i2c_driver);
     65
     66MODULE_DESCRIPTION("ASoC WM8731 driver - I2C");
     67MODULE_AUTHOR("Richard Purdie");
     68MODULE_LICENSE("GPL");