Skip to content
Snippets Groups Projects
Select Git revision
  • 0ffa0285052607513a29f529ddb5061c907fd8a6
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

spi.c

Blame
  • spi.c 17.96 KiB
    /*
     * spi.c - SPI init/core code
     *
     * Copyright (C) 2005 David Brownell
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     */
    
    #include <linux/autoconf.h>
    #include <linux/kernel.h>
    #include <linux/device.h>
    #include <linux/init.h>
    #include <linux/cache.h>
    #include <linux/spi/spi.h>
    
    
    /* SPI bustype and spi_master class are registered after board init code
     * provides the SPI device tables, ensuring that both are present by the
     * time controller driver registration causes spi_devices to "enumerate".
     */
    static void spidev_release(struct device *dev)
    {
    	struct spi_device	*spi = to_spi_device(dev);
    
    	/* spi masters may cleanup for released devices */
    	if (spi->master->cleanup)
    		spi->master->cleanup(spi);
    
    	spi_master_put(spi->master);
    	kfree(dev);
    }
    
    static ssize_t
    modalias_show(struct device *dev, struct device_attribute *a, char *buf)
    {
    	const struct spi_device	*spi = to_spi_device(dev);
    
    	return snprintf(buf, BUS_ID_SIZE + 1, "%s\n", spi->modalias);
    }
    
    static struct device_attribute spi_dev_attrs[] = {
    	__ATTR_RO(modalias),
    	__ATTR_NULL,
    };
    
    /* modalias support makes "modprobe $MODALIAS" new-style hotplug work,
     * and the sysfs version makes coldplug work too.
     */
    
    static int spi_match_device(struct device *dev, struct device_driver *drv)
    {
    	const struct spi_device	*spi = to_spi_device(dev);
    
    	return strncmp(spi->modalias, drv->name, BUS_ID_SIZE) == 0;
    }
    
    static int spi_uevent(struct device *dev, char **envp, int num_envp,
    		char *buffer, int buffer_size)