Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a394c6a0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull PCMCIA update from Dominik Brodowski:
 "A few PCMCIA fixes and cleanups are available in the PCMCIA tree.

  Most of them are trivial and self-explanatory.  Of particular note are
  the last three patches which add an important hardware quirk for
  Toshiba ToPIC95 sockets (or BIOS breakage on systems with these
  sockets), fix resource leaks in yenta_socket enable/disable call
  paths, and fix a regression caused by patch 1c6c9b1d since v4.0.

  Alan stated he is OK with me pushing this patch upstream.  Once it
  works out well in your tree, I will push it to stable for 4.0/4.1 as
  well"

* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia:
  pcmcia: do not break rsrc_nonstatic when handling anonymous cards
  pcmcia: Fix resource leaks in yenta_probe() and _close()
  Disable write buffering on Toshiba ToPIC95
  pcmcia: Convert dev_printk to dev_<level>
  pcmcia/vrc4171: Remove typedefs for enums and struct
  pcmcia: Remove typedef in structs and emum
  pcmcia: Remove typedef tuple_flags
  drivers: pcmcia: electra_cf.c fix checkpatch error and warnings
  drivers: pcmcia: ds.c fix checkpatch errors
  PCMCIA: Remove commented references to dead class_device_create_file()
  drivers/pcmcia/electra_cf.c: add missing iounmap and kfree
  pcmcia: replace open-coded ARRAY_SIZE with macro
parents d8133356 e8e68fd8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -532,8 +532,7 @@ static int reader_config(struct pcmcia_device *link, int devno)

	fail_rc = pcmcia_enable_device(link);
	if (fail_rc != 0) {
		dev_printk(KERN_INFO, &link->dev,
			   "pcmcia_enable_device failed 0x%x\n",
		dev_info(&link->dev, "pcmcia_enable_device failed 0x%x\n",
			 fail_rc);
		goto cs_release;
	}
+19 −31
Original line number Diff line number Diff line
@@ -94,8 +94,7 @@ static void __iomem *set_cis_map(struct pcmcia_socket *s,
		mem->res = pcmcia_find_mem_region(0, s->map_size,
						s->map_size, 0, s);
		if (mem->res == NULL) {
			dev_printk(KERN_NOTICE, &s->dev,
				   "cs: unable to map card memory!\n");
			dev_notice(&s->dev, "cs: unable to map card memory!\n");
			return NULL;
		}
		s->cis_virt = NULL;
@@ -381,8 +380,7 @@ int verify_cis_cache(struct pcmcia_socket *s)

	buf = kmalloc(256, GFP_KERNEL);
	if (buf == NULL) {
		dev_printk(KERN_WARNING, &s->dev,
			   "no memory for verifying CIS\n");
		dev_warn(&s->dev, "no memory for verifying CIS\n");
		return -ENOMEM;
	}
	mutex_lock(&s->ops_mutex);
@@ -414,14 +412,14 @@ int pcmcia_replace_cis(struct pcmcia_socket *s,
		       const u8 *data, const size_t len)
{
	if (len > CISTPL_MAX_CIS_SIZE) {
		dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n");
		dev_warn(&s->dev, "replacement CIS too big\n");
		return -EINVAL;
	}
	mutex_lock(&s->ops_mutex);
	kfree(s->fake_cis);
	s->fake_cis = kmalloc(len, GFP_KERNEL);
	if (s->fake_cis == NULL) {
		dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n");
		dev_warn(&s->dev, "no memory to replace CIS\n");
		mutex_unlock(&s->ops_mutex);
		return -ENOMEM;
	}
@@ -434,17 +432,17 @@ int pcmcia_replace_cis(struct pcmcia_socket *s,

/* The high-level CIS tuple services */

typedef struct tuple_flags {
struct tuple_flags {
	u_int		link_space:4;
	u_int		has_link:1;
	u_int		mfc_fn:3;
	u_int		space:4;
} tuple_flags;
};

#define LINK_SPACE(f)	(((tuple_flags *)(&(f)))->link_space)
#define HAS_LINK(f)	(((tuple_flags *)(&(f)))->has_link)
#define MFC_FN(f)	(((tuple_flags *)(&(f)))->mfc_fn)
#define SPACE(f)	(((tuple_flags *)(&(f)))->space)
#define LINK_SPACE(f)	(((struct tuple_flags *)(&(f)))->link_space)
#define HAS_LINK(f)	(((struct tuple_flags *)(&(f)))->has_link)
#define MFC_FN(f)	(((struct tuple_flags *)(&(f)))->mfc_fn)
#define SPACE(f)	(((struct tuple_flags *)(&(f)))->space)

int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
			tuple_t *tuple)
@@ -1451,26 +1449,16 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
done:
	/* invalidate CIS cache on failure */
	if (!dev_ok || !ident_ok || !count) {
#if defined(CONFIG_MTD_PCMCIA_ANONYMOUS)
		/* Set up as an anonymous card. If we don't have anonymous
		   memory support then just error the card as there is no
		   point trying to second guess.

		   Note: some cards have just a device entry, it may be
		   worth extending support to cover these in future */
		if (!dev_ok || !ident_ok) {
			dev_info(&s->dev, "no CIS, assuming an anonymous memory card.\n");
			pcmcia_replace_cis(s, "\xFF", 1);
			count = 1;
			ret = 0;
		} else
#endif
		{
		mutex_lock(&s->ops_mutex);
		destroy_cis_cache(s);
		mutex_unlock(&s->ops_mutex);
		/* We differentiate between dev_ok, ident_ok and count
		   failures to allow for an override for anonymous cards
		   in ds.c */
		if (!dev_ok || !ident_ok)
			ret = -EIO;
		}
		else
			ret = -EFAULT;
	}

	if (info)
+12 −17
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)

	wait_for_completion(&socket->thread_done);
	if (!socket->thread) {
		dev_printk(KERN_WARNING, &socket->dev,
		dev_warn(&socket->dev,
			 "PCMCIA: warning: socket thread did not start\n");
		return -EIO;
	}
@@ -275,7 +275,7 @@ static int socket_reset(struct pcmcia_socket *skt)
		msleep(unreset_check * 10);
	}

	dev_printk(KERN_ERR, &skt->dev, "time out after reset.\n");
	dev_err(&skt->dev, "time out after reset\n");
	return -ETIMEDOUT;
}

@@ -325,7 +325,7 @@ static void socket_shutdown(struct pcmcia_socket *s)

	s->ops->get_status(s, &status);
	if (status & SS_POWERON) {
		dev_printk(KERN_ERR, &s->dev,
		dev_err(&s->dev,
			"*** DANGER *** unable to remove socket power\n");
	}

@@ -356,15 +356,13 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
	}

	if (status & SS_PENDING) {
		dev_printk(KERN_ERR, &skt->dev,
			   "voltage interrogation timed out.\n");
		dev_err(&skt->dev, "voltage interrogation timed out\n");
		return -ETIMEDOUT;
	}

	if (status & SS_CARDBUS) {
		if (!(skt->features & SS_CAP_CARDBUS)) {
			dev_printk(KERN_ERR, &skt->dev,
				"cardbus cards are not supported.\n");
			dev_err(&skt->dev, "cardbus cards are not supported\n");
			return -EINVAL;
		}
		skt->state |= SOCKET_CARDBUS;
@@ -379,7 +377,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
	else if (!(status & SS_XVCARD))
		skt->socket.Vcc = skt->socket.Vpp = 50;
	else {
		dev_printk(KERN_ERR, &skt->dev, "unsupported voltage key.\n");
		dev_err(&skt->dev, "unsupported voltage key\n");
		return -EIO;
	}

@@ -396,7 +394,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)

	skt->ops->get_status(skt, &status);
	if (!(status & SS_POWERON)) {
		dev_printk(KERN_ERR, &skt->dev, "unable to apply power.\n");
		dev_err(&skt->dev, "unable to apply power\n");
		return -EIO;
	}

@@ -429,8 +427,7 @@ static int socket_insert(struct pcmcia_socket *skt)
	if (ret == 0) {
		skt->state |= SOCKET_PRESENT;

		dev_printk(KERN_NOTICE, &skt->dev,
			   "pccard: %s card inserted into slot %d\n",
		dev_notice(&skt->dev, "pccard: %s card inserted into slot %d\n",
			   (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
			   skt->sock);

@@ -558,8 +555,7 @@ static int socket_resume(struct pcmcia_socket *skt)

static void socket_remove(struct pcmcia_socket *skt)
{
	dev_printk(KERN_NOTICE, &skt->dev,
		   "pccard: card ejected from slot %d\n", skt->sock);
	dev_notice(&skt->dev, "pccard: card ejected from slot %d\n", skt->sock);
	socket_shutdown(skt);
}

@@ -605,8 +601,7 @@ static int pccardd(void *__skt)
	/* register with the device core */
	ret = device_register(&skt->dev);
	if (ret) {
		dev_printk(KERN_WARNING, &skt->dev,
			   "PCMCIA: unable to register socket\n");
		dev_warn(&skt->dev, "PCMCIA: unable to register socket\n");
		skt->thread = NULL;
		complete(&skt->thread_done);
		return 0;
+44 −32
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ static int pcmcia_device_probe(struct device *dev)
		dev_dbg(dev, "base %x, regs %x", p_dev->config_base,
			p_dev->config_regs);
	} else {
		dev_printk(KERN_INFO, dev,
		dev_info(dev,
			 "pcmcia: could not parse base and rmask0 of CIS\n");
		p_dev->config_base = 0;
		p_dev->config_regs = 0;
@@ -382,13 +382,13 @@ static int pcmcia_device_remove(struct device *dev)

	/* check for proper unloading */
	if (p_dev->_irq || p_dev->_io || p_dev->_locked)
		dev_printk(KERN_INFO, dev,
		dev_info(dev,
			 "pcmcia: driver %s did not release config properly\n",
			 p_drv->name);

	for (i = 0; i < MAX_WIN; i++)
		if (p_dev->_win & CLIENT_WIN_REQ(i))
			dev_printk(KERN_INFO, dev,
			dev_info(dev,
				 "pcmcia: driver %s did not release window properly\n",
				 p_drv->name);

@@ -578,8 +578,7 @@ static struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s,

	mutex_unlock(&s->ops_mutex);

	dev_printk(KERN_NOTICE, &p_dev->dev,
		   "pcmcia: registering new device %s (IRQ: %d)\n",
	dev_notice(&p_dev->dev, "pcmcia: registering new device %s (IRQ: %d)\n",
		   p_dev->devname, p_dev->irq);

	pcmcia_device_query(p_dev);
@@ -634,9 +633,25 @@ static int pcmcia_card_add(struct pcmcia_socket *s)

	ret = pccard_validate_cis(s, &no_chains);
	if (ret || !no_chains) {
#if defined(CONFIG_MTD_PCMCIA_ANONYMOUS)
		/* Set up as an anonymous card. If we don't have anonymous
		   memory support then just error the card as there is no
		   point trying to second guess.

		   Note: some cards have just a device entry, it may be
		   worth extending support to cover these in future */
		if (ret == -EIO) {
			dev_info(&s->dev, "no CIS, assuming an anonymous memory card.\n");
			pcmcia_replace_cis(s, "\xFF", 1);
			no_chains = 1;
			ret = 0;
		} else
#endif
		{
			dev_dbg(&s->dev, "invalid CIS or invalid resources\n");
			return -ENODEV;
		}
	}

	if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
		no_funcs = mfc.nfn;
@@ -745,16 +760,14 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
	if (request_firmware(&fw, filename, &dev->dev) == 0) {
		if (fw->size >= CISTPL_MAX_CIS_SIZE) {
			ret = -EINVAL;
			dev_printk(KERN_ERR, &dev->dev,
				   "pcmcia: CIS override is too big\n");
			dev_err(&dev->dev, "pcmcia: CIS override is too big\n");
			goto release;
		}

		if (!pcmcia_replace_cis(s, fw->data, fw->size))
			ret = 0;
		else {
			dev_printk(KERN_ERR, &dev->dev,
				   "pcmcia: CIS override failed\n");
			dev_err(&dev->dev, "pcmcia: CIS override failed\n");
			goto release;
		}

@@ -781,7 +794,8 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)

#else /* !CONFIG_PCMCIA_LOAD_CIS */

static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
static inline int pcmcia_load_firmware(struct pcmcia_device *dev,
				       char *filename)
{
	return -ENODEV;
}
@@ -1148,9 +1162,8 @@ static int pcmcia_dev_suspend(struct device *dev, pm_message_t state)
	if (p_drv->suspend) {
		ret = p_drv->suspend(p_dev);
		if (ret) {
			dev_printk(KERN_ERR, dev,
				   "pcmcia: device %s (driver %s) did "
				   "not want to go to sleep (%d)\n",
			dev_err(dev,
				"pcmcia: device %s (driver %s) did not want to go to sleep (%d)\n",
				p_dev->devname, p_drv->name, ret);
			mutex_lock(&p_dev->socket->ops_mutex);
			p_dev->suspended = 0;
@@ -1342,14 +1355,13 @@ static int pcmcia_bus_add_socket(struct device *dev,

	socket = pcmcia_get_socket(socket);
	if (!socket) {
		dev_printk(KERN_ERR, dev,
			   "PCMCIA obtaining reference to socket failed\n");
		dev_err(dev, "PCMCIA obtaining reference to socket failed\n");
		return -ENODEV;
	}

	ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr);
	if (ret) {
		dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n");
		dev_err(dev, "PCMCIA registration failed\n");
		pcmcia_put_socket(socket);
		return ret;
	}
@@ -1361,7 +1373,7 @@ static int pcmcia_bus_add_socket(struct device *dev,

	ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback);
	if (ret) {
		dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n");
		dev_err(dev, "PCMCIA registration failed\n");
		pcmcia_put_socket(socket);
		return ret;
	}
+11 −8
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ static int electra_cf_probe(struct platform_device *ofdev)
	if (err)
		return -EINVAL;

	cf = kzalloc(sizeof *cf, GFP_KERNEL);
	cf = kzalloc(sizeof(*cf), GFP_KERNEL);
	if (!cf)
		return -ENOMEM;

@@ -216,8 +216,10 @@ static int electra_cf_probe(struct platform_device *ofdev)
	cf->io_size = PAGE_ALIGN(resource_size(&io));

	area = __get_vm_area(cf->io_size, 0, PHB_IO_BASE, PHB_IO_END);
	if (area == NULL)
		return -ENOMEM;
	if (area == NULL) {
		status = -ENOMEM;
		goto fail1;
	}

	cf->io_virt = (void __iomem *)(area->addr);

@@ -320,6 +322,7 @@ static int electra_cf_probe(struct platform_device *ofdev)
		iounmap(cf->mem_base);
	if (cf->gpio_base)
		iounmap(cf->gpio_base);
	if (area)
		device_init_wakeup(&ofdev->dev, 0);
	kfree(cf);
	return status;
Loading